ReactOS 0.4.15-dev-7834-g00c4b3d
treeview.h File Reference
#include "comctl32supp.h"
Include dependency graph for treeview.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void TreeView_Set3StateCheck (HWND hTree)
 
void TreeView_Cleanup (HWND hTree)
 
HTREEITEM InsertItem (HWND hTree, LPCWSTR szName, HTREEITEM hParent, HTREEITEM hInsertAfter)
 
UINT TreeView_GetRealSubtreeState (HWND hTree, HTREEITEM htiSubtreeItem)
 
void TreeView_PropagateStateOfItemToParent (HWND hTree, HTREEITEM htiItem)
 
void TreeView_DownItem (HWND hTree, HTREEITEM htiItemToDown)
 
void TreeView_UpItem (HWND hTree, HTREEITEM htiItemToUp)
 
HTREEITEM TreeView_GetFirst (HWND hTree)
 
HTREEITEM TreeView_GetLastFromItem (HWND hTree, HTREEITEM hItem)
 
HTREEITEM TreeView_GetLast (HWND hTree)
 
HTREEITEM TreeView_GetPrev (HWND hTree, HTREEITEM hItem)
 
HTREEITEM TreeView_GetNext (HWND hTree, HTREEITEM hItem)
 

Function Documentation

◆ InsertItem()

HTREEITEM InsertItem ( HWND  hTree,
LPCWSTR  szName,
HTREEITEM  hParent,
HTREEITEM  hInsertAfter 
)

Definition at line 95 of file treeview.c.

99{
100 TVINSERTSTRUCTW tvis;
101 SecureZeroMemory(&tvis, sizeof(tvis));
102
103 tvis.hParent = hParent;
104 tvis.hInsertAfter = hInsertAfter;
105 tvis.itemex.mask = TVIF_TEXT;
106 tvis.itemex.pszText = (LPWSTR)szName;
107
108 return (tvis.itemex.hItem = TreeView_InsertItem(hTree, &tvis));
109}
static const WCHAR szName[]
Definition: powrprof.c:45
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
TVITEMEXW itemex
Definition: commctrl.h:3396
HTREEITEM hParent
Definition: commctrl.h:3393
HTREEITEM hInsertAfter
Definition: commctrl.h:3394
LPWSTR pszText
Definition: commctrl.h:3350
HTREEITEM hItem
Definition: commctrl.h:3347
static HWND hTree
Definition: systempage.cpp:52
#define SecureZeroMemory
Definition: winbase.h:1713
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CAppsListView::AddItem(), and CommonWndProc().

◆ TreeView_Cleanup()

void TreeView_Cleanup ( HWND  hTree)

Definition at line 87 of file treeview.c.

88{
89 // FIXME: Should we do it always, or only when the custom image list was set?
91}
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
#define TVSIL_STATE
Definition: commctrl.h:3444
#define TreeView_GetImageList(hwnd, iImage)
Definition: commctrl.h:3441

Referenced by CommonWndProc().

◆ TreeView_DownItem()

void TreeView_DownItem ( HWND  hTree,
HTREEITEM  htiItemToDown 
)

Definition at line 186 of file treeview.c.

187{
188 HTREEITEM htiNextItem, htiNewItem;
189
190 if (!hTree || !htiItemToDown)
191 return;
192
193 htiNextItem = TreeView_GetNextSibling(hTree, htiItemToDown);
194 if (!htiNextItem)
195 htiNextItem = TVI_LAST;
196
197 htiNewItem = Tree_Item_Copy(hTree, htiItemToDown, TreeView_GetParent(hTree, htiItemToDown), htiNextItem);
198 TreeView_DeleteItem(hTree, htiItemToDown); // Delete the item and ALL its children.
199 TreeView_SelectItem(hTree, htiNewItem);
200
201 return;
202}
HTREEITEM Tree_Item_Copy(HWND hTree, HTREEITEM hSourceItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
Definition: treeview.c:154
#define TVI_LAST
Definition: commctrl.h:3370
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3481
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3467
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3415

Referenced by CommonWndProc().

◆ TreeView_GetFirst()

HTREEITEM TreeView_GetFirst ( HWND  hTree)

Definition at line 224 of file treeview.c.

225{
226 return TreeView_GetRoot(hTree);
227}
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3475

Referenced by FindDialogWndProc(), and WriteIniFile().

◆ TreeView_GetLast()

HTREEITEM TreeView_GetLast ( HWND  hTree)

Definition at line 240 of file treeview.c.

241{
243}
HTREEITEM TreeView_GetLastFromItem(HWND hTree, HTREEITEM hItem)
Definition: treeview.c:229

Referenced by FindDialogWndProc().

◆ TreeView_GetLastFromItem()

HTREEITEM TreeView_GetLastFromItem ( HWND  hTree,
HTREEITEM  hItem 
)

Definition at line 229 of file treeview.c.

230{
231 HTREEITEM htiRet = NULL;
232 HTREEITEM htiIterator;
233
234 for (htiIterator = hItem ; htiIterator ; htiIterator = TreeView_GetNextSibling(hTree, htiIterator))
235 htiRet = htiIterator;
236
237 return htiRet;
238}
#define NULL
Definition: types.h:112

Referenced by TreeView_GetLast(), and TreeView_GetPrev().

◆ TreeView_GetNext()

HTREEITEM TreeView_GetNext ( HWND  hTree,
HTREEITEM  hItem 
)

Definition at line 263 of file treeview.c.

264{
265 HTREEITEM hNext;
266
267 if (!hTree)
268 return NULL;
269
270 hNext = TreeView_GetChild(hTree, hItem);
271 if (hNext)
272 return hNext;
273
275 if (hNext)
276 return hNext;
277 else
279}
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3466

Referenced by FindDialogWndProc(), and WriteIniFile().

◆ TreeView_GetPrev()

HTREEITEM TreeView_GetPrev ( HWND  hTree,
HTREEITEM  hItem 
)

Definition at line 245 of file treeview.c.

246{
247 HTREEITEM hPrev, hTmp;
248
249 if (!hTree)
250 return NULL;
251
253 if (!hPrev)
255
256 hTmp = TreeView_GetChild(hTree, hPrev);
257 if (hTmp)
258 return TreeView_GetLastFromItem(hTree, hTmp);
259 else
260 return hPrev;
261}
#define TreeView_GetPrevSibling(hwnd, hitem)
Definition: commctrl.h:3468

Referenced by FindDialogWndProc().

◆ TreeView_GetRealSubtreeState()

UINT TreeView_GetRealSubtreeState ( HWND  hTree,
HTREEITEM  htiSubtreeItem 
)

Definition at line 111 of file treeview.c.

112{
113#define OP(a, b) ((a) == (b) ? (a) : 2)
114
115 HTREEITEM htiIterator = TreeView_GetChild(hTree, htiSubtreeItem);
116 UINT uRealSubtreeState = TreeView_GetCheckState(hTree, htiIterator);
117 /*
118 while (htiIterator)
119 {
120 UINT temp = TreeView_GetCheckState(hTree, htiIterator);
121 uRealSubtreeState = OP(uRealSubtreeState, temp);
122
123 htiIterator = TreeView_GetNextSibling(hTree, htiIterator);
124 }
125 */
126 while ( htiIterator && ( (htiIterator = TreeView_GetNextSibling(hTree, htiIterator)) != NULL ) )
127 {
128 UINT temp = TreeView_GetCheckState(hTree, htiIterator);
129 uRealSubtreeState = OP(uRealSubtreeState, temp);
130 }
131
132 return uRealSubtreeState;
133}
#define OP(a, b)
unsigned int UINT
Definition: ndis.h:50
#define TreeView_GetCheckState(hwndTV, hti)
Definition: commctrl.h:3596
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by TreeView_PropagateStateOfItemToParent(), and Update_Btn_States().

◆ TreeView_PropagateStateOfItemToParent()

void TreeView_PropagateStateOfItemToParent ( HWND  hTree,
HTREEITEM  htiItem 
)

Definition at line 135 of file treeview.c.

136{
137 HTREEITEM htiParent;
138 UINT uGlobalSiblingsCheckState;
139
140 if (!hTree || !htiItem /* || htiItem == TVI_ROOT */)
141 return;
142
143 htiParent = TreeView_GetParent(hTree, htiItem);
144 if (!htiParent)
145 return;
146
147 uGlobalSiblingsCheckState = TreeView_GetRealSubtreeState(hTree, htiParent);
148 TreeView_SetItemState(hTree, htiParent, INDEXTOSTATEIMAGEMASK(uGlobalSiblingsCheckState + 1), TVIS_STATEIMAGEMASK);
150
151 return;
152}
void TreeView_PropagateStateOfItemToParent(HWND hTree, HTREEITEM htiItem)
Definition: treeview.c:135
UINT TreeView_GetRealSubtreeState(HWND hTree, HTREEITEM htiSubtreeItem)
Definition: treeview.c:111
#define TreeView_SetItemState(hwndTV, hti, data, _mask)
Definition: commctrl.h:3592
#define TVIS_STATEIMAGEMASK
Definition: commctrl.h:3288
#define INDEXTOSTATEIMAGEMASK(i)
Definition: commctrl.h:2328

Referenced by TreeView_PropagateStateOfItemToParent(), and TreeView_SetBOOLCheck().

◆ TreeView_Set3StateCheck()

void TreeView_Set3StateCheck ( HWND  hTree)

Definition at line 24 of file treeview.c.

25{
26 LONG_PTR lStyle;
27 DWORD dwExStyle;
28
29 DWORD Major, Minor, Build;
30 GetComCtl32Version(&Major, &Minor, &Build);
31
32 /*
33 * Choose the best way to handle 3-state TreeView checkboxes
34 * according to the version of comctl32.dll we are running against.
35 *
36 * Starting version comctl32 version 6.10 (Vista+, via SxS)
37 * we have native 3-state checkboxes available.
38 * Only when comctl32 version 5.82 (no SxS) is available,
39 * use its build number to know whether we should use 2k3-style
40 * or Vista+ style check-boxes.
41 */
42 if (Major > 6 || (Major == 6 && Minor >= 10))
43 {
44 /*
45 * NOTE: As explained in the following link:
46 * http://stackoverflow.com/questions/31488233/treeview-setextendedstyle-does-not-apply-certain-styles-what-am-i-doing-wrong
47 * the TreeView control should have the extended check-box style set
48 * *BEFORE* actually setting the check-box window style, because it is
49 * only at that step that the TreeView control builds its image list
50 * containing the three check-box states. Indeed, if the extended
51 * check-box style was applied after setting the window style, then
52 * the image list would be already built with the default two states
53 * and would not be updated.
54 *
55 * The MSDN documentation is not very clear on that point.
56 *
57 * Let me also take this opportunity to document what those
58 * extended check-box state styles look like on Windows Vista+ :
59 *
60 * - TVS_EX_DIMMEDCHECKBOXES creates a grey tone version of the normal checked box state.
61 * - TVS_EX_EXCLUSIONCHECKBOXES creates a red 'X'-style cross check-box state.
62 * - TVS_EX_PARTIALCHECKBOXES creates a filled box.
63 */
64 dwExStyle = TreeView_GetExtendedStyle(hTree);
65 TreeView_SetExtendedStyle(hTree, dwExStyle | TVS_EX_PARTIALCHECKBOXES, 0);
66
69 }
70 else
71 {
74
75 // TODO: Implement this function which should build at runtime
76 // the image list with either two or three check-box states
77 // (as it is done by the real common control TreeView), instead
78 // of storing resource bitmaps.
79 //
80 // hCheckImageList = CreateCheckBoxImagelist(NULL, TRUE, TRUE, FALSE);
82 ImageList_LoadBitmap(hInst, (Build >= 6000 ? MAKEINTRESOURCEW(IDB_V7CHECK) : MAKEINTRESOURCEW(IDB_2K3CHECK)), 16, 4, RGB(255, 255, 255)),
84 }
85}
#define IDB_V7CHECK
Definition: resource.h:152
#define IDB_2K3CHECK
Definition: resource.h:151
HRESULT GetComCtl32Version(OUT PDWORD pdwMajor, OUT PDWORD pdwMinor, OUT PDWORD pdwBuild)
Definition: comctl32supp.c:11
#define RGB(r, g, b)
Definition: precomp.h:71
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ImageList_LoadBitmap(hi, lpbmp, cx, cGrow, crMask)
Definition: commctrl.h:558
#define TVS_CHECKBOXES
Definition: commctrl.h:3255
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GWL_STYLE
Definition: winuser.h:852
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44

Referenced by CommonWndProc().

◆ TreeView_UpItem()

void TreeView_UpItem ( HWND  hTree,
HTREEITEM  htiItemToUp 
)

Definition at line 204 of file treeview.c.

205{
206 HTREEITEM htiPrevItem, htiPrevPrevItem, htiNewItem;
207
208 if (!hTree || !htiItemToUp)
209 return;
210
211 htiPrevItem = TreeView_GetPrevSibling(hTree, htiItemToUp);
212 htiPrevPrevItem = TreeView_GetPrevSibling(hTree, htiPrevItem);
213 if (!htiPrevPrevItem)
214 htiPrevPrevItem = TVI_FIRST;
215 // if htiPrevItem == NULL , htiPrevPrevItem == NULL.
216
217 htiNewItem = Tree_Item_Copy(hTree, htiItemToUp, TreeView_GetParent(hTree, htiItemToUp), htiPrevPrevItem);
218 TreeView_DeleteItem(hTree, htiItemToUp); // Delete the item and ALL its children.
219 TreeView_SelectItem(hTree, htiNewItem);
220
221 return;
222}
#define TVI_FIRST
Definition: commctrl.h:3369

Referenced by CommonWndProc().