Index: base/applications/regedit/framewnd.c =================================================================== --- base/applications/regedit/framewnd.c (revision 58088) +++ base/applications/regedit/framewnd.c (working copy) @@ -1306,6 +1306,13 @@ if (LOWORD(hWnd)) SetFocus(g_pChildWnd->hWnd); break; + case WM_CLOSE: + if (himlTV) + { + ImageList_Destroy(himlTV); + } + PostQuitMessage(0); + break; case WM_SIZE: resize_frame_client(hWnd); break; Index: base/applications/regedit/main.h =================================================================== --- base/applications/regedit/main.h (revision 58088) +++ base/applications/regedit/main.h (working copy) @@ -119,6 +119,7 @@ LPCWSTR getAppName(void); /* treeview.c */ +HIMAGELIST himlTV; /* handle to image list */ extern HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, HMENU id); extern BOOL RefreshTreeView(HWND hWndTV); extern BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem); Index: base/applications/regedit/treeview.c =================================================================== --- base/applications/regedit/treeview.c (revision 58088) +++ base/applications/regedit/treeview.c (working copy) @@ -437,11 +437,11 @@ */ static BOOL InitTreeViewImageLists(HWND hwndTV) { - HIMAGELIST himl; /* handle to image list */ HICON hico; /* handle to icon */ + himlTV = 0; /* Create the image list. */ - if ((himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), + if ((himlTV = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 0, @@ -459,7 +459,7 @@ 0); if (hico) { - Image_Open = ImageList_AddIcon(himl, hico); + Image_Open = ImageList_AddIcon(himlTV, hico); DestroyIcon(hico); } @@ -471,7 +471,7 @@ 0); if (hico) { - Image_Closed = ImageList_AddIcon(himl, hico); + Image_Closed = ImageList_AddIcon(himlTV, hico); DestroyIcon(hico); } @@ -483,19 +483,20 @@ 0); if (hico) { - Image_Root = ImageList_AddIcon(himl, hico); + Image_Root = ImageList_AddIcon(himlTV, hico); DestroyIcon(hico); } /* Fail if not all of the images were added. */ - if (ImageList_GetImageCount(himl) < NUM_ICONS) + if (ImageList_GetImageCount(himlTV) < NUM_ICONS) { - ImageList_Destroy(himl); + ImageList_Destroy(himlTV); + himlTV = 0; return FALSE; } /* Associate the image list with the tree view control. */ - (void)TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL); + (void)TreeView_SetImageList(hwndTV, himlTV, TVSIL_NORMAL); return TRUE; }