[PATCH 08/10] explorerframe/nstc: Create the treeview on initialization.
David Hedberg
david.hedberg at gmail.com
Sat Jul 31 13:02:52 CDT 2010
---
dlls/explorerframe/Makefile.in | 2 +-
dlls/explorerframe/explorerframe_main.h | 3 +
dlls/explorerframe/nstc.c | 114 +++++++++++++++++++++++++++++++
3 files changed, 118 insertions(+), 1 deletions(-)
diff --git a/dlls/explorerframe/Makefile.in b/dlls/explorerframe/Makefile.in
index b2c306e..83eceeb 100644
--- a/dlls/explorerframe/Makefile.in
+++ b/dlls/explorerframe/Makefile.in
@@ -4,7 +4,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = explorerframe.dll
-IMPORTS = uuid user32
+IMPORTS = uuid shell32 user32
C_SRCS = \
explorerframe_main.c \
diff --git a/dlls/explorerframe/explorerframe_main.h b/dlls/explorerframe/explorerframe_main.h
index 26d0f7f..09a50de 100644
--- a/dlls/explorerframe/explorerframe_main.h
+++ b/dlls/explorerframe/explorerframe_main.h
@@ -23,6 +23,9 @@
#include "shlobj.h"
+/* Not declared in commctrl.h ("for internal use (msdn)") */
+#define TVS_EX_NOSINGLECOLLAPSE 0x0001
+
extern HINSTANCE explorerframe_hinstance;
extern LONG EFRAME_refCount;
diff --git a/dlls/explorerframe/nstc.c b/dlls/explorerframe/nstc.c
index bd37492..884be77 100644
--- a/dlls/explorerframe/nstc.c
+++ b/dlls/explorerframe/nstc.c
@@ -39,20 +39,116 @@ typedef struct {
LONG ref;
HWND hwnd_main;
+ HWND hwnd_tv;
NSTCSTYLE style;
} NSTC2Impl;
+static const DWORD unsupported_styles =
+ NSTCS_SINGLECLICKEXPAND | NSTCS_NOREPLACEOPEN | NSTCS_NOORDERSTREAM | NSTCS_FAVORITESMODE |
+ NSTCS_EMPTYTEXT | NSTCS_ALLOWJUNCTIONS | NSTCS_SHOWTABSBUTTON | NSTCS_SHOWDELETEBUTTON |
+ NSTCS_SHOWREFRESHBUTTON | NSTCS_SPRINGEXPAND | NSTCS_RICHTOOLTIP | NSTCS_NOINDENTCHECKS;
+
+/*************************************************************************
+ * NamespaceTree helper functions
+ */
+static DWORD treeview_style_from_nstcs(NSTC2Impl *This, NSTCSTYLE nstcs,
+ NSTCSTYLE nstcs_mask, DWORD *new_style)
+{
+ DWORD old_style, tv_mask = 0;
+ TRACE("%p, %x, %x, %p\n", This, nstcs, nstcs_mask, new_style);
+
+ if(This->hwnd_tv)
+ old_style = GetWindowLongPtrW(This->hwnd_tv, GWL_STYLE);
+ else
+ old_style = /* The default */
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
+ WS_TABSTOP | TVS_NOHSCROLL | TVS_NONEVENHEIGHT | TVS_INFOTIP |
+ TVS_EDITLABELS | TVS_TRACKSELECT;
+
+ if(nstcs_mask & NSTCS_HASEXPANDOS) tv_mask |= TVS_HASBUTTONS;
+ if(nstcs_mask & NSTCS_HASLINES) tv_mask |= TVS_HASLINES;
+ if(nstcs_mask & NSTCS_FULLROWSELECT) tv_mask |= TVS_FULLROWSELECT;
+ if(nstcs_mask & NSTCS_HORIZONTALSCROLL) tv_mask |= TVS_NOHSCROLL;
+ if(nstcs_mask & NSTCS_ROOTHASEXPANDO) tv_mask |= TVS_LINESATROOT;
+ if(nstcs_mask & NSTCS_SHOWSELECTIONALWAYS) tv_mask |= TVS_SHOWSELALWAYS;
+ if(nstcs_mask & NSTCS_NOINFOTIP) tv_mask |= TVS_INFOTIP;
+ if(nstcs_mask & NSTCS_EVENHEIGHT) tv_mask |= TVS_NONEVENHEIGHT;
+ if(nstcs_mask & NSTCS_DISABLEDRAGDROP) tv_mask |= TVS_DISABLEDRAGDROP;
+ if(nstcs_mask & NSTCS_NOEDITLABELS) tv_mask |= TVS_EDITLABELS;
+ if(nstcs_mask & NSTCS_CHECKBOXES) tv_mask |= TVS_CHECKBOXES;
+
+ *new_style = old_style & ~tv_mask;
+
+ if(nstcs & NSTCS_HASEXPANDOS) *new_style |= TVS_HASBUTTONS;
+ if(nstcs & NSTCS_HASLINES) *new_style |= TVS_HASLINES;
+ if(nstcs & NSTCS_FULLROWSELECT) *new_style |= TVS_FULLROWSELECT;
+ if(!(nstcs & NSTCS_HORIZONTALSCROLL)) *new_style |= TVS_NOHSCROLL;
+ if(nstcs & NSTCS_ROOTHASEXPANDO) *new_style |= TVS_LINESATROOT;
+ if(nstcs & NSTCS_SHOWSELECTIONALWAYS) *new_style |= TVS_SHOWSELALWAYS;
+ if(!(nstcs & NSTCS_NOINFOTIP)) *new_style |= TVS_INFOTIP;
+ if(!(nstcs & NSTCS_EVENHEIGHT)) *new_style |= TVS_NONEVENHEIGHT;
+ if(nstcs & NSTCS_DISABLEDRAGDROP) *new_style |= TVS_DISABLEDRAGDROP;
+ if(!(nstcs & NSTCS_NOEDITLABELS)) *new_style |= TVS_EDITLABELS;
+ if(nstcs & NSTCS_CHECKBOXES) *new_style |= TVS_CHECKBOXES;
+
+ TRACE("old: %08x, new: %08x\n", old_style, *new_style);
+
+ return old_style^*new_style;
+}
+
/*************************************************************************
* NamespaceTree Window Functions
*/
static LRESULT create_namespacetree(HWND hWnd, CREATESTRUCTW *crs)
{
NSTC2Impl *This = crs->lpCreateParams;
+ HIMAGELIST ShellSmallIconList;
+ DWORD treeview_style, treeview_ex_style;
TRACE("%p (%p)\n", This, crs);
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LPARAM)This);
+ treeview_style_from_nstcs(This, This->style, 0xFFFFFFFF, &treeview_style);
+
+ /* Create the treeview */
+ This->hwnd_tv = CreateWindowExW(0, WC_TREEVIEWW, NULL, treeview_style,
+ 0, 0, 0, 0,
+ hWnd, NULL, explorerframe_hinstance, NULL);
+
+ if(!This->hwnd_tv)
+ {
+ ERR("Failed to create treeview!\n");
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+
+ /* Some default extended styles */
+ treeview_ex_style = TVS_EX_DRAWIMAGEASYNC | TVS_EX_RICHTOOLTIP |
+ TVS_EX_DOUBLEBUFFER | TVS_EX_NOSINGLECOLLAPSE;
+
+ if(This->style & NSTCS_AUTOHSCROLL)
+ treeview_ex_style |= TVS_EX_AUTOHSCROLL;
+ if(This->style & NSTCS_FADEINOUTEXPANDOS)
+ treeview_ex_style |= TVS_EX_FADEINOUTEXPANDOS;
+ if(This->style & NSTCS_PARTIALCHECKBOXES)
+ treeview_ex_style |= TVS_EX_PARTIALCHECKBOXES;
+ if(This->style & NSTCS_EXCLUSIONCHECKBOXES)
+ treeview_ex_style |= TVS_EX_EXCLUSIONCHECKBOXES;
+ if(This->style & NSTCS_DIMMEDCHECKBOXES)
+ treeview_ex_style |= TVS_EX_DIMMEDCHECKBOXES;
+
+ SendMessageW(This->hwnd_tv, TVM_SETEXTENDEDSTYLE, treeview_ex_style, 0xffff);
+
+ /* Get and Set the image list */
+ if(Shell_GetImageLists(NULL, &ShellSmallIconList))
+ {
+ SendMessageW(This->hwnd_tv, TVM_SETIMAGELIST,
+ (WPARAM)TVSIL_NORMAL, (LPARAM)ShellSmallIconList);
+ }
+ else
+ {
+ ERR("Failed to get the System Image List.\n");
+ }
/* Native is not destroyed until the window is destroyed. */
INameSpaceTreeControl_AddRef((INameSpaceTreeControl*)This);
@@ -60,6 +156,19 @@ static LRESULT create_namespacetree(HWND hWnd, CREATESTRUCTW *crs)
return TRUE;
}
+static LRESULT resize_namespacetree(NSTC2Impl *This)
+{
+ RECT rc;
+ TRACE("%p\n", This);
+
+ /* Resize the treeview to fit inside the window */
+ GetClientRect(This->hwnd_main, &rc);
+ SetWindowPos(This->hwnd_tv, HWND_TOP, rc.left, rc.top,
+ rc.right, rc.bottom, SWP_SHOWWINDOW);
+
+ return TRUE;
+}
+
static LRESULT destroy_namespacetree(NSTC2Impl *This)
{
TRACE("%p\n", This);
@@ -77,6 +186,7 @@ static LRESULT CALLBACK NSTC2_WndProc(HWND hWnd, UINT uMessage,
switch(uMessage)
{
case WM_NCCREATE: return create_namespacetree(hWnd, (CREATESTRUCTW*)lParam);
+ case WM_SIZE: return resize_namespacetree(This);
case WM_DESTROY: return destroy_namespacetree(This);
default: return DefWindowProcW(hWnd, uMessage, wParam, lParam);
}
@@ -152,6 +262,10 @@ static HRESULT WINAPI NSTC2_fnInitialize(INameSpaceTreeControl2* iface,
TRACE("%p (%p, %p, %x)\n", This, hwndParent, prc, nstcsFlags);
+ if(nstcsFlags & unsupported_styles)
+ FIXME("0x%08x contains the unsupported style(s) 0x%08x\n",
+ nstcsFlags, nstcsFlags & unsupported_styles);
+
/* Save the flags */
This->style = nstcsFlags;
--
1.7.2
More information about the wine-patches
mailing list