4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
5 * Copyright (C) 2008 Alexander N. Sørnes <alex@thehandofagony.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
30 #include <wine/debug.h>
36 WINE_DEFAULT_DEBUG_CHANNEL(regedit);
38 /* Global variables and constants */
39 /* Image_Open, Image_Closed, and Image_Root - integer variables for indexes of the images. */
40 /* CX_BITMAP and CY_BITMAP - width and height of an icon. */
41 /* NUM_BITMAPS - number of bitmaps to add to the image list. */
50 static BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state);
52 static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKeyPath, int* pPathLen, int* pMaxChars)
58 item.mask = TVIF_PARAM;
60 if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
63 /* found root key with valid key value */
64 *phKey = (HKEY)item.lParam;
68 if(!get_item_path(hwndTV, TreeView_GetParent(hwndTV, hItem), phKey, pKeyPath, pPathLen, pMaxChars)) return FALSE;
70 (*pKeyPath)[*pPathLen] = '\\';
75 item.mask = TVIF_TEXT;
77 item.pszText = *pKeyPath + *pPathLen;
78 item.cchTextMax = maxChars = *pMaxChars - *pPathLen;
79 if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
80 chars = lstrlenW(item.pszText);
81 if (chars < maxChars - 1) {
85 newStr = HeapReAlloc(GetProcessHeap(), 0, *pKeyPath, *pMaxChars * 2);
86 if (!newStr) return FALSE;
94 LPWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
96 int pathLen = 0, maxLen;
99 pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024*sizeof(WCHAR));
100 if (!pathBuffer) return NULL;
102 maxLen = HeapSize(GetProcessHeap(), 0, pathBuffer);
103 if (maxLen == (SIZE_T) - 1) return NULL;
104 maxLen = maxLen / sizeof(WCHAR);
105 if (!hItem) hItem = TreeView_GetSelection(hwndTV);
106 if (!hItem) return NULL;
107 if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
111 static LPWSTR get_path_component(LPCWSTR *lplpKeyName) {
112 LPCWSTR lpPos = *lplpKeyName;
113 LPWSTR lpResult = NULL;
117 while(*lpPos && *lpPos != '\\')
119 if (*lpPos && lpPos == *lplpKeyName)
121 len = lpPos+1-(*lplpKeyName);
122 lpResult = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
123 if (!lpResult) /* that would be very odd */
125 lstrcpynW(lpResult, *lplpKeyName, len);
126 *lplpKeyName = *lpPos ? lpPos+1 : NULL;
130 HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
132 WCHAR buf[261]; /* tree view has 260 character limitation on item name */
133 HTREEITEM hItem, hOldItem;
136 hItem = TreeView_GetRoot(hwndTV);
137 SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
138 hItem = TreeView_GetChild(hwndTV, hItem);
141 LPWSTR lpItemName = get_path_component(&lpKeyName);
145 tvi.mask = TVIF_TEXT | TVIF_HANDLE;
148 tvi.cchTextMax = 260;
149 SendMessageW(hwndTV, TVM_GETITEMW, 0, (LPARAM) &tvi);
150 if (!lstrcmpiW(tvi.pszText, lpItemName)) {
151 SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
154 HeapFree(GetProcessHeap(), 0, lpItemName);
158 hItem = TreeView_GetChild(hwndTV, hItem);
161 hItem = TreeView_GetNextSibling(hwndTV, hItem);
163 HeapFree(GetProcessHeap(), 0, lpItemName);
172 BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem)
174 if (!hItem) hItem = TreeView_GetSelection(hwndTV);
175 if (!hItem) return FALSE;
176 return TreeView_DeleteItem(hwndTV, hItem);
179 /* Add an entry to the tree. Only give hKey for root nodes (HKEY_ constants) */
180 static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPWSTR label, HKEY hKey, DWORD dwChildren)
182 TVINSERTSTRUCTW tvins;
185 if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwChildren, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
190 tvins.u.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
191 tvins.u.item.pszText = label;
192 tvins.u.item.cchTextMax = lstrlenW(label);
193 tvins.u.item.iImage = Image_Closed;
194 tvins.u.item.iSelectedImage = Image_Open;
195 tvins.u.item.cChildren = dwChildren;
196 tvins.u.item.lParam = (LPARAM)hKey;
197 tvins.hInsertAfter = hKey ? TVI_LAST : TVI_SORT;
198 tvins.hParent = hParent;
200 return TreeView_InsertItemW(hwndTV, &tvins);
203 static BOOL match_string(LPCWSTR sstring1, LPCWSTR sstring2, int mode)
205 if (mode & SEARCH_WHOLE)
206 return !lstrcmpiW(sstring1, sstring2);
208 return NULL != StrStrIW(sstring1, sstring2);
211 static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, int *row)
214 WCHAR keyname[KEY_MAX_LEN];
215 item.mask = TVIF_TEXT;
217 item.pszText = keyname;
218 item.cchTextMax = KEY_MAX_LEN;
219 if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
220 if ((mode & SEARCH_KEYS) && match_string(keyname, sstring, mode)) {
225 if (mode & (SEARCH_VALUES | SEARCH_CONTENT)) {
227 WCHAR valName[KEY_MAX_LEN], *KeyPath;
231 KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
233 if (!KeyPath || !hRoot)
236 if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
237 HeapFree(GetProcessHeap(), 0, KeyPath);
241 HeapFree(GetProcessHeap(), 0, KeyPath);
242 lenName = KEY_MAX_LEN;
244 /* RegEnumValue won't return empty default value, so fake it when dealing with *row,
245 which corresponds to list view rows, not value ids */
246 if (ERROR_SUCCESS == RegEnumValueW(hKey, 0, valName, &lenName, NULL, NULL, NULL, NULL) && *valName)
252 DWORD lenValue = 0, type = 0;
253 lenName = KEY_MAX_LEN;
255 if (ERROR_SUCCESS != RegEnumValueW(hKey,
256 i, valName, &lenName, NULL, &type, NULL, &lenValue))
259 if (mode & SEARCH_VALUES) {
260 if (match_string(valName, sstring, mode)) {
267 if ((mode & SEARCH_CONTENT) && (type == REG_EXPAND_SZ || type == REG_SZ)) {
269 buffer = HeapAlloc(GetProcessHeap(), 0, lenValue);
272 if (ERROR_SUCCESS != RegEnumValueW(hKey, i, NULL, NULL, NULL, &type, (LPBYTE)buffer, &lenValue))
274 if (match_string(buffer, sstring, mode)) {
275 HeapFree(GetProcessHeap(), 0, buffer);
280 HeapFree(GetProcessHeap(), 0, buffer);
290 HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, int *row)
292 HTREEITEM hTry, hLast;
296 if (match_item(hwndTV, hLast, sstring, mode & ~SEARCH_KEYS, row)) {
302 /* first look in subtree */
303 /* no children? maybe we haven't loaded them yet? */
304 if (!TreeView_GetChild(hwndTV, hLast)) {
305 UpdateExpandingTree(hwndTV, hLast, TreeView_GetItemState(hwndTV, hLast, -1));
307 hTry = TreeView_GetChild(hwndTV, hLast);
309 if (match_item(hwndTV, hTry, sstring, mode, row))
314 /* no more children, maybe there are any siblings? */
315 hTry = TreeView_GetNextSibling(hwndTV, hLast);
317 if (match_item(hwndTV, hTry, sstring, mode, row))
322 /* no more siblings, look at the next siblings in parent(s) */
323 hLast = TreeView_GetParent(hwndTV, hLast);
326 while (hLast && (hTry = TreeView_GetNextSibling(hwndTV, hLast)) == NULL) {
327 hLast = TreeView_GetParent(hwndTV, hLast);
329 if (match_item(hwndTV, hTry, sstring, mode, row))
336 static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
338 HKEY hRoot, hKey, hSubKey;
341 DWORD dwCount, dwIndex, dwMaxSubKeyLen;
346 KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
348 if (!KeyPath || !hRoot)
352 if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
353 WINE_TRACE("RegOpenKeyEx failed, %s was probably removed.\n", wine_dbgstr_w(KeyPath));
359 HeapFree(GetProcessHeap(), 0, KeyPath);
361 if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
365 /* Set the number of children again */
366 tvItem.mask = TVIF_CHILDREN;
367 tvItem.hItem = hItem;
368 tvItem.cChildren = dwCount;
369 if (!TreeView_SetItemW(hwndTV, &tvItem)) {
373 /* We don't have to bother with the rest if it's not expanded. */
374 if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0) {
379 dwMaxSubKeyLen++; /* account for the \0 terminator */
380 if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
383 tvItem.cchTextMax = dwMaxSubKeyLen;
384 if (!(tvItem.pszText = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
385 HeapFree(GetProcessHeap(), 0, Name);
389 /* Now go through all the children in the registry, and check if any have to be added. */
390 for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
391 DWORD cName = dwMaxSubKeyLen, dwSubCount;
395 if (RegEnumKeyExW(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS) {
399 /* Find the number of children of the node. */
401 if (RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) {
402 if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
405 RegCloseKey(hSubKey);
408 /* Check if the node is already in there. */
409 for (childItem = TreeView_GetChild(hwndTV, hItem); childItem;
410 childItem = TreeView_GetNextSibling(hwndTV, childItem)) {
411 tvItem.mask = TVIF_TEXT;
412 tvItem.hItem = childItem;
413 if (!TreeView_GetItemW(hwndTV, &tvItem)) {
414 HeapFree(GetProcessHeap(), 0, Name);
415 HeapFree(GetProcessHeap(), 0, tvItem.pszText);
419 if (!lstrcmpiW(tvItem.pszText, Name)) {
425 if (found == FALSE) {
426 WINE_TRACE("New subkey %s\n", wine_dbgstr_w(Name));
427 AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
430 HeapFree(GetProcessHeap(), 0, Name);
431 HeapFree(GetProcessHeap(), 0, tvItem.pszText);
434 /* Now go through all the children in the tree, and check if any have to be removed. */
435 childItem = TreeView_GetChild(hwndTV, hItem);
437 HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
438 if (RefreshTreeItem(hwndTV, childItem) == FALSE) {
439 SendMessageW(hwndTV, TVM_DELETEITEM, 0, (LPARAM)childItem);
441 childItem = nextItem;
447 BOOL RefreshTreeView(HWND hwndTV)
450 HTREEITEM hSelectedItem;
454 hSelectedItem = TreeView_GetSelection(hwndTV);
455 hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
456 SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
458 hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV));
460 RefreshTreeItem(hwndTV, hItem);
461 hItem = TreeView_GetNextSibling(hwndTV, hItem);
464 SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
465 InvalidateRect(hwndTV, NULL, FALSE);
466 SetCursor(hcursorOld);
468 /* We reselect the currently selected node, this will prompt a refresh of the listview. */
469 SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hSelectedItem);
473 HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
475 WCHAR buf[MAX_NEW_KEY_LEN];
476 HTREEITEM hNewItem = 0;
479 if (!hItem) hItem = TreeView_GetSelection(hwndTV);
480 if (!hItem) return FALSE;
481 if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE)) {
482 hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
484 item.mask = TVIF_CHILDREN | TVIF_HANDLE;
486 if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
488 if (!TreeView_SetItemW(hwndTV, &item)) return FALSE;
490 SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
492 for(hNewItem = TreeView_GetChild(hwndTV, hItem); hNewItem; hNewItem = TreeView_GetNextSibling(hwndTV, hNewItem)) {
493 item.mask = TVIF_HANDLE | TVIF_TEXT;
494 item.hItem = hNewItem;
496 item.cchTextMax = COUNT_OF(buf);
497 if (!TreeView_GetItemW(hwndTV, &item)) continue;
498 if (lstrcmpW(name, item.pszText) == 0) break;
502 SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hNewItem);
507 HWND StartKeyRename(HWND hwndTV)
511 if(!(hItem = TreeView_GetSelection(hwndTV))) return 0;
512 return TreeView_EditLabel(hwndTV, hItem);
515 static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName)
517 TVINSERTSTRUCTW tvins;
519 static WCHAR hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0},
520 hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0},
521 hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0},
522 hku[] = {'H','K','E','Y','_','U','S','E','R','S',0},
523 hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0},
524 hkdd[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0};
526 tvins.u.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
527 /* Set the text of the item. */
528 tvins.u.item.pszText = pHostName;
529 tvins.u.item.cchTextMax = lstrlenW(pHostName);
530 /* Assume the item is not a parent item, so give it an image. */
531 tvins.u.item.iImage = Image_Root;
532 tvins.u.item.iSelectedImage = Image_Root;
533 tvins.u.item.cChildren = 5;
534 /* Save the heading level in the item's application-defined data area. */
535 tvins.u.item.lParam = 0;
536 tvins.hInsertAfter = TVI_FIRST;
537 tvins.hParent = TVI_ROOT;
538 /* Add the item to the tree view control. */
539 if (!(hRoot = TreeView_InsertItemW(hwndTV, &tvins))) return FALSE;
541 if (!AddEntryToTree(hwndTV, hRoot, hkcr, HKEY_CLASSES_ROOT, 1)) return FALSE;
542 if (!AddEntryToTree(hwndTV, hRoot, hkcu, HKEY_CURRENT_USER, 1)) return FALSE;
543 if (!AddEntryToTree(hwndTV, hRoot, hklm, HKEY_LOCAL_MACHINE, 1)) return FALSE;
544 if (!AddEntryToTree(hwndTV, hRoot, hku, HKEY_USERS, 1)) return FALSE;
545 if (!AddEntryToTree(hwndTV, hRoot, hkcc, HKEY_CURRENT_CONFIG, 1)) return FALSE;
546 if (!AddEntryToTree(hwndTV, hRoot, hkdd, HKEY_DYN_DATA, 1)) return FALSE;
548 /* expand and select host name */
549 SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hRoot );
550 SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hRoot);
556 * InitTreeViewImageLists - creates an image list, adds three bitmaps
557 * to it, and associates the image list with a tree view control.
558 * Returns TRUE if successful, or FALSE otherwise.
559 * hwndTV - handle to the tree view control.
561 static BOOL InitTreeViewImageLists(HWND hwndTV)
563 HIMAGELIST himl; /* handle to image list */
564 HICON hico; /* handle to icon */
566 /* Create the image list. */
567 if ((himl = ImageList_Create(CX_ICON, CY_ICON,
568 ILC_MASK, 0, NUM_ICONS)) == NULL)
571 /* Add the open file, closed file, and document bitmaps. */
572 hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_OPEN_FILE));
573 Image_Open = ImageList_AddIcon(himl, hico);
575 hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_CLOSED_FILE));
576 Image_Closed = ImageList_AddIcon(himl, hico);
578 hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_ROOT));
579 Image_Root = ImageList_AddIcon(himl, hico);
581 /* Fail if not all of the images were added. */
582 if (ImageList_GetImageCount(himl) < NUM_ICONS)
587 /* Associate the image list with the tree view control. */
588 SendMessageW(hwndTV, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)himl);
593 BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
595 DWORD dwCount, dwIndex, dwMaxSubKeyLen;
596 HKEY hRoot, hNewKey, hKey;
602 static int expanding;
603 if (expanding) return FALSE;
604 if (state & TVIS_EXPANDEDONCE ) {
608 hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
609 SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
611 keyPath = GetItemPath(hwndTV, hItem, &hRoot);
612 if (!keyPath) goto done;
615 errCode = RegOpenKeyExW(hRoot, keyPath, 0, KEY_READ, &hNewKey);
616 if (errCode != ERROR_SUCCESS) goto done;
621 errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
622 if (errCode != ERROR_SUCCESS) goto done;
623 dwMaxSubKeyLen++; /* account for the \0 terminator */
624 Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR));
625 if (!Name) goto done;
627 for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
628 DWORD cName = dwMaxSubKeyLen, dwSubCount;
630 errCode = RegEnumKeyExW(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
631 if (errCode != ERROR_SUCCESS) continue;
632 errCode = RegOpenKeyExW(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
633 if (errCode == ERROR_SUCCESS) {
634 errCode = RegQueryInfoKeyW(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
637 if (errCode != ERROR_SUCCESS) dwSubCount = 0;
638 AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
640 RegCloseKey(hNewKey);
641 HeapFree(GetProcessHeap(), 0, Name);
644 TreeView_SetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE, TVIS_EXPANDEDONCE);
645 SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
646 SetCursor(hcursorOld);
648 HeapFree(GetProcessHeap(), 0, keyPath);
653 BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
655 return UpdateExpandingTree(hwndTV, pnmtv->itemNew.hItem, pnmtv->itemNew.state);
660 * CreateTreeView - creates a tree view control.
661 * Returns the handle to the new control if successful, or NULL otherwise.
662 * hwndParent - handle to the control's parent window.
664 HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, UINT id)
668 WCHAR TreeView[] = {'T','r','e','e',' ','V','i','e','w',0};
670 /* Get the dimensions of the parent window's client area, and create the tree view control. */
671 GetClientRect(hwndParent, &rcClient);
672 hwndTV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, TreeView,
673 WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
674 0, 0, rcClient.right, rcClient.bottom,
675 hwndParent, ULongToHandle(id), hInst, NULL);
676 SendMessageW(hwndTV, TVM_SETUNICODEFORMAT, TRUE, 0);
677 /* Initialize the image list, and add items to the control. */
678 if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
679 DestroyWindow(hwndTV);