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_GetItem(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 = (HTREEITEM)(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_GetItem(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);
270 RegEnumValueW(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue);
271 if (match_string(buffer, sstring, mode)) {
272 HeapFree(GetProcessHeap(), 0, buffer);
277 HeapFree(GetProcessHeap(), 0, buffer);
287 HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, int *row)
289 HTREEITEM hTry, hLast;
293 if (match_item(hwndTV, hLast, sstring, mode & ~SEARCH_KEYS, row)) {
299 /* first look in subtree */
300 /* no children? maybe we haven't loaded them yet? */
301 if (!TreeView_GetChild(hwndTV, hLast)) {
302 UpdateExpandingTree(hwndTV, hLast, TreeView_GetItemState(hwndTV, hLast, -1));
304 hTry = TreeView_GetChild(hwndTV, hLast);
306 if (match_item(hwndTV, hTry, sstring, mode, row))
311 /* no more children, maybe there are any siblings? */
312 hTry = TreeView_GetNextSibling(hwndTV, hLast);
314 if (match_item(hwndTV, hTry, sstring, mode, row))
319 /* no more siblings, look at the next siblings in parent(s) */
320 hLast = TreeView_GetParent(hwndTV, hLast);
323 while (hLast && (hTry = TreeView_GetNextSibling(hwndTV, hLast)) == NULL) {
324 hLast = TreeView_GetParent(hwndTV, hLast);
326 if (match_item(hwndTV, hTry, sstring, mode, row))
333 static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
335 HKEY hRoot, hKey, hSubKey;
338 DWORD dwCount, dwIndex, dwMaxSubKeyLen;
343 KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
345 if (!KeyPath || !hRoot)
349 if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
350 WINE_TRACE("RegOpenKeyEx failed, %s was probably removed.\n", wine_dbgstr_w(KeyPath));
356 HeapFree(GetProcessHeap(), 0, KeyPath);
358 if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
362 /* Set the number of children again */
363 tvItem.mask = TVIF_CHILDREN;
364 tvItem.hItem = hItem;
365 tvItem.cChildren = dwCount;
366 if (!TreeView_SetItemW(hwndTV, &tvItem)) {
370 /* We don't have to bother with the rest if it's not expanded. */
371 if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDED) == 0) {
376 dwMaxSubKeyLen++; /* account for the \0 terminator */
377 if (!(Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
380 tvItem.cchTextMax = dwMaxSubKeyLen;
381 if (!(tvItem.pszText = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR)))) {
382 HeapFree(GetProcessHeap(), 0, Name);
386 /* Now go through all the children in the registry, and check if any have to be added. */
387 for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
388 DWORD cName = dwMaxSubKeyLen, dwSubCount;
392 if (RegEnumKeyExW(hKey, dwIndex, Name, &cName, 0, 0, 0, NULL) != ERROR_SUCCESS) {
396 /* Find the number of children of the node. */
398 if (RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey) == ERROR_SUCCESS) {
399 if (RegQueryInfoKey(hSubKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
402 RegCloseKey(hSubKey);
405 /* Check if the node is already in there. */
406 for (childItem = TreeView_GetChild(hwndTV, hItem); childItem;
407 childItem = TreeView_GetNextSibling(hwndTV, childItem)) {
408 tvItem.mask = TVIF_TEXT;
409 tvItem.hItem = childItem;
410 if (!TreeView_GetItemW(hwndTV, &tvItem)) {
411 HeapFree(GetProcessHeap(), 0, Name);
412 HeapFree(GetProcessHeap(), 0, tvItem.pszText);
416 if (!lstrcmpiW(tvItem.pszText, Name)) {
422 if (found == FALSE) {
423 WINE_TRACE("New subkey %s\n", wine_dbgstr_w(Name));
424 AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
427 HeapFree(GetProcessHeap(), 0, Name);
428 HeapFree(GetProcessHeap(), 0, tvItem.pszText);
431 /* Now go through all the children in the tree, and check if any have to be removed. */
432 childItem = TreeView_GetChild(hwndTV, hItem);
434 HTREEITEM nextItem = TreeView_GetNextSibling(hwndTV, childItem);
435 if (RefreshTreeItem(hwndTV, childItem) == FALSE) {
436 SendMessageW(hwndTV, TVM_DELETEITEM, 0, (LPARAM)childItem);
438 childItem = nextItem;
444 BOOL RefreshTreeView(HWND hwndTV)
447 HTREEITEM hSelectedItem;
451 hSelectedItem = TreeView_GetSelection(hwndTV);
452 hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
453 SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
455 hItem = TreeView_GetChild(hwndTV, TreeView_GetRoot(hwndTV));
457 RefreshTreeItem(hwndTV, hItem);
458 hItem = TreeView_GetNextSibling(hwndTV, hItem);
461 SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
462 InvalidateRect(hwndTV, NULL, FALSE);
463 SetCursor(hcursorOld);
465 /* We reselect the currently selected node, this will prompt a refresh of the listview. */
466 SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hSelectedItem);
470 HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
472 WCHAR buf[MAX_NEW_KEY_LEN];
473 HTREEITEM hNewItem = 0;
476 if (!hItem) hItem = TreeView_GetSelection(hwndTV);
477 if (!hItem) return FALSE;
478 if (TreeView_GetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE)) {
479 hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
481 item.mask = TVIF_CHILDREN | TVIF_HANDLE;
483 if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
485 if (!TreeView_SetItemW(hwndTV, &item)) return FALSE;
487 SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
489 for(hNewItem = TreeView_GetChild(hwndTV, hItem); hNewItem; hNewItem = TreeView_GetNextSibling(hwndTV, hNewItem)) {
490 item.mask = TVIF_HANDLE | TVIF_TEXT;
491 item.hItem = hNewItem;
493 item.cchTextMax = COUNT_OF(buf);
494 if (!TreeView_GetItemW(hwndTV, &item)) continue;
495 if (lstrcmpW(name, item.pszText) == 0) break;
499 SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hNewItem);
504 HWND StartKeyRename(HWND hwndTV)
508 if(!(hItem = TreeView_GetSelection(hwndTV))) return 0;
509 return TreeView_EditLabel(hwndTV, hItem);
512 static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName)
514 TVINSERTSTRUCTW tvins;
516 static WCHAR hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0},
517 hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0},
518 hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0},
519 hku[] = {'H','K','E','Y','_','U','S','E','R','S',0},
520 hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0},
521 hkdd[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0};
523 tvins.u.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
524 /* Set the text of the item. */
525 tvins.u.item.pszText = pHostName;
526 tvins.u.item.cchTextMax = lstrlenW(pHostName);
527 /* Assume the item is not a parent item, so give it an image. */
528 tvins.u.item.iImage = Image_Root;
529 tvins.u.item.iSelectedImage = Image_Root;
530 tvins.u.item.cChildren = 5;
531 /* Save the heading level in the item's application-defined data area. */
532 tvins.u.item.lParam = (LPARAM)NULL;
533 tvins.hInsertAfter = (HTREEITEM)TVI_FIRST;
534 tvins.hParent = TVI_ROOT;
535 /* Add the item to the tree view control. */
536 if (!(hRoot = TreeView_InsertItemW(hwndTV, &tvins))) return FALSE;
538 if (!AddEntryToTree(hwndTV, hRoot, hkcr, HKEY_CLASSES_ROOT, 1)) return FALSE;
539 if (!AddEntryToTree(hwndTV, hRoot, hkcu, HKEY_CURRENT_USER, 1)) return FALSE;
540 if (!AddEntryToTree(hwndTV, hRoot, hklm, HKEY_LOCAL_MACHINE, 1)) return FALSE;
541 if (!AddEntryToTree(hwndTV, hRoot, hku, HKEY_USERS, 1)) return FALSE;
542 if (!AddEntryToTree(hwndTV, hRoot, hkcc, HKEY_CURRENT_CONFIG, 1)) return FALSE;
543 if (!AddEntryToTree(hwndTV, hRoot, hkdd, HKEY_DYN_DATA, 1)) return FALSE;
545 /* expand and select host name */
546 SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hRoot );
547 SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hRoot);
553 * InitTreeViewImageLists - creates an image list, adds three bitmaps
554 * to it, and associates the image list with a tree view control.
555 * Returns TRUE if successful, or FALSE otherwise.
556 * hwndTV - handle to the tree view control.
558 static BOOL InitTreeViewImageLists(HWND hwndTV)
560 HIMAGELIST himl; /* handle to image list */
561 HICON hico; /* handle to icon */
563 /* Create the image list. */
564 if ((himl = ImageList_Create(CX_ICON, CY_ICON,
565 ILC_MASK, 0, NUM_ICONS)) == NULL)
568 /* Add the open file, closed file, and document bitmaps. */
569 hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_OPEN_FILE));
570 Image_Open = ImageList_AddIcon(himl, hico);
572 hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_CLOSED_FILE));
573 Image_Closed = ImageList_AddIcon(himl, hico);
575 hico = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_ROOT));
576 Image_Root = ImageList_AddIcon(himl, hico);
578 /* Fail if not all of the images were added. */
579 if (ImageList_GetImageCount(himl) < NUM_ICONS)
584 /* Associate the image list with the tree view control. */
585 SendMessageW(hwndTV, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)himl);
590 BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
592 DWORD dwCount, dwIndex, dwMaxSubKeyLen;
593 HKEY hRoot, hNewKey, hKey;
599 static int expanding;
600 if (expanding) return FALSE;
601 if (state & TVIS_EXPANDEDONCE ) {
605 hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
606 SendMessageW(hwndTV, WM_SETREDRAW, FALSE, 0);
608 keyPath = GetItemPath(hwndTV, hItem, &hRoot);
609 if (!keyPath) goto done;
612 errCode = RegOpenKeyExW(hRoot, keyPath, 0, KEY_READ, &hNewKey);
613 if (errCode != ERROR_SUCCESS) goto done;
618 errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
619 if (errCode != ERROR_SUCCESS) goto done;
620 dwMaxSubKeyLen++; /* account for the \0 terminator */
621 Name = HeapAlloc(GetProcessHeap(), 0, dwMaxSubKeyLen * sizeof(WCHAR));
622 if (!Name) goto done;
624 for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
625 DWORD cName = dwMaxSubKeyLen, dwSubCount;
627 errCode = RegEnumKeyExW(hNewKey, dwIndex, Name, &cName, 0, 0, 0, 0);
628 if (errCode != ERROR_SUCCESS) continue;
629 errCode = RegOpenKeyExW(hNewKey, Name, 0, KEY_QUERY_VALUE, &hKey);
630 if (errCode == ERROR_SUCCESS) {
631 errCode = RegQueryInfoKeyW(hKey, 0, 0, 0, &dwSubCount, 0, 0, 0, 0, 0, 0, 0);
634 if (errCode != ERROR_SUCCESS) dwSubCount = 0;
635 AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
637 RegCloseKey(hNewKey);
638 HeapFree(GetProcessHeap(), 0, Name);
641 TreeView_SetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE, TVIS_EXPANDEDONCE);
642 SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
643 SetCursor(hcursorOld);
645 HeapFree(GetProcessHeap(), 0, keyPath);
650 BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
652 return UpdateExpandingTree(hwndTV, pnmtv->itemNew.hItem, pnmtv->itemNew.state);
657 * CreateTreeView - creates a tree view control.
658 * Returns the handle to the new control if successful, or NULL otherwise.
659 * hwndParent - handle to the control's parent window.
661 HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, UINT id)
665 WCHAR TreeView[] = {'T','r','e','e',' ','V','i','e','w',0};
667 /* Get the dimensions of the parent window's client area, and create the tree view control. */
668 GetClientRect(hwndParent, &rcClient);
669 hwndTV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, TreeView,
670 WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
671 0, 0, rcClient.right, rcClient.bottom,
672 hwndParent, (HMENU)ULongToHandle(id), hInst, NULL);
673 SendMessageW(hwndTV, TVM_SETUNICODEFORMAT, TRUE, 0);
674 /* Initialize the image list, and add items to the control. */
675 if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
676 DestroyWindow(hwndTV);