INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { RECT rc; int nXDifference; int nYDifference; /* HDC hdc; */ /* PAINTSTRUCT ps; */ switch (message) { case WM_DESTROY: GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph); GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph); #ifdef RUN_PERF_PAGE EndLocalThread(&hPerformanceThread, dwPerformanceThread); #endif break; case WM_INITDIALOG: /* Save the width and height */ GetClientRect(hDlg, &rc); nPerformancePageWidth = rc.right; nPerformancePageHeight = rc.bottom; /* Update window position */ SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); /* * Get handles to all the controls */ hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME); hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME); hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME); hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME); hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME); hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME); hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME); hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME); hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL); hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT); hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK); hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL); hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED); hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED); hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL); hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE); hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE); hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT); hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT); hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT); hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH); hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH); hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH); hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc); /* create the control */ /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */ GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); /* customize the control */ GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10); /* PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; */ /* PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; */ /* PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; */ /* PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; */ /* PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */ GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ; GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 128, 64)); GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(0, 255, 0)) ; GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 1, RGB(255, 0, 0)) ; GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc); GraphCtrl_Create(&PerformancePageMemUsageHistoryGraph, hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH); GraphCtrl_SetRange(&PerformancePageMemUsageHistoryGraph, 0.0, 100.0, 10) ; GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ; GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 128, 64)) ; GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ; /* Start our refresh thread */ #ifdef RUN_PERF_PAGE hPerformanceThread = CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, &dwPerformanceThread); #endif /* * Subclass graph buttons */ OldGraphWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); SetWindowLongPtrW(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); OldGraphCtrlWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); return TRUE; case WM_COMMAND: break; #if 0 case WM_NCPAINT: hdc = GetDC(hDlg); GetClientRect(hDlg, &rc); Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); ReleaseDC(hDlg, hdc); break; case WM_PAINT: hdc = BeginPaint(hDlg, &ps); GetClientRect(hDlg, &rc); Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); EndPaint(hDlg, &ps); break; #endif case WM_SIZE: do { int cx, cy; if (wParam == SIZE_MINIMIZED) return 0; cx = LOWORD(lParam); cy = HIWORD(lParam); nXDifference = cx - nPerformancePageWidth; nYDifference = cy - nPerformancePageHeight; nPerformancePageWidth = cx; nPerformancePageHeight = cy; } while (0); /* Reposition the performance page's controls */ AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0); AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference); AdjustControlPostion(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference); nXDifference += lastX; nYDifference += lastY; lastX = lastY = 0; if (nXDifference % 2) { if (nXDifference > 0) { nXDifference--; lastX++; } else { nXDifference++; lastX--; } } if (nYDifference % 2) { if (nYDifference > 0) { nYDifference--; lastY++; } else { nYDifference++; lastY--; } } AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1); AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2); AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3); AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4); AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1); AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2); AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3); AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4); break; } return 0; }
INT_PTR CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { RECT rc; int nXDifference; int nYDifference; int cx, cy; switch (message) { case WM_INITDIALOG: /* * Save the width and height */ GetClientRect(hDlg, &rc); nProcessPageWidth = rc.right; nProcessPageHeight = rc.bottom; /* Update window position */ SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); /* * Get handles to the controls */ hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST); hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl); hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS); hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES); /* * Set the title, and extended window styles for the list control */ SetWindowTextW(hProcessPageListCtrl, L"Processes"); (void)ListView_SetExtendedListViewStyle(hProcessPageListCtrl, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP); AddColumns(); /* * Subclass the process list control so we can intercept WM_ERASEBKGND */ OldProcessListWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc); #ifdef RUN_PROC_PAGE /* Start our refresh thread */ hProcessThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, &dwProcessThread); #endif return TRUE; case WM_DESTROY: /* Close the event handle, this will make the */ /* refresh thread exit when the wait fails */ #ifdef RUN_PROC_PAGE EndLocalThread(&hProcessThread, dwProcessThread); #endif SaveColumnSettings(); break; case WM_COMMAND: /* Handle the button clicks */ switch (LOWORD(wParam)) { case IDC_ENDPROCESS: ProcessPage_OnEndProcess(); } break; case WM_SIZE: if (wParam == SIZE_MINIMIZED) return 0; cx = LOWORD(lParam); cy = HIWORD(lParam); nXDifference = cx - nProcessPageWidth; nYDifference = cy - nProcessPageHeight; nProcessPageWidth = cx; nProcessPageHeight = cy; /* Reposition the application page's controls */ GetWindowRect(hProcessPageListCtrl, &rc); cx = (rc.right - rc.left) + nXDifference; cy = (rc.bottom - rc.top) + nYDifference; SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); InvalidateRect(hProcessPageListCtrl, NULL, TRUE); GetClientRect(hProcessPageEndProcessButton, &rc); MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT)); cx = rc.left + nXDifference; cy = rc.top + nYDifference; SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE); GetClientRect(hProcessPageShowAllProcessesButton, &rc); MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT)); cx = rc.left; cy = rc.top + nYDifference; SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE); break; case WM_NOTIFY: ProcessPageOnNotify(wParam, lParam); break; case WM_KEYDOWN: if (wParam == VK_DELETE) ProcessPage_OnEndProcess(); break; } return 0; }
INT_PTR CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { RECT rc; int nXDifference; int nYDifference; LV_COLUMN column; WCHAR szTemp[256]; int cx, cy; switch (message) { case WM_INITDIALOG: /* Save the width and height */ GetClientRect(hDlg, &rc); nApplicationPageWidth = rc.right; nApplicationPageHeight = rc.bottom; /* Update window position */ SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); /* Get handles to the controls */ hApplicationPageListCtrl = GetDlgItem(hDlg, IDC_APPLIST); hApplicationPageEndTaskButton = GetDlgItem(hDlg, IDC_ENDTASK); hApplicationPageSwitchToButton = GetDlgItem(hDlg, IDC_SWITCHTO); hApplicationPageNewTaskButton = GetDlgItem(hDlg, IDC_NEWTASK); SetWindowTextW(hApplicationPageListCtrl, L"Tasks"); /* Initialize the application page's controls */ column.mask = LVCF_TEXT|LVCF_WIDTH; LoadStringW(hInst, IDS_TAB_TASK, szTemp, 256); column.pszText = szTemp; column.cx = 250; (void)ListView_InsertColumn(hApplicationPageListCtrl, 0, &column); /* Add the "Task" column */ column.mask = LVCF_TEXT|LVCF_WIDTH; LoadStringW(hInst, IDS_TAB_STATUS, szTemp, 256); column.pszText = szTemp; column.cx = 95; (void)ListView_InsertColumn(hApplicationPageListCtrl, 1, &column); /* Add the "Status" column */ (void)ListView_SetImageList(hApplicationPageListCtrl, ImageList_Create(16, 16, GetSystemColorDepth()|ILC_MASK, 0, 1), LVSIL_SMALL); (void)ListView_SetImageList(hApplicationPageListCtrl, ImageList_Create(32, 32, GetSystemColorDepth()|ILC_MASK, 0, 1), LVSIL_NORMAL); UpdateApplicationListControlViewSetting(); /* Start our refresh thread */ #ifdef RUN_APPS_PAGE hApplicationThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, &dwApplicationThread); #endif /* Refresh page */ ApplicationPageUpdate(); return TRUE; case WM_DESTROY: /* Close refresh thread */ #ifdef RUN_APPS_PAGE EndLocalThread(&hApplicationThread, dwApplicationThread); #endif break; case WM_COMMAND: /* Handle the button clicks */ switch (LOWORD(wParam)) { case IDC_ENDTASK: ApplicationPage_OnEndTask(); break; case IDC_SWITCHTO: ApplicationPage_OnSwitchTo(); break; case IDC_NEWTASK: SendMessageW(hMainWnd, WM_COMMAND, MAKEWPARAM(ID_FILE_NEW, 0), 0); break; } break; case WM_SIZE: if (wParam == SIZE_MINIMIZED) return 0; cx = LOWORD(lParam); cy = HIWORD(lParam); nXDifference = cx - nApplicationPageWidth; nYDifference = cy - nApplicationPageHeight; nApplicationPageWidth = cx; nApplicationPageHeight = cy; /* Reposition the application page's controls */ GetWindowRect(hApplicationPageListCtrl, &rc); cx = (rc.right - rc.left) + nXDifference; cy = (rc.bottom - rc.top) + nYDifference; SetWindowPos(hApplicationPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); InvalidateRect(hApplicationPageListCtrl, NULL, TRUE); GetClientRect(hApplicationPageEndTaskButton, &rc); MapWindowPoints(hApplicationPageEndTaskButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT)); cx = rc.left + nXDifference; cy = rc.top + nYDifference; SetWindowPos(hApplicationPageEndTaskButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); InvalidateRect(hApplicationPageEndTaskButton, NULL, TRUE); GetClientRect(hApplicationPageSwitchToButton, &rc); MapWindowPoints(hApplicationPageSwitchToButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT)); cx = rc.left + nXDifference; cy = rc.top + nYDifference; SetWindowPos(hApplicationPageSwitchToButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); InvalidateRect(hApplicationPageSwitchToButton, NULL, TRUE); GetClientRect(hApplicationPageNewTaskButton, &rc); MapWindowPoints(hApplicationPageNewTaskButton, hDlg, (LPPOINT)(PRECT)(&rc), sizeof(RECT)/sizeof(POINT)); cx = rc.left + nXDifference; cy = rc.top + nYDifference; SetWindowPos(hApplicationPageNewTaskButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); InvalidateRect(hApplicationPageNewTaskButton, NULL, TRUE); break; case WM_NOTIFY: ApplicationPageOnNotify(wParam, lParam); break; case WM_KEYDOWN: if (wParam == VK_DELETE) ProcessPage_OnEndProcess(); break; } return 0; }