ReactOS  0.4.12-dev-102-g4b7f1e0
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.

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

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 }
HTREEITEM hParent
Definition: commctrl.h:3360
#define SecureZeroMemory
Definition: winbase.h:1636
LPWSTR pszText
Definition: commctrl.h:3317
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3379
HTREEITEM hInsertAfter
Definition: commctrl.h:3361
TVITEMEXW itemex
Definition: commctrl.h:3363
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
HTREEITEM hItem
Definition: commctrl.h:3314
#define TVIF_TEXT
Definition: commctrl.h:3233
static const WCHAR szName[]
Definition: msipriv.h:1194
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ TreeView_Cleanup()

void TreeView_Cleanup ( HWND  hTree)

Definition at line 87 of file treeview.c.

Referenced by CommonWndProc().

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

◆ TreeView_DownItem()

void TreeView_DownItem ( HWND  hTree,
HTREEITEM  htiItemToDown 
)

Definition at line 186 of file treeview.c.

Referenced by CommonWndProc().

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 }
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
HTREEITEM Tree_Item_Copy(HWND hTree, HTREEITEM hSourceItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
Definition: treeview.c:154
#define TVI_LAST
Definition: commctrl.h:3337
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3382
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3436
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3448

◆ TreeView_GetFirst()

HTREEITEM TreeView_GetFirst ( HWND  hTree)

Definition at line 224 of file treeview.c.

Referenced by FindDialogWndProc(), and WriteIniFile().

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

◆ TreeView_GetLast()

HTREEITEM TreeView_GetLast ( HWND  hTree)

Definition at line 240 of file treeview.c.

Referenced by FindDialogWndProc().

241 {
242  return TreeView_GetLastFromItem(hTree, TreeView_GetRoot(hTree));
243 }
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3442
HTREEITEM TreeView_GetLastFromItem(HWND hTree, HTREEITEM hItem)
Definition: treeview.c:229

◆ TreeView_GetLastFromItem()

HTREEITEM TreeView_GetLastFromItem ( HWND  hTree,
HTREEITEM  hItem 
)

Definition at line 229 of file treeview.c.

Referenced by TreeView_GetLast(), and TreeView_GetPrev().

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 TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
smooth NULL
Definition: ftsmooth.c:416

◆ TreeView_GetNext()

HTREEITEM TreeView_GetNext ( HWND  hTree,
HTREEITEM  hItem 
)

Definition at line 263 of file treeview.c.

Referenced by FindDialogWndProc(), and WriteIniFile().

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 
274  hNext = TreeView_GetNextSibling(hTree, hItem);
275  if (hNext)
276  return hNext;
277  else
278  return TreeView_GetNextSibling(hTree, TreeView_GetParent(hTree, hItem));
279 }
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3433
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
smooth NULL
Definition: ftsmooth.c:416
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3436

◆ TreeView_GetPrev()

HTREEITEM TreeView_GetPrev ( HWND  hTree,
HTREEITEM  hItem 
)

Definition at line 245 of file treeview.c.

Referenced by FindDialogWndProc().

246 {
247  HTREEITEM hPrev, hTmp;
248 
249  if (!hTree)
250  return NULL;
251 
252  hPrev = TreeView_GetPrevSibling(hTree, hItem);
253  if (!hPrev)
254  return TreeView_GetParent(hTree, hItem);
255 
256  hTmp = TreeView_GetChild(hTree, hPrev);
257  if (hTmp)
258  return TreeView_GetLastFromItem(hTree, hTmp);
259  else
260  return hPrev;
261 }
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3433
smooth NULL
Definition: ftsmooth.c:416
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3436
#define TreeView_GetPrevSibling(hwnd, hitem)
Definition: commctrl.h:3435
HTREEITEM TreeView_GetLastFromItem(HWND hTree, HTREEITEM hItem)
Definition: treeview.c:229

◆ TreeView_GetRealSubtreeState()

UINT TreeView_GetRealSubtreeState ( HWND  hTree,
HTREEITEM  htiSubtreeItem 
)

Definition at line 111 of file treeview.c.

Referenced by TreeView_PropagateStateOfItemToParent(), and Update_Btn_States().

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 TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3433
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3434
smooth NULL
Definition: ftsmooth.c:416
#define TreeView_GetCheckState(hwndTV, hti)
Definition: commctrl.h:3563
#define OP(a, b)
unsigned int UINT
Definition: ndis.h:50
static stack_node_t temp
Definition: rpn.c:18

◆ TreeView_PropagateStateOfItemToParent()

void TreeView_PropagateStateOfItemToParent ( HWND  hTree,
HTREEITEM  htiItem 
)

Definition at line 135 of file treeview.c.

Referenced by TreeView_PropagateStateOfItemToParent(), and TreeView_SetBOOLCheck().

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);
149  TreeView_PropagateStateOfItemToParent(hTree, htiParent);
150 
151  return;
152 }
void TreeView_PropagateStateOfItemToParent(HWND hTree, HTREEITEM htiItem)
Definition: treeview.c:135
#define INDEXTOSTATEIMAGEMASK(i)
Definition: commctrl.h:2298
unsigned int UINT
Definition: ndis.h:50
#define TreeView_SetItemState(hwndTV, hti, data, _mask)
Definition: commctrl.h:3559
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3436
UINT TreeView_GetRealSubtreeState(HWND hTree, HTREEITEM htiSubtreeItem)
Definition: treeview.c:111
#define TVIS_STATEIMAGEMASK
Definition: commctrl.h:3255

◆ TreeView_Set3StateCheck()

void TreeView_Set3StateCheck ( HWND  hTree)

Definition at line 24 of file treeview.c.

Referenced by CommonWndProc().

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 
67  lStyle = GetWindowLongPtr(hTree, GWL_STYLE);
68  SetWindowLongPtr(hTree, GWL_STYLE, lStyle | TVS_CHECKBOXES);
69  }
70  else
71  {
72  lStyle = GetWindowLongPtr(hTree, GWL_STYLE);
73  SetWindowLongPtr(hTree, GWL_STYLE, lStyle | TVS_CHECKBOXES);
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)),
83  TVSIL_STATE);
84  }
85 }
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
#define IDB_V7CHECK
Definition: resource.h:152
#define SetWindowLongPtr
Definition: treelist.c:70
HRESULT GetComCtl32Version(OUT PDWORD pdwMajor, OUT PDWORD pdwMinor, OUT PDWORD pdwBuild)
Definition: comctl32supp.c:11
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3414
#define RGB(r, g, b)
Definition: wingdi.h:2917
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TVS_CHECKBOXES
Definition: commctrl.h:3222
#define GWL_STYLE
Definition: winuser.h:846
HINSTANCE hInst
Definition: dxdiag.c:13
#define ImageList_LoadBitmap(hi, lpbmp, cx, cGrow, crMask)
Definition: commctrl.h:543
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define TVSIL_STATE
Definition: commctrl.h:3411
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDB_2K3CHECK
Definition: resource.h:151

◆ TreeView_UpItem()

void TreeView_UpItem ( HWND  hTree,
HTREEITEM  htiItemToUp 
)

Definition at line 204 of file treeview.c.

Referenced by CommonWndProc().

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 }
HTREEITEM Tree_Item_Copy(HWND hTree, HTREEITEM hSourceItem, HTREEITEM hParent, HTREEITEM hInsertAfter)
Definition: treeview.c:154
#define TVI_FIRST
Definition: commctrl.h:3336
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3382
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3436
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3448
#define TreeView_GetPrevSibling(hwnd, hitem)
Definition: commctrl.h:3435