4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 /* Global variables and constants */
24 /* Image_Open, Image_Closed, and Image_Root - integer variables for indexes of the images. */
25 /* CX_ICON and CY_ICON - width and height of an icon. */
26 /* NUM_ICON - number of icons to add to the image list. */
27 static int Image_Open
= 0;
28 static int Image_Closed
= 0;
29 static int Image_Root
= 0;
31 static LPWSTR pathBuffer
;
35 static BOOL
get_item_path(HWND hwndTV
, HTREEITEM hItem
, HKEY
* phKey
, LPWSTR
* pKeyPath
, int* pPathLen
, int* pMaxLen
)
41 item
.mask
= TVIF_PARAM
;
43 if (!TreeView_GetItem(hwndTV
, &item
)) return FALSE
;
47 /* found root key with valid key value */
48 *phKey
= (HKEY
)item
.lParam
;
52 if(!get_item_path(hwndTV
, TreeView_GetParent(hwndTV
, hItem
), phKey
, pKeyPath
, pPathLen
, pMaxLen
)) return FALSE
;
55 (*pKeyPath
)[*pPathLen
] = L
'\\';
61 item
.mask
= TVIF_TEXT
;
63 item
.pszText
= *pKeyPath
+ *pPathLen
;
64 maxLen
= *pMaxLen
- *pPathLen
;
65 item
.cchTextMax
= (int) maxLen
;
66 if (!TreeView_GetItem(hwndTV
, &item
)) return FALSE
;
67 len
= wcslen(item
.pszText
);
70 *pPathLen
+= (int) len
;
73 newStr
= HeapReAlloc(GetProcessHeap(), 0, *pKeyPath
, *pMaxLen
* 2);
74 if (!newStr
) return FALSE
;
83 LPCWSTR
GetItemPath(HWND hwndTV
, HTREEITEM hItem
, HKEY
* phRootKey
)
85 int pathLen
= 0, maxLen
;
88 if (!pathBuffer
) pathBuffer
= HeapAlloc(GetProcessHeap(), 0, 1024);
89 if (!pathBuffer
) return NULL
;
91 maxLen
= (int) HeapSize(GetProcessHeap(), 0, pathBuffer
);
92 if (maxLen
== -1) return NULL
;
93 if (!hItem
) hItem
= TreeView_GetSelection(hwndTV
);
94 if (!hItem
) return NULL
;
95 if (!get_item_path(hwndTV
, hItem
, phRootKey
, &pathBuffer
, &pathLen
, &maxLen
))
102 BOOL
DeleteNode(HWND hwndTV
, HTREEITEM hItem
)
104 if (!hItem
) hItem
= TreeView_GetSelection(hwndTV
);
105 if (!hItem
) return FALSE
;
106 return TreeView_DeleteItem(hwndTV
, hItem
);
109 /* Add an entry to the tree. Only give hKey for root nodes (HKEY_ constants) */
110 static HTREEITEM
AddEntryToTree(HWND hwndTV
, HTREEITEM hParent
, LPWSTR label
, HKEY hKey
, DWORD dwChildren
)
113 TVINSERTSTRUCTW tvins
;
117 if (RegQueryInfoKeyW(hKey
, 0, 0, 0, &dwChildren
, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS
)
123 tvi
.mask
= TVIF_TEXT
| TVIF_IMAGE
| TVIF_SELECTEDIMAGE
| TVIF_CHILDREN
| TVIF_PARAM
;
125 tvi
.cchTextMax
= wcslen(tvi
.pszText
);
126 tvi
.iImage
= Image_Closed
;
127 tvi
.iSelectedImage
= Image_Open
;
128 tvi
.cChildren
= dwChildren
;
129 tvi
.lParam
= (LPARAM
)hKey
;
131 tvins
.hInsertAfter
= (HTREEITEM
)(hKey
? TVI_LAST
: TVI_FIRST
);
132 tvins
.hParent
= hParent
;
133 return TreeView_InsertItem(hwndTV
, &tvins
);
136 BOOL
RefreshTreeItem(HWND hwndTV
, HTREEITEM hItem
)
138 HKEY hRoot
, hKey
, hSubKey
;
141 DWORD dwCount
, dwIndex
, dwMaxSubKeyLen
;
144 LPWSTR pszNodes
= NULL
;
145 BOOL bSuccess
= FALSE
;
149 KeyPath
= GetItemPath(hwndTV
, hItem
, &hRoot
);
153 if (RegOpenKeyExW(hRoot
, KeyPath
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
163 if (RegQueryInfoKeyW(hKey
, 0, 0, 0, &dwCount
, &dwMaxSubKeyLen
, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS
)
168 /* Set the number of children again */
169 tvItem
.mask
= TVIF_CHILDREN
;
170 tvItem
.hItem
= hItem
;
171 tvItem
.cChildren
= dwCount
;
172 if (!TreeView_SetItem(hwndTV
, &tvItem
))
177 /* We don't have to bother with the rest if it's not expanded. */
178 if (TreeView_GetItemState(hwndTV
, hItem
, TVIS_EXPANDED
) == 0)
185 dwMaxSubKeyLen
++; /* account for the \0 terminator */
186 if (!(Name
= HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen
* sizeof(WCHAR
))))
190 tvItem
.cchTextMax
= dwMaxSubKeyLen
;
191 /*if (!(tvItem.pszText = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
195 /* Get all of the tree node siblings in one contiguous block of memory */
197 DWORD dwPhysicalSize
= 0;
198 DWORD dwActualSize
= 0;
199 DWORD dwNewPhysicalSize
;
201 DWORD dwStep
= 10000;
203 for (childItem
= TreeView_GetChild(hwndTV
, hItem
); childItem
;
204 childItem
= TreeView_GetNextSibling(hwndTV
, childItem
))
207 if (dwActualSize
+ dwMaxSubKeyLen
+ 1 > dwPhysicalSize
)
209 dwNewPhysicalSize
= dwActualSize
+ dwMaxSubKeyLen
+ 1 + dwStep
;
212 pszNewNodes
= (LPWSTR
) HeapReAlloc(GetProcessHeap(), 0, pszNodes
, dwNewPhysicalSize
* sizeof(WCHAR
));
214 pszNewNodes
= (LPWSTR
) HeapAlloc(GetProcessHeap(), 0, dwNewPhysicalSize
* sizeof(WCHAR
));
218 dwPhysicalSize
= dwNewPhysicalSize
;
219 pszNodes
= pszNewNodes
;
222 tvItem
.mask
= TVIF_TEXT
;
223 tvItem
.hItem
= childItem
;
224 tvItem
.pszText
= &pszNodes
[dwActualSize
];
225 tvItem
.cchTextMax
= dwPhysicalSize
- dwActualSize
;
226 if (!TreeView_GetItem(hwndTV
, &tvItem
))
229 dwActualSize
+= (DWORD
) wcslen(&pszNodes
[dwActualSize
]) + 1;
233 pszNodes
[dwActualSize
] = L
'\0';
236 /* Now go through all the children in the tree, and check if any have to be removed. */
237 childItem
= TreeView_GetChild(hwndTV
, hItem
);
240 HTREEITEM nextItem
= TreeView_GetNextSibling(hwndTV
, childItem
);
241 if (RefreshTreeItem(hwndTV
, childItem
) == FALSE
)
243 (void)TreeView_DeleteItem(hwndTV
, childItem
);
245 childItem
= nextItem
;
248 /* Now go through all the children in the registry, and check if any have to be added. */
250 for (dwIndex
= 0; dwIndex
< dwCount
; dwIndex
++)
252 DWORD cName
= dwMaxSubKeyLen
, dwSubCount
;
256 if (RegEnumKeyExW(hKey
, dwIndex
, Name
, &cName
, 0, 0, 0, NULL
) != ERROR_SUCCESS
)
261 /* Check if the node is already in there. */
264 for (s
= pszNodes
; *s
; s
+= wcslen(s
) + 1)
266 if (!wcscmp(s
, Name
))
276 /* Find the number of children of the node. */
278 if (RegOpenKeyExW(hKey
, Name
, 0, KEY_QUERY_VALUE
, &hSubKey
) == ERROR_SUCCESS
)
280 if (RegQueryInfoKeyW(hSubKey
, 0, 0, 0, &dwSubCount
, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS
)
284 RegCloseKey(hSubKey
);
287 AddEntryToTree(hwndTV
, hItem
, Name
, NULL
, dwSubCount
);
294 SendMessageW(hwndTV
, TVM_SORTCHILDREN
, 0, (LPARAM
) hItem
);
300 HeapFree(GetProcessHeap(), 0, pszNodes
);
302 HeapFree(GetProcessHeap(), 0, Name
);
306 BOOL
RefreshTreeView(HWND hwndTV
)
309 HTREEITEM hSelectedItem
;
312 hSelectedItem
= TreeView_GetSelection(hwndTV
);
313 hcursorOld
= SetCursor(LoadCursor(NULL
, IDC_WAIT
));
314 SendMessageW(hwndTV
, WM_SETREDRAW
, FALSE
, 0);
316 hItem
= TreeView_GetChild(hwndTV
, TreeView_GetRoot(hwndTV
));
319 RefreshTreeItem(hwndTV
, hItem
);
320 hItem
= TreeView_GetNextSibling(hwndTV
, hItem
);
323 SendMessageW(hwndTV
, WM_SETREDRAW
, TRUE
, 0);
324 SetCursor(hcursorOld
);
326 /* We reselect the currently selected node, this will prompt a refresh of the listview. */
327 (void)TreeView_SelectItem(hwndTV
, hSelectedItem
);
331 HTREEITEM
InsertNode(HWND hwndTV
, HTREEITEM hItem
, LPWSTR name
)
333 WCHAR buf
[MAX_NEW_KEY_LEN
];
334 HTREEITEM hNewItem
= 0;
337 /* Default to the current selection */
340 hItem
= TreeView_GetSelection(hwndTV
);
345 memset(&item
, 0, sizeof(item
));
347 item
.mask
= TVIF_CHILDREN
| TVIF_HANDLE
| TVIF_STATE
;
348 if (!TreeView_GetItem(hwndTV
, &item
))
351 if ((item
.state
& TVIS_EXPANDEDONCE
) && (item
.cChildren
> 0))
353 hNewItem
= AddEntryToTree(hwndTV
, hItem
, name
, 0, 0);
354 SendMessageW(hwndTV
, TVM_SORTCHILDREN
, 0, (LPARAM
) hItem
);
358 item
.mask
= TVIF_CHILDREN
| TVIF_HANDLE
;
361 if (!TreeView_SetItem(hwndTV
, &item
))
365 (void)TreeView_Expand(hwndTV
, hItem
, TVE_EXPAND
);
368 for(hNewItem
= TreeView_GetChild(hwndTV
, hItem
); hNewItem
; hNewItem
= TreeView_GetNextSibling(hwndTV
, hNewItem
))
370 item
.mask
= TVIF_HANDLE
| TVIF_TEXT
;
371 item
.hItem
= hNewItem
;
373 item
.cchTextMax
= COUNT_OF(buf
);
374 if (!TreeView_GetItem(hwndTV
, &item
)) continue;
375 if (wcscmp(name
, item
.pszText
) == 0) break;
378 if (hNewItem
) (void)TreeView_SelectItem(hwndTV
, hNewItem
);
383 HWND
StartKeyRename(HWND hwndTV
)
387 if(!(hItem
= TreeView_GetSelection(hwndTV
))) return 0;
388 return TreeView_EditLabel(hwndTV
, hItem
);
391 static BOOL
InitTreeViewItems(HWND hwndTV
, LPWSTR pHostName
)
394 TVINSERTSTRUCTW tvins
;
397 tvi
.mask
= TVIF_TEXT
| TVIF_IMAGE
| TVIF_SELECTEDIMAGE
| TVIF_CHILDREN
| TVIF_PARAM
;
398 /* Set the text of the item. */
399 tvi
.pszText
= pHostName
;
400 tvi
.cchTextMax
= wcslen(tvi
.pszText
);
401 /* Assume the item is not a parent item, so give it an image. */
402 tvi
.iImage
= Image_Root
;
403 tvi
.iSelectedImage
= Image_Root
;
405 /* Save the heading level in the item's application-defined data area. */
406 tvi
.lParam
= (LPARAM
)NULL
;
408 tvins
.hInsertAfter
= (HTREEITEM
)TVI_FIRST
;
409 tvins
.hParent
= TVI_ROOT
;
410 /* Add the item to the tree view control. */
411 if (!(hRoot
= TreeView_InsertItem(hwndTV
, &tvins
))) return FALSE
;
413 if (!AddEntryToTree(hwndTV
, hRoot
, L
"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT
, 1)) return FALSE
;
414 if (!AddEntryToTree(hwndTV
, hRoot
, L
"HKEY_CURRENT_USER", HKEY_CURRENT_USER
, 1)) return FALSE
;
415 if (!AddEntryToTree(hwndTV
, hRoot
, L
"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE
, 1)) return FALSE
;
416 if (!AddEntryToTree(hwndTV
, hRoot
, L
"HKEY_USERS", HKEY_USERS
, 1)) return FALSE
;
417 if (!AddEntryToTree(hwndTV
, hRoot
, L
"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG
, 1)) return FALSE
;
419 if (GetVersion() & 0x80000000)
421 /* Win9x specific key */
422 if (!AddEntryToTree(hwndTV
, hRoot
, L
"HKEY_DYN_DATA", HKEY_DYN_DATA
, 1)) return FALSE
;
425 /* expand and select host name */
426 (void)TreeView_Expand(hwndTV
, hRoot
, TVE_EXPAND
);
427 (void)TreeView_Select(hwndTV
, hRoot
, TVGN_CARET
);
433 * InitTreeViewImageLists - creates an image list, adds three bitmaps
434 * to it, and associates the image list with a tree view control.
435 * Returns TRUE if successful, or FALSE otherwise.
436 * hwndTV - handle to the tree view control.
438 static BOOL
InitTreeViewImageLists(HWND hwndTV
)
440 HIMAGELIST himl
; /* handle to image list */
441 HICON hico
; /* handle to icon */
443 /* Create the image list. */
444 if ((himl
= ImageList_Create(GetSystemMetrics(SM_CXSMICON
),
445 GetSystemMetrics(SM_CYSMICON
),
446 ILC_MASK
| ILC_COLOR32
,
453 /* Add the open file, closed file, and document bitmaps. */
454 hico
= LoadImageW(hInst
,
455 MAKEINTRESOURCEW(IDI_OPEN_FILE
),
457 GetSystemMetrics(SM_CXSMICON
),
458 GetSystemMetrics(SM_CYSMICON
),
462 Image_Open
= ImageList_AddIcon(himl
, hico
);
466 hico
= LoadImageW(hInst
,
467 MAKEINTRESOURCEW(IDI_CLOSED_FILE
),
469 GetSystemMetrics(SM_CXSMICON
),
470 GetSystemMetrics(SM_CYSMICON
),
474 Image_Closed
= ImageList_AddIcon(himl
, hico
);
478 hico
= LoadImageW(hInst
,
479 MAKEINTRESOURCEW(IDI_ROOT
),
481 GetSystemMetrics(SM_CXSMICON
),
482 GetSystemMetrics(SM_CYSMICON
),
486 Image_Root
= ImageList_AddIcon(himl
, hico
);
490 /* Fail if not all of the images were added. */
491 if (ImageList_GetImageCount(himl
) < NUM_ICONS
)
493 ImageList_Destroy(himl
);
497 /* Associate the image list with the tree view control. */
498 (void)TreeView_SetImageList(hwndTV
, himl
, TVSIL_NORMAL
);
503 BOOL
OnTreeExpanding(HWND hwndTV
, NMTREEVIEW
* pnmtv
)
505 DWORD dwCount
, dwIndex
, dwMaxSubKeyLen
;
506 HKEY hRoot
, hNewKey
, hKey
;
512 static int expanding
;
513 if (expanding
) return FALSE
;
514 if (pnmtv
->itemNew
.state
& TVIS_EXPANDEDONCE
)
519 hcursorOld
= SetCursor(LoadCursor(NULL
, IDC_WAIT
));
520 SendMessageW(hwndTV
, WM_SETREDRAW
, FALSE
, 0);
522 keyPath
= GetItemPath(hwndTV
, pnmtv
->itemNew
.hItem
, &hRoot
);
523 if (!keyPath
) goto done
;
527 errCode
= RegOpenKeyExW(hRoot
, keyPath
, 0, KEY_READ
, &hNewKey
);
528 if (errCode
!= ERROR_SUCCESS
) goto done
;
535 errCode
= RegQueryInfoKeyW(hNewKey
, 0, 0, 0, &dwCount
, &dwMaxSubKeyLen
, 0, 0, 0, 0, 0, 0);
536 if (errCode
!= ERROR_SUCCESS
) goto done
;
537 dwMaxSubKeyLen
++; /* account for the \0 terminator */
538 Name
= HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen
* sizeof(WCHAR
));
539 if (!Name
) goto done
;
541 for (dwIndex
= 0; dwIndex
< dwCount
; dwIndex
++)
543 DWORD cName
= dwMaxSubKeyLen
, dwSubCount
;
545 errCode
= RegEnumKeyExW(hNewKey
, dwIndex
, Name
, &cName
, 0, 0, 0, 0);
546 if (errCode
!= ERROR_SUCCESS
) continue;
547 errCode
= RegOpenKeyExW(hNewKey
, Name
, 0, KEY_QUERY_VALUE
, &hKey
);
548 if (errCode
== ERROR_SUCCESS
)
550 errCode
= RegQueryInfoKeyW(hKey
, 0, 0, 0, &dwSubCount
, 0, 0, 0, 0, 0, 0, 0);
553 if (errCode
!= ERROR_SUCCESS
) dwSubCount
= 0;
554 AddEntryToTree(hwndTV
, pnmtv
->itemNew
.hItem
, Name
, NULL
, dwSubCount
);
557 SendMessageW(hwndTV
, TVM_SORTCHILDREN
, 0, (LPARAM
)pnmtv
->itemNew
.hItem
);
559 RegCloseKey(hNewKey
);
560 HeapFree(GetProcessHeap(), 0, Name
);
563 SendMessageW(hwndTV
, WM_SETREDRAW
, TRUE
, 0);
564 SetCursor(hcursorOld
);
571 BOOL
CreateNewKey(HWND hwndTV
, HTREEITEM hItem
)
573 WCHAR szNewKeyFormat
[128];
578 HKEY hRootKey
= NULL
, hKey
= NULL
, hNewKey
= NULL
;
579 BOOL bSuccess
= FALSE
;
583 pszKeyPath
= GetItemPath(hwndTV
, hItem
, &hRootKey
);
584 if (pszKeyPath
[0] == L
'\0')
586 else if (RegOpenKeyW(hRootKey
, pszKeyPath
, &hKey
) != ERROR_SUCCESS
)
589 if (LoadStringW(hInst
, IDS_NEW_KEY
, szNewKeyFormat
, COUNT_OF(szNewKeyFormat
)) <= 0)
592 /* Need to create a new key with a unique name */
595 wsprintf(szNewKey
, szNewKeyFormat
, iIndex
++);
596 nResult
= RegCreateKeyExW(hKey
, szNewKey
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hNewKey
, &dwDisposition
);
597 if (hNewKey
&& dwDisposition
== REG_OPENED_EXISTING_KEY
)
599 RegCloseKey(hNewKey
);
604 InfoMessageBox(hFrameWnd
, MB_OK
| MB_ICONERROR
, NULL
, L
"Cannot create new key!\n\nError Code: %d", nResult
);
610 /* Insert the new key */
611 hNewItem
= InsertNode(hwndTV
, hItem
, szNewKey
);
615 /* The new key's name is probably not appropriate yet */
616 (void)TreeView_EditLabel(hwndTV
, hNewItem
);
621 if (hKey
!= hRootKey
&& hKey
)
624 RegCloseKey(hNewKey
);
630 * CreateTreeView - creates a tree view control.
631 * Returns the handle to the new control if successful, or NULL otherwise.
632 * hwndParent - handle to the control's parent window.
634 HWND
CreateTreeView(HWND hwndParent
, LPWSTR pHostName
, HMENU id
)
639 /* Get the dimensions of the parent window's client area, and create the tree view control. */
640 GetClientRect(hwndParent
, &rcClient
);
641 hwndTV
= CreateWindowExW(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, NULL
,
642 WS_VISIBLE
| WS_CHILD
| WS_TABSTOP
| TVS_HASLINES
| TVS_HASBUTTONS
| TVS_LINESATROOT
| TVS_EDITLABELS
| TVS_SHOWSELALWAYS
,
643 0, 0, rcClient
.right
, rcClient
.bottom
,
644 hwndParent
, id
, hInst
, NULL
);
645 /* Initialize the image list, and add items to the control. */
646 if (!InitTreeViewImageLists(hwndTV
) || !InitTreeViewItems(hwndTV
, pHostName
))
648 DestroyWindow(hwndTV
);
654 void DestroyTreeView(HWND hwndTV
)
658 if (pathBuffer
) HeapFree(GetProcessHeap(), 0, pathBuffer
);
660 /* Destroy the image list associated with the tree view control */
661 himl
= TreeView_GetImageList(hwndTV
, TVSIL_NORMAL
);
662 if (himl
) ImageList_Destroy(himl
);
665 BOOL
SelectNode(HWND hwndTV
, LPCWSTR keyPath
)
667 HTREEITEM hRoot
, hItem
;
668 HTREEITEM hChildItem
;
669 WCHAR szPathPart
[128];
674 /* Load "My Computer" string... */
675 LoadStringW(hInst
, IDS_MY_COMPUTER
, szBuffer
, COUNT_OF(szBuffer
));
676 wcscat(szBuffer
, L
"\\");
678 /* ... and remove it from the key path */
679 if (!_wcsnicmp(keyPath
, szBuffer
, wcslen(szBuffer
)))
680 keyPath
+= wcslen(szBuffer
);
682 /* Reinitialize szBuffer */
685 hRoot
= TreeView_GetRoot(hwndTV
);
690 s
= wcschr(keyPath
, L
'\\');
691 lstrcpynW(szPathPart
, keyPath
, s
? s
- keyPath
+ 1 : wcslen(keyPath
) + 1);
693 /* Special case for root to expand root key abbreviations */
696 if (!_wcsicmp(szPathPart
, L
"HKCR"))
697 wcscpy(szPathPart
, L
"HKEY_CLASSES_ROOT");
698 else if (!_wcsicmp(szPathPart
, L
"HKCU"))
699 wcscpy(szPathPart
, L
"HKEY_CURRENT_USER");
700 else if (!_wcsicmp(szPathPart
, L
"HKLM"))
701 wcscpy(szPathPart
, L
"HKEY_LOCAL_MACHINE");
702 else if (!_wcsicmp(szPathPart
, L
"HKU"))
703 wcscpy(szPathPart
, L
"HKEY_USERS");
704 else if (!_wcsicmp(szPathPart
, L
"HKCC"))
705 wcscpy(szPathPart
, L
"HKEY_CURRENT_CONFIG");
706 else if (!_wcsicmp(szPathPart
, L
"HKDD"))
707 wcscpy(szPathPart
, L
"HKEY_DYN_DATA");
710 for (hChildItem
= TreeView_GetChild(hwndTV
, hItem
); hChildItem
;
711 hChildItem
= TreeView_GetNextSibling(hwndTV
, hChildItem
))
713 memset(&tvi
, 0, sizeof(tvi
));
714 tvi
.hItem
= hChildItem
;
715 tvi
.mask
= TVIF_TEXT
| TVIF_CHILDREN
;
716 tvi
.pszText
= szBuffer
;
717 tvi
.cchTextMax
= COUNT_OF(szBuffer
);
719 (void)TreeView_GetItem(hwndTV
, &tvi
);
721 if (!_wcsicmp(szBuffer
, szPathPart
))
728 if (tvi
.cChildren
> 0)
730 if (!TreeView_Expand(hwndTV
, hChildItem
, TVE_EXPAND
))
734 keyPath
= s
? s
+ 1 : L
"";
738 (void)TreeView_SelectItem(hwndTV
, hItem
);
739 (void)TreeView_EnsureVisible(hwndTV
, hItem
);