[TASKMGR] Completely reformat perfpage.c, perfpage.h, procpage.h and trayicon.c

- Rename also these stupidly long "hPerformancePageBlablabla" variables.
- Remove unnecessary global variables in procpage.c/h.
This commit is contained in:
Hermès Bélusca-Maïto 2022-05-15 21:51:29 +02:00
parent da7dcec6a0
commit 7b53126375
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 300 additions and 315 deletions

View file

@ -14,30 +14,30 @@ TM_GRAPH_CONTROL PerformancePageCpuUsageHistoryGraph;
TM_GRAPH_CONTROL PerformancePageMemUsageHistoryGraph; TM_GRAPH_CONTROL PerformancePageMemUsageHistoryGraph;
HWND hPerformancePage; /* Performance Property Page */ HWND hPerformancePage; /* Performance Property Page */
HWND hPerformancePageCpuUsageGraph; /* CPU Usage Graph */ static HWND hCpuUsageGraph; /* CPU Usage Graph */
HWND hPerformancePageMemUsageGraph; /* MEM Usage Graph */ static HWND hMemUsageGraph; /* MEM Usage Graph */
HWND hPerformancePageCpuUsageHistoryGraph; /* CPU Usage History Graph */ HWND hPerformancePageCpuUsageHistoryGraph; /* CPU Usage History Graph */
HWND hPerformancePageMemUsageHistoryGraph; /* Memory Usage History Graph */ HWND hPerformancePageMemUsageHistoryGraph; /* Memory Usage History Graph */
HWND hPerformancePageTotalsFrame; /* Totals Frame */ static HWND hTotalsFrame; /* Totals Frame */
HWND hPerformancePageCommitChargeFrame; /* Commit Charge Frame */ static HWND hCommitChargeFrame; /* Commit Charge Frame */
HWND hPerformancePageKernelMemoryFrame; /* Kernel Memory Frame */ static HWND hKernelMemoryFrame; /* Kernel Memory Frame */
HWND hPerformancePagePhysicalMemoryFrame; /* Physical Memory Frame */ static HWND hPhysicalMemoryFrame; /* Physical Memory Frame */
HWND hPerformancePageCpuUsageFrame; static HWND hCpuUsageFrame;
HWND hPerformancePageMemUsageFrame; static HWND hMemUsageFrame;
HWND hPerformancePageCpuUsageHistoryFrame; static HWND hCpuUsageHistoryFrame;
HWND hPerformancePageMemUsageHistoryFrame; static HWND hMemUsageHistoryFrame;
HWND hPerformancePageCommitChargeTotalEdit; /* Commit Charge Total Edit Control */ static HWND hCommitChargeTotalEdit; /* Commit Charge Total Edit Control */
HWND hPerformancePageCommitChargeLimitEdit; /* Commit Charge Limit Edit Control */ static HWND hCommitChargeLimitEdit; /* Commit Charge Limit Edit Control */
HWND hPerformancePageCommitChargePeakEdit; /* Commit Charge Peak Edit Control */ static HWND hCommitChargePeakEdit; /* Commit Charge Peak Edit Control */
HWND hPerformancePageKernelMemoryTotalEdit; /* Kernel Memory Total Edit Control */ static HWND hKernelMemoryTotalEdit; /* Kernel Memory Total Edit Control */
HWND hPerformancePageKernelMemoryPagedEdit; /* Kernel Memory Paged Edit Control */ static HWND hKernelMemoryPagedEdit; /* Kernel Memory Paged Edit Control */
HWND hPerformancePageKernelMemoryNonPagedEdit; /* Kernel Memory NonPaged Edit Control */ static HWND hKernelMemoryNonPagedEdit; /* Kernel Memory NonPaged Edit Control */
HWND hPerformancePagePhysicalMemoryTotalEdit; /* Physical Memory Total Edit Control */ static HWND hPhysicalMemoryTotalEdit; /* Physical Memory Total Edit Control */
HWND hPerformancePagePhysicalMemoryAvailableEdit; /* Physical Memory Available Edit Control */ static HWND hPhysicalMemoryAvailableEdit; /* Physical Memory Available Edit Control */
HWND hPerformancePagePhysicalMemorySystemCacheEdit; /* Physical Memory System Cache Edit Control */ static HWND hPhysicalMemorySystemCacheEdit; /* Physical Memory System Cache Edit Control */
HWND hPerformancePageTotalsHandleCountEdit; /* Total Handles Edit Control */ static HWND hTotalsHandleCountEdit; /* Total Handles Edit Control */
HWND hPerformancePageTotalsProcessCountEdit; /* Total Processes Edit Control */ static HWND hTotalsProcessCountEdit; /* Total Processes Edit Control */
HWND hPerformancePageTotalsThreadCountEdit; /* Total Threads Edit Control */ static HWND hTotalsThreadCountEdit; /* Total Threads Edit Control */
#ifdef RUN_PERF_PAGE #ifdef RUN_PERF_PAGE
static HANDLE hPerformanceThread = NULL; static HANDLE hPerformanceThread = NULL;
@ -47,7 +47,7 @@ static DWORD dwPerformanceThread;
static int nPerformancePageWidth; static int nPerformancePageWidth;
static int nPerformancePageHeight; static int nPerformancePageHeight;
static int lastX, lastY; static int lastX, lastY;
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter); DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter);
void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos) void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
{ {
@ -84,12 +84,14 @@ void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference,
InvalidateRect(hCntrl, NULL, TRUE); InvalidateRect(hCntrl, NULL, TRUE);
} }
static void AdjustControlPosition(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference) static inline
void AdjustControlPosition(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
{ {
AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0); AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
} }
static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference) static inline
void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
{ {
AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0); AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
} }
@ -98,12 +100,9 @@ INT_PTR CALLBACK
PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
RECT rc; RECT rc;
int nXDifference;
int nYDifference;
/* HDC hdc; */
/* PAINTSTRUCT ps; */
switch (message) { switch (message)
{
case WM_DESTROY: case WM_DESTROY:
GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph); GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph);
GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph); GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph);
@ -128,31 +127,31 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
/* /*
* Get handles to all the controls * Get handles to all the controls
*/ */
hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME); hTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME);
hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME); hCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME); hKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME); hPhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME);
hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME); hCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME);
hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME); hMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME);
hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME); hCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME);
hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME); hMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME);
hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL); hCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL);
hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT); hCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT);
hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK); hCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK);
hPerformancePageKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL); hKernelMemoryTotalEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_TOTAL);
hPerformancePageKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED); hKernelMemoryPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_PAGED);
hPerformancePageKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED); hKernelMemoryNonPagedEdit = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_NONPAGED);
hPerformancePagePhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL); hPhysicalMemoryTotalEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_TOTAL);
hPerformancePagePhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE); hPhysicalMemoryAvailableEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_AVAILABLE);
hPerformancePagePhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE); hPhysicalMemorySystemCacheEdit = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_SYSTEM_CACHE);
hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT); hTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT);
hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT); hTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT);
hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT); hTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT);
hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH); hCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH);
hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH); hMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH);
hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH); hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
@ -188,8 +187,8 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
/* /*
* Subclass graph buttons * Subclass graph buttons
*/ */
OldGraphWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); OldGraphWndProc = (WNDPROC)SetWindowLongPtrW(hCpuUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
SetWindowLongPtrW(hPerformancePageMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc); SetWindowLongPtrW(hMemUsageGraph, GWLP_WNDPROC, (LONG_PTR)Graph_WndProc);
OldGraphCtrlWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); OldGraphCtrlWndProc = (WNDPROC)SetWindowLongPtrW(hPerformancePageMemUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc); SetWindowLongPtrW(hPerformancePageCpuUsageHistoryGraph, GWLP_WNDPROC, (LONG_PTR)GraphCtrl_WndProc);
return TRUE; return TRUE;
@ -197,24 +196,12 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case WM_COMMAND: case WM_COMMAND:
break; 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: case WM_SIZE:
do { {
int cx, cy; int cx, cy;
int nXDifference;
int nYDifference;
if (wParam == SIZE_MINIMIZED) if (wParam == SIZE_MINIMIZED)
return 0; return 0;
@ -225,13 +212,12 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
nYDifference = cy - nPerformancePageHeight; nYDifference = cy - nPerformancePageHeight;
nPerformancePageWidth = cx; nPerformancePageWidth = cx;
nPerformancePageHeight = cy; nPerformancePageHeight = cy;
} while (0);
/* Reposition the performance page's controls */ /* Reposition the performance page's controls */
AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hTotalsFrame, hDlg, 0, nYDifference, 0);
AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hCommitChargeFrame, hDlg, 0, nYDifference, 0);
AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hKernelMemoryFrame, hDlg, 0, nYDifference, 0);
AdjustFrameSize(hPerformancePagePhysicalMemoryFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPhysicalMemoryFrame, hDlg, 0, nYDifference, 0);
AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, 0, nYDifference);
AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, 0, nYDifference);
AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, 0, nYDifference);
@ -245,63 +231,72 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, 0, nYDifference);
AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference); AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageCommitChargeTotalEdit, hDlg, 0, nYDifference); AdjustControlPosition(hCommitChargeTotalEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageCommitChargeLimitEdit, hDlg, 0, nYDifference); AdjustControlPosition(hCommitChargeLimitEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageCommitChargePeakEdit, hDlg, 0, nYDifference); AdjustControlPosition(hCommitChargePeakEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageKernelMemoryTotalEdit, hDlg, 0, nYDifference); AdjustControlPosition(hKernelMemoryTotalEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageKernelMemoryPagedEdit, hDlg, 0, nYDifference); AdjustControlPosition(hKernelMemoryPagedEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageKernelMemoryNonPagedEdit, hDlg, 0, nYDifference); AdjustControlPosition(hKernelMemoryNonPagedEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePagePhysicalMemoryTotalEdit, hDlg, 0, nYDifference); AdjustControlPosition(hPhysicalMemoryTotalEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, 0, nYDifference); AdjustControlPosition(hPhysicalMemoryAvailableEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference); AdjustControlPosition(hPhysicalMemorySystemCacheEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageTotalsHandleCountEdit, hDlg, 0, nYDifference); AdjustControlPosition(hTotalsHandleCountEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageTotalsProcessCountEdit, hDlg, 0, nYDifference); AdjustControlPosition(hTotalsProcessCountEdit, hDlg, 0, nYDifference);
AdjustControlPosition(hPerformancePageTotalsThreadCountEdit, hDlg, 0, nYDifference); AdjustControlPosition(hTotalsThreadCountEdit, hDlg, 0, nYDifference);
nXDifference += lastX; nXDifference += lastX;
nYDifference += lastY; nYDifference += lastY;
lastX = lastY = 0; lastX = lastY = 0;
if (nXDifference % 2) { if (nXDifference % 2)
if (nXDifference > 0) { {
if (nXDifference > 0)
{
nXDifference--; nXDifference--;
lastX++; lastX++;
} else { }
else
{
nXDifference++; nXDifference++;
lastX--; lastX--;
} }
} }
if (nYDifference % 2) { if (nYDifference % 2)
if (nYDifference > 0) { {
if (nYDifference > 0)
{
nYDifference--; nYDifference--;
lastY++; lastY++;
} else { }
else
{
nYDifference++; nYDifference++;
lastY--; lastY--;
} }
} }
AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference, 1); AdjustFrameSize(hCpuUsageFrame, hDlg, nXDifference, nYDifference, 1);
AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference, 2); AdjustFrameSize(hMemUsageFrame, hDlg, nXDifference, nYDifference, 2);
AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3); AdjustFrameSize(hCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference, 3);
AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4); AdjustFrameSize(hMemUsageHistoryFrame, hDlg, nXDifference, nYDifference, 4);
AdjustFrameSize(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference, 1); AdjustFrameSize(hCpuUsageGraph, hDlg, nXDifference, nYDifference, 1);
AdjustFrameSize(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference, 2); AdjustFrameSize(hMemUsageGraph, hDlg, nXDifference, nYDifference, 2);
AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3); AdjustFrameSize(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference, 3);
AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4); AdjustFrameSize(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference, 4);
break; break;
} }
}
return 0; return 0;
} }
void RefreshPerformancePage(void) void RefreshPerformancePage(void)
{ {
#ifdef RUN_PERF_PAGE #ifdef RUN_PERF_PAGE
/* Signal the event so that our refresh thread */ /* Signal the event so that our refresh thread
/* will wake up and refresh the performance page */ * will wake up and refresh the performance page */
PostThreadMessage(dwPerformanceThread, WM_TIMER, 0, 0); PostThreadMessage(dwPerformanceThread, WM_TIMER, 0, 0);
#endif #endif
} }
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
{ {
ULONGLONG CommitChargeTotal; ULONGLONG CommitChargeTotal;
ULONGLONG CommitChargeLimit; ULONGLONG CommitChargeLimit;
@ -327,9 +322,9 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
WCHAR Text[260]; WCHAR Text[260];
WCHAR szMemUsage[256], szCpuUsage[256], szProcesses[256]; WCHAR szMemUsage[256], szCpuUsage[256], szProcesses[256];
LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256); LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, ARRAYSIZE(szCpuUsage));
LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, 256); LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, ARRAYSIZE(szMemUsage));
LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256); LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, ARRAYSIZE(szProcesses));
while (1) while (1)
{ {
@ -352,19 +347,19 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
CommitChargeLimit = PerfDataGetCommitChargeLimitK(); CommitChargeLimit = PerfDataGetCommitChargeLimitK();
CommitChargePeak = PerfDataGetCommitChargePeakK(); CommitChargePeak = PerfDataGetCommitChargePeakK();
_ultow(CommitChargeTotal, Text, 10); _ultow(CommitChargeTotal, Text, 10);
SetWindowTextW(hPerformancePageCommitChargeTotalEdit, Text); SetWindowTextW(hCommitChargeTotalEdit, Text);
_ultow(CommitChargeLimit, Text, 10); _ultow(CommitChargeLimit, Text, 10);
SetWindowTextW(hPerformancePageCommitChargeLimitEdit, Text); SetWindowTextW(hCommitChargeLimitEdit, Text);
_ultow(CommitChargePeak, Text, 10); _ultow(CommitChargePeak, Text, 10);
SetWindowTextW(hPerformancePageCommitChargePeakEdit, Text); SetWindowTextW(hCommitChargePeakEdit, Text);
StrFormatByteSizeW(CommitChargeTotal * 1024, StrFormatByteSizeW(CommitChargeTotal * 1024,
szChargeTotalFormat, szChargeTotalFormat,
_countof(szChargeTotalFormat)); ARRAYSIZE(szChargeTotalFormat));
StrFormatByteSizeW(CommitChargeLimit * 1024, StrFormatByteSizeW(CommitChargeLimit * 1024,
szChargeLimitFormat, szChargeLimitFormat,
_countof(szChargeLimitFormat)); ARRAYSIZE(szChargeLimitFormat));
if (!bInMenuLoop) if (!bInMenuLoop)
{ {
@ -380,11 +375,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
KernelMemoryPaged = PerfDataGetKernelMemoryPagedK(); KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK(); KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
_ultow(KernelMemoryTotal, Text, 10); _ultow(KernelMemoryTotal, Text, 10);
SetWindowTextW(hPerformancePageKernelMemoryTotalEdit, Text); SetWindowTextW(hKernelMemoryTotalEdit, Text);
_ultow(KernelMemoryPaged, Text, 10); _ultow(KernelMemoryPaged, Text, 10);
SetWindowTextW(hPerformancePageKernelMemoryPagedEdit, Text); SetWindowTextW(hKernelMemoryPagedEdit, Text);
_ultow(KernelMemoryNonPaged, Text, 10); _ultow(KernelMemoryNonPaged, Text, 10);
SetWindowTextW(hPerformancePageKernelMemoryNonPagedEdit, Text); SetWindowTextW(hKernelMemoryNonPagedEdit, Text);
/* /*
* Update the physical memory info * Update the physical memory info
@ -393,11 +388,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK(); PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK(); PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
_ultow(PhysicalMemoryTotal, Text, 10); _ultow(PhysicalMemoryTotal, Text, 10);
SetWindowTextW(hPerformancePagePhysicalMemoryTotalEdit, Text); SetWindowTextW(hPhysicalMemoryTotalEdit, Text);
_ultow(PhysicalMemoryAvailable, Text, 10); _ultow(PhysicalMemoryAvailable, Text, 10);
SetWindowTextW(hPerformancePagePhysicalMemoryAvailableEdit, Text); SetWindowTextW(hPhysicalMemoryAvailableEdit, Text);
_ultow(PhysicalMemorySystemCache, Text, 10); _ultow(PhysicalMemorySystemCache, Text, 10);
SetWindowTextW(hPerformancePagePhysicalMemorySystemCacheEdit, Text); SetWindowTextW(hPhysicalMemorySystemCacheEdit, Text);
/* /*
* Update the totals info * Update the totals info
@ -406,11 +401,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
TotalThreads = PerfDataGetTotalThreadCount(); TotalThreads = PerfDataGetTotalThreadCount();
TotalProcesses = PerfDataGetProcessCount(); TotalProcesses = PerfDataGetProcessCount();
_ultow(TotalHandles, Text, 10); _ultow(TotalHandles, Text, 10);
SetWindowTextW(hPerformancePageTotalsHandleCountEdit, Text); SetWindowTextW(hTotalsHandleCountEdit, Text);
_ultow(TotalThreads, Text, 10); _ultow(TotalThreads, Text, 10);
SetWindowTextW(hPerformancePageTotalsThreadCountEdit, Text); SetWindowTextW(hTotalsThreadCountEdit, Text);
_ultow(TotalProcesses, Text, 10); _ultow(TotalProcesses, Text, 10);
SetWindowTextW(hPerformancePageTotalsProcessCountEdit, Text); SetWindowTextW(hTotalsProcessCountEdit, Text);
if (!bInMenuLoop) if (!bInMenuLoop)
{ {
wsprintfW(Text, szProcesses, TotalProcesses); wsprintfW(Text, szProcesses, TotalProcesses);
@ -420,8 +415,8 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
/* /*
* Redraw the graphs * Redraw the graphs
*/ */
InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE); InvalidateRect(hCpuUsageGraph, NULL, FALSE);
InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE); InvalidateRect(hMemUsageGraph, NULL, FALSE);
/* /*
* Get the CPU usage * Get the CPU usage
@ -515,4 +510,3 @@ void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE; TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND); CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
} }

View file

@ -13,6 +13,7 @@ extern "C" {
extern HWND hPerformancePage; /* Performance Property Page */ extern HWND hPerformancePage; /* Performance Property Page */
INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void RefreshPerformancePage(void); void RefreshPerformancePage(void);
void PerformancePage_OnViewShowKernelTimes(void); void PerformancePage_OnViewShowKernelTimes(void);
void PerformancePage_OnViewCPUHistoryOneGraphAll(void); void PerformancePage_OnViewCPUHistoryOneGraphAll(void);

View file

@ -27,8 +27,8 @@ HWND hProcessPage; /* Process List Property Page */
HWND hProcessPageListCtrl; /* Process ListCtrl Window */ HWND hProcessPageListCtrl; /* Process ListCtrl Window */
HWND hProcessPageHeaderCtrl; /* Process Header Control */ HWND hProcessPageHeaderCtrl; /* Process Header Control */
HWND hProcessPageEndProcessButton; /* Process End Process button */ static HWND hProcessPageEndProcessButton; /* Process End Process button */
HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */ static HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */
BOOL bProcessPageSelectionMade = FALSE; /* Is item in ListCtrl selected */ BOOL bProcessPageSelectionMade = FALSE; /* Is item in ListCtrl selected */
static int nProcessPageWidth; static int nProcessPageWidth;

View file

@ -12,8 +12,6 @@
extern HWND hProcessPage; /* Process List Property Page */ extern HWND hProcessPage; /* Process List Property Page */
extern HWND hProcessPageListCtrl; /* Process ListCtrl Window */ extern HWND hProcessPageListCtrl; /* Process ListCtrl Window */
extern HWND hProcessPageHeaderCtrl; /* Process Header Control */ extern HWND hProcessPageHeaderCtrl; /* Process Header Control */
extern HWND hProcessPageEndProcessButton; /* Process End Process button */
extern HWND hProcessPageShowAllProcessesButton; /* Process Show All Processes checkbox */
INT_PTR CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void RefreshProcessPage(void); void RefreshProcessPage(void);

View file

@ -22,16 +22,12 @@ HICON TrayIcon_GetProcessorUsageIcon(void)
HBRUSH hBitmapBrush = NULL; HBRUSH hBitmapBrush = NULL;
RECT rc; RECT rc;
/* /* Get a handle to the screen DC */
* Get a handle to the screen DC
*/
hScreenDC = GetDC(NULL); hScreenDC = GetDC(NULL);
if (!hScreenDC) if (!hScreenDC)
goto done; goto done;
/* /* Create our own DC from it */
* Create our own DC from it
*/
hDC = CreateCompatibleDC(hScreenDC); hDC = CreateCompatibleDC(hScreenDC);
if (!hDC) if (!hDC)
goto done; goto done;
@ -52,7 +48,7 @@ HICON TrayIcon_GetProcessorUsageIcon(void)
* Select the bitmap into our device context * Select the bitmap into our device context
* so we can draw on it. * so we can draw on it.
*/ */
hOldBitmap = (HBITMAP) SelectObject(hDC, hBitmap); hOldBitmap = SelectObject(hDC, hBitmap);
/* /*
* Get the cpu usage * Get the cpu usage
@ -71,9 +67,7 @@ HICON TrayIcon_GetProcessorUsageIcon(void)
rc.right = 13; rc.right = 13;
rc.bottom = 13; rc.bottom = 13;
/* /* Now draw the cpu usage */
* Now draw the cpu usage
*/
if (nLinesToDraw) if (nLinesToDraw)
FillRect(hDC, &rc, hBitmapBrush); FillRect(hDC, &rc, hBitmapBrush);
@ -105,9 +99,7 @@ done:
if (hBitmapMask) if (hBitmapMask)
DeleteObject(hBitmapMask); DeleteObject(hBitmapMask);
/* /* Return the newly created tray icon (if successful) */
* Return the newly created tray icon (if successful)
*/
return hTrayIcon; return hTrayIcon;
} }