HWND hApplicationPageNewTaskButton; /* Application New Task button */
static int nApplicationPageWidth;
static int nApplicationPageHeight;
-static HANDLE hApplicationPageEvent = NULL; /* When this event becomes signaled then we refresh the app list */
static BOOL bSortAscending = TRUE;
DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter);
BOOL noApps;
void ApplicationPageShowContextMenu1(void);
void ApplicationPageShowContextMenu2(void);
int CALLBACK ApplicationPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
-int PerfGetIndexByProcessId(DWORD dwProcessId);
+int ProcGetIndexByProcessId(DWORD dwProcessId);
+
+#ifdef RUN_APPS_PAGE
+static HANDLE hApplicationThread = NULL;
+static DWORD dwApplicationThread;
+#endif
#if 0
void SwitchToThisWindow (
LV_COLUMN column;
WCHAR szTemp[256];
int cx, cy;
- HANDLE hRefreshThread = NULL;
switch (message) {
case WM_INITDIALOG:
UpdateApplicationListControlViewSetting();
/* Start our refresh thread */
- hRefreshThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, NULL);
-
+#ifdef RUN_APPS_PAGE
+ hApplicationThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, &dwApplicationThread);
+#endif
return TRUE;
case WM_DESTROY:
- /* Close the event handle, this will make the */
- /* refresh thread exit when the wait fails */
- CloseHandle(hApplicationPageEvent);
- CloseHandle(hRefreshThread);
+ /* Close refresh thread */
+#ifdef RUN_APPS_PAGE
+ EndLocalThread(&hApplicationThread, dwApplicationThread);
+#endif
break;
case WM_COMMAND:
void RefreshApplicationPage(void)
{
+#ifdef RUN_APPS_PAGE
/* Signal the event so that our refresh thread */
/* will wake up and refresh the application page */
- SetEvent(hApplicationPageEvent);
+ PostThreadMessage(dwApplicationThread, WM_TIMER, 0, 0);
+#endif
}
void UpdateApplicationListControlViewSetting(void)
DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter)
{
- /* Create the event */
- hApplicationPageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
+ MSG msg;
+ INT i;
+ BOOL bItemRemoved = FALSE;
+ LV_ITEM item;
+ LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL;
+ HIMAGELIST hImageListLarge;
+ HIMAGELIST hImageListSmall;
/* If we couldn't create the event then exit the thread */
- if (!hApplicationPageEvent)
- return 0;
-
while (1)
{
- DWORD dwWaitVal;
-
- /* Wait on the event */
- dwWaitVal = WaitForSingleObject(hApplicationPageEvent, INFINITE);
-
- /* If the wait failed then the event object must have been */
- /* closed and the task manager is exiting so exit this thread */
- if (dwWaitVal == WAIT_FAILED)
+ /* Wait for an the event or application close */
+ if (GetMessage(&msg, NULL, 0, 0) <= 0)
return 0;
- if (dwWaitVal == WAIT_OBJECT_0)
+ if (msg.message == WM_TIMER)
{
- /* Reset our event */
- ResetEvent(hApplicationPageEvent);
-
/*
* FIXME:
*
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<ListView_GetItemCount(hApplicationPageListCtrl); i++)
+ {
+ memset(&item, 0, sizeof(LV_ITEM));
+ item.mask = LVIF_IMAGE;
+ item.iItem = i;
+ item.iImage = i;
+ (void)ListView_SetItem(hApplicationPageListCtrl, &item);
+ }
+ bItemRemoved = FALSE;
+ }
+
+ ApplicationPageUpdate();
}
}
}
void AddOrUpdateHwnd(HWND hWnd, WCHAR *szTitle, HICON hIcon, BOOL bHung)
{
- LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL;
- HIMAGELIST hImageListLarge;
- HIMAGELIST hImageListSmall;
- LV_ITEM item;
- int i;
- BOOL bAlreadyInList = FALSE;
- BOOL bItemRemoved = FALSE;
+ LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL;
+ HIMAGELIST hImageListLarge;
+ HIMAGELIST hImageListSmall;
+ LV_ITEM item;
+ int i;
+ BOOL bAlreadyInList = FALSE;
memset(&item, 0, sizeof(LV_ITEM));
item.lParam = (LPARAM)pAPLI;
(void)ListView_InsertItem(hApplicationPageListCtrl, &item);
}
-
-
- /* 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) ||
- (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<ListView_GetItemCount(hApplicationPageListCtrl); i++)
- {
- memset(&item, 0, sizeof(LV_ITEM));
- item.mask = LVIF_IMAGE;
- item.iItem = i;
- item.iImage = i;
- (void)ListView_SetItem(hApplicationPageListCtrl, &item);
- }
- }
-
- ApplicationPageUpdate();
+ return;
}
void ApplicationPageUpdate(void)
LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL;
LV_ITEM item;
int i;
- /* NMHDR nmhdr; */
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
memset(&item, 0, sizeof(LV_ITEM));
/*
* Select the process item in the list
*/
- i = PerfGetIndexByProcessId(dwProcessId);
+ i = ProcGetIndexByProcessId(dwProcessId);
if (i != -1)
{
ListView_SetItemState(hProcessPageListCtrl,