From d31ce0d47ba77de0de3eeacc3d08b4185a371f24 Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Sat, 10 Apr 2010 16:19:30 +0000 Subject: [PATCH] [TASKMGR] Handle icon list checks after enumerating windows, instead of doing them per window Patch by Timo Kreuzer, bug #1940 svn path=/trunk/; revision=46818 --- reactos/base/applications/taskmgr/applpage.c | 115 ++++++++++--------- 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/reactos/base/applications/taskmgr/applpage.c b/reactos/base/applications/taskmgr/applpage.c index 355c3aea51a..0c20e810817 100644 --- a/reactos/base/applications/taskmgr/applpage.c +++ b/reactos/base/applications/taskmgr/applpage.c @@ -236,6 +236,13 @@ void UpdateApplicationListControlViewSetting(void) DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter) { + INT i; + BOOL bItemRemoved = FALSE; + LV_ITEM item; + LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL; + HIMAGELIST hImageListLarge; + HIMAGELIST hImageListSmall; + /* Create the event */ hApplicationPageEvent = CreateEventW(NULL, TRUE, TRUE, NULL); @@ -269,6 +276,55 @@ DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter) EnumWindows(EnumWindowsProc, 0); if (noApps) (void)ListView_DeleteAllItems(hApplicationPageListCtrl); + + /* Get the image lists */ + hImageListLarge = ListView_GetImageList(hApplicationPageListCtrl, LVSIL_NORMAL); + hImageListSmall = ListView_GetImageList(hApplicationPageListCtrl, LVSIL_SMALL); + + /* Check to see if we need to remove any items from the list */ + for (i=ListView_GetItemCount(hApplicationPageListCtrl)-1; i>=0; i--) + { + memset(&item, 0, sizeof(LV_ITEM)); + item.mask = LVIF_IMAGE|LVIF_PARAM; + item.iItem = i; + (void)ListView_GetItem(hApplicationPageListCtrl, &item); + + pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam; + if (!IsWindow(pAPLI->hWnd)|| + (wcslen(pAPLI->szTitle) <= 0) || + !IsWindowVisible(pAPLI->hWnd) || + (GetParent(pAPLI->hWnd) != NULL) || + (GetWindow(pAPLI->hWnd, GW_OWNER) != NULL) || + (GetWindowLongPtr(pAPLI->hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) + { + ImageList_Remove(hImageListLarge, item.iItem); + ImageList_Remove(hImageListSmall, item.iItem); + + (void)ListView_DeleteItem(hApplicationPageListCtrl, item.iItem); + HeapFree(GetProcessHeap(), 0, pAPLI); + bItemRemoved = TRUE; + } + } + + /* + * If an item was removed from the list then + * we need to resync all the items with the + * image list + */ + if (bItemRemoved) + { + for (i=0; i=0; i--) - { - memset(&item, 0, sizeof(LV_ITEM)); - item.mask = LVIF_IMAGE|LVIF_PARAM; - item.iItem = i; - (void)ListView_GetItem(hApplicationPageListCtrl, &item); - - pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam; - if (!IsWindow(pAPLI->hWnd)|| - (wcslen(pAPLI->szTitle) <= 0) || - !IsWindowVisible(pAPLI->hWnd) || - (GetParent(pAPLI->hWnd) != NULL) || - (GetWindow(pAPLI->hWnd, GW_OWNER) != NULL) || - (GetWindowLongPtrW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) - { - ImageList_Remove(hImageListLarge, item.iItem); - ImageList_Remove(hImageListSmall, item.iItem); - - (void)ListView_DeleteItem(hApplicationPageListCtrl, item.iItem); - HeapFree(GetProcessHeap(), 0, pAPLI); - bItemRemoved = TRUE; - } - } - - /* - * If an item was removed from the list then - * we need to resync all the items with the - * image list - */ - if (bItemRemoved) - { - for (i=0; i