taskmgr: Avoid forward declarations and make functions static.

This commit is contained in:
Francois Gouget 2006-03-21 18:32:40 +01:00 committed by Alexandre Julliard
parent 0c02e4671e
commit b72013d6d1
7 changed files with 596 additions and 616 deletions

View File

@ -31,15 +31,7 @@
#include "taskmgr.h"
INT_PTR CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void OnAbout(void)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, AboutDialogWndProc);
}
INT_PTR CALLBACK
AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
static INT_PTR CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hLicenseEditWnd;
TCHAR strLicense[0x1000];
@ -69,3 +61,8 @@ AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
void OnAbout(void)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, AboutDialogWndProc);
}

View File

@ -35,41 +35,7 @@
HANDLE hProcessAffinityHandle;
INT_PTR CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void ProcessPage_OnSetAffinity(void)
{
LV_ITEM lvitem;
ULONG Index;
DWORD dwProcessId;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) {
memset(&lvitem, 0, sizeof(LV_ITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcessAffinityHandle) {
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
return;
}
DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, AffinityDialogWndProc);
if (hProcessAffinityHandle) {
CloseHandle(hProcessAffinityHandle);
hProcessAffinityHandle = NULL;
}
}
INT_PTR CALLBACK
static INT_PTR CALLBACK
AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
DWORD dwProcessAffinityMask = 0;
@ -343,3 +309,35 @@ AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
void ProcessPage_OnSetAffinity(void)
{
LV_ITEM lvitem;
ULONG Index;
DWORD dwProcessId;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) {
memset(&lvitem, 0, sizeof(LV_ITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcessAffinityHandle) {
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
return;
}
DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, AffinityDialogWndProc);
if (hProcessAffinityHandle) {
CloseHandle(hProcessAffinityHandle);
hProcessAffinityHandle = NULL;
}
}

View File

@ -34,8 +34,29 @@
UINT ColumnDataHints[25];
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem);
INT_PTR CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
static int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
{
LVCOLUMN column;
column.mask = LVCF_TEXT|LVCF_FMT;
column.pszText = (LPTSTR)lpszColumnHeading;
column.fmt = nFormat;
if (nWidth != -1)
{
column.mask |= LVCF_WIDTH;
column.cx = nWidth;
}
if (nSubItem != -1)
{
column.mask |= LVCF_SUBITEM;
column.iSubItem = nSubItem;
}
return ListView_InsertColumn(hProcessPageListCtrl, nCol, &column);
}
void AddColumns(void)
{
@ -98,27 +119,110 @@ void AddColumns(void)
UpdateColumnDataHints();
}
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
static INT_PTR CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
LVCOLUMN column;
column.mask = LVCF_TEXT|LVCF_FMT;
column.pszText = (LPTSTR)lpszColumnHeading;
column.fmt = nFormat;
if (nWidth != -1)
switch (message)
{
column.mask |= LVCF_WIDTH;
column.cx = nWidth;
case WM_INITDIALOG:
if (TaskManagerSettings.Column_ImageName)
SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PID)
SendMessage(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_UserName)
SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_SessionID)
SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_CPUUsage)
SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_CPUTime)
SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_MemoryUsage)
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PeakMemoryUsage)
SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_MemoryUsageDelta)
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PageFaults)
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PageFaultsDelta)
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_VirtualMemorySize)
SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PagedPool)
SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_NonPagedPool)
SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_BasePriority)
SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_HandleCount)
SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_ThreadCount)
SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_USERObjects)
SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_GDIObjects)
SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOReads)
SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOWrites)
SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOOther)
SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOReadBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOWriteBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOOtherBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if (LOWORD(wParam) == IDOK)
{
TaskManagerSettings.Column_ImageName = SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PID = SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_UserName = SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_SessionID = SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_CPUUsage = SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_CPUTime = SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_MemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PeakMemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_MemoryUsageDelta = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PageFaults = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PageFaultsDelta = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_VirtualMemorySize = SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PagedPool = SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_NonPagedPool = SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_BasePriority = SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_HandleCount = SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_ThreadCount = SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_USERObjects = SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_GDIObjects = SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOReads = SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOWrites = SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOOther = SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOReadBytes = SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOWriteBytes = SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
if (nSubItem != -1)
{
column.mask |= LVCF_SUBITEM;
column.iSubItem = nSubItem;
}
return ListView_InsertColumn(hProcessPageListCtrl, nCol, &column);
return 0;
}
void SaveColumnSettings(void)
@ -369,113 +473,6 @@ void ProcessPage_OnViewSelectColumns(void)
}
}
INT_PTR CALLBACK
ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
if (TaskManagerSettings.Column_ImageName)
SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PID)
SendMessage(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_UserName)
SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_SessionID)
SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_CPUUsage)
SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_CPUTime)
SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_MemoryUsage)
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PeakMemoryUsage)
SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_MemoryUsageDelta)
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PageFaults)
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PageFaultsDelta)
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_VirtualMemorySize)
SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PagedPool)
SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_NonPagedPool)
SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_BasePriority)
SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_HandleCount)
SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_ThreadCount)
SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_USERObjects)
SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_GDIObjects)
SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOReads)
SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOWrites)
SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOOther)
SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOReadBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOWriteBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOOtherBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if (LOWORD(wParam) == IDOK)
{
TaskManagerSettings.Column_ImageName = SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PID = SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_UserName = SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_SessionID = SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_CPUUsage = SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_CPUTime = SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_MemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PeakMemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_MemoryUsageDelta = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PageFaults = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PageFaultsDelta = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_VirtualMemorySize = SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PagedPool = SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_NonPagedPool = SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_BasePriority = SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_HandleCount = SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_ThreadCount = SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_USERObjects = SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_GDIObjects = SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOReads = SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOWrites = SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOOther = SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOReadBytes = SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOWriteBytes = SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return 0;
}
void UpdateColumnDataHints(void)
{
HDITEM hditem;

View File

@ -40,110 +40,7 @@
WNDPROC OldGraphWndProc;
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd);
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd);
INT_PTR CALLBACK
Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
LONG WindowId;
switch (message)
{
case WM_ERASEBKGND:
return TRUE;
/*
* Filter out mouse & keyboard messages
*/
/* case WM_APPCOMMAND: */
case WM_CAPTURECHANGED:
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MOUSEACTIVATE:
case WM_MOUSEHOVER:
case WM_MOUSELEAVE:
case WM_MOUSEMOVE:
/* case WM_MOUSEWHEEL: */
case WM_NCHITTEST:
case WM_NCLBUTTONDBLCLK:
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP:
case WM_NCMBUTTONDBLCLK:
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP:
/* case WM_NCMOUSEHOVER: */
/* case WM_NCMOUSELEAVE: */
case WM_NCMOUSEMOVE:
case WM_NCRBUTTONDBLCLK:
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
/* case WM_NCXBUTTONDBLCLK: */
/* case WM_NCXBUTTONDOWN: */
/* case WM_NCXBUTTONUP: */
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
/* case WM_XBUTTONDBLCLK: */
/* case WM_XBUTTONDOWN: */
/* case WM_XBUTTONUP: */
case WM_ACTIVATE:
case WM_CHAR:
case WM_DEADCHAR:
case WM_GETHOTKEY:
case WM_HOTKEY:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_KILLFOCUS:
case WM_SETFOCUS:
case WM_SETHOTKEY:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_NCCALCSIZE:
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
WindowId = GetWindowLongPtr(hWnd, GWLP_ID);
switch (WindowId)
{
case IDC_CPU_USAGE_GRAPH:
Graph_DrawCpuUsageGraph(hdc, hWnd);
break;
case IDC_MEM_USAGE_GRAPH:
Graph_DrawMemUsageGraph(hdc, hWnd);
break;
case IDC_MEM_USAGE_HISTORY_GRAPH:
Graph_DrawMemUsageHistoryGraph(hdc, hWnd);
break;
}
EndPaint(hWnd, &ps);
return 0;
}
/*
* We pass on all non-handled messages
*/
return CallWindowProc((WNDPROC)OldGraphWndProc, hWnd, message, wParam, lParam);
}
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
{
RECT rcClient;
RECT rcBarLeft;
@ -323,7 +220,7 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
}
}
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
{
RECT rcClient;
RECT rcBarLeft;
@ -418,7 +315,7 @@ void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
}
}
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)
static void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)
{
RECT rcClient;
ULONGLONG CommitChargeLimit;
@ -473,3 +370,102 @@ void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)
{
}
}
INT_PTR CALLBACK
Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
LONG WindowId;
switch (message)
{
case WM_ERASEBKGND:
return TRUE;
/*
* Filter out mouse & keyboard messages
*/
/* case WM_APPCOMMAND: */
case WM_CAPTURECHANGED:
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MOUSEACTIVATE:
case WM_MOUSEHOVER:
case WM_MOUSELEAVE:
case WM_MOUSEMOVE:
/* case WM_MOUSEWHEEL: */
case WM_NCHITTEST:
case WM_NCLBUTTONDBLCLK:
case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP:
case WM_NCMBUTTONDBLCLK:
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP:
/* case WM_NCMOUSEHOVER: */
/* case WM_NCMOUSELEAVE: */
case WM_NCMOUSEMOVE:
case WM_NCRBUTTONDBLCLK:
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
/* case WM_NCXBUTTONDBLCLK: */
/* case WM_NCXBUTTONDOWN: */
/* case WM_NCXBUTTONUP: */
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
/* case WM_XBUTTONDBLCLK: */
/* case WM_XBUTTONDOWN: */
/* case WM_XBUTTONUP: */
case WM_ACTIVATE:
case WM_CHAR:
case WM_DEADCHAR:
case WM_GETHOTKEY:
case WM_HOTKEY:
case WM_KEYDOWN:
case WM_KEYUP:
case WM_KILLFOCUS:
case WM_SETFOCUS:
case WM_SETHOTKEY:
case WM_SYSCHAR:
case WM_SYSDEADCHAR:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
case WM_NCCALCSIZE:
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
WindowId = GetWindowLongPtr(hWnd, GWLP_ID);
switch (WindowId)
{
case IDC_CPU_USAGE_GRAPH:
Graph_DrawCpuUsageGraph(hdc, hWnd);
break;
case IDC_MEM_USAGE_GRAPH:
Graph_DrawMemUsageGraph(hdc, hWnd);
break;
case IDC_MEM_USAGE_HISTORY_GRAPH:
Graph_DrawMemUsageHistoryGraph(hdc, hWnd);
break;
}
EndPaint(hWnd, &ps);
return 0;
}
/*
* We pass on all non-handled messages
*/
return CallWindowProc((WNDPROC)OldGraphWndProc, hWnd, message, wParam, lParam);
}

View File

@ -67,7 +67,6 @@ HWND hPerformancePageTotalsThreadCountEdit; /* Total Threads Edit Control */
static int nPerformancePageWidth;
static int nPerformancePageHeight;
static HANDLE hPerformancePageEvent = NULL; /* When this event becomes signaled then we refresh the performance page */
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter);
static void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
{
@ -114,7 +113,154 @@ static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDiffe
{
AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
}
void RefreshPerformancePage(void)
{
/* Signal the event so that our refresh thread */
/* will wake up and refresh the performance page */
SetEvent(hPerformancePageEvent);
}
static DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
{
ULONG CommitChargeTotal;
ULONG CommitChargeLimit;
ULONG CommitChargePeak;
ULONG KernelMemoryTotal;
ULONG KernelMemoryPaged;
ULONG KernelMemoryNonPaged;
ULONG PhysicalMemoryTotal;
ULONG PhysicalMemoryAvailable;
ULONG PhysicalMemorySystemCache;
ULONG TotalHandles;
ULONG TotalThreads;
ULONG TotalProcesses;
TCHAR Text[260];
/* Create the event */
hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
/* If we couldn't create the event then exit the thread */
if (!hPerformancePageEvent)
return 0;
while (1)
{
DWORD dwWaitVal;
/* Wait on the event */
dwWaitVal = WaitForSingleObject(hPerformancePageEvent, 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)
return 0;
if (dwWaitVal == WAIT_OBJECT_0)
{
ULONG CpuUsage;
ULONG CpuKernelUsage;
int nBarsUsed1;
int nBarsUsed2;
/* Reset our event */
ResetEvent(hPerformancePageEvent);
/*
* Update the commit charge info
*/
CommitChargeTotal = PerfDataGetCommitChargeTotalK();
CommitChargeLimit = PerfDataGetCommitChargeLimitK();
CommitChargePeak = PerfDataGetCommitChargePeakK();
_ultoa(CommitChargeTotal, Text, 10);
SetWindowText(hPerformancePageCommitChargeTotalEdit, Text);
_ultoa(CommitChargeLimit, Text, 10);
SetWindowText(hPerformancePageCommitChargeLimitEdit, Text);
_ultoa(CommitChargePeak, Text, 10);
SetWindowText(hPerformancePageCommitChargePeakEdit, Text);
wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit);
SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
/*
* Update the kernel memory info
*/
KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
_ultoa(KernelMemoryTotal, Text, 10);
SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text);
_ultoa(KernelMemoryPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text);
_ultoa(KernelMemoryNonPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
/*
* Update the physical memory info
*/
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
_ultoa(PhysicalMemoryTotal, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text);
_ultoa(PhysicalMemoryAvailable, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text);
_ultoa(PhysicalMemorySystemCache, Text, 10);
SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
/*
* Update the totals info
*/
TotalHandles = PerfDataGetSystemHandleCount();
TotalThreads = PerfDataGetTotalThreadCount();
TotalProcesses = PerfDataGetProcessCount();
_ultoa(TotalHandles, Text, 10);
SetWindowText(hPerformancePageTotalsHandleCountEdit, Text);
_ultoa(TotalThreads, Text, 10);
SetWindowText(hPerformancePageTotalsThreadCountEdit, Text);
_ultoa(TotalProcesses, Text, 10);
SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
/*
* Redraw the graphs
*/
InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
/*
* Get the CPU usage
*/
CpuUsage = PerfDataGetProcessorUsage();
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
if (CpuUsage < 0 ) CpuUsage = 0;
if (CpuUsage > 100) CpuUsage = 100;
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
/*
* Get the memory usage
*/
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
/* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
}
}
return 0;
}
INT_PTR CALLBACK
PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@ -305,154 +451,6 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return 0;
}
void RefreshPerformancePage(void)
{
/* Signal the event so that our refresh thread */
/* will wake up and refresh the performance page */
SetEvent(hPerformancePageEvent);
}
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
{
ULONG CommitChargeTotal;
ULONG CommitChargeLimit;
ULONG CommitChargePeak;
ULONG KernelMemoryTotal;
ULONG KernelMemoryPaged;
ULONG KernelMemoryNonPaged;
ULONG PhysicalMemoryTotal;
ULONG PhysicalMemoryAvailable;
ULONG PhysicalMemorySystemCache;
ULONG TotalHandles;
ULONG TotalThreads;
ULONG TotalProcesses;
TCHAR Text[260];
/* Create the event */
hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
/* If we couldn't create the event then exit the thread */
if (!hPerformancePageEvent)
return 0;
while (1)
{
DWORD dwWaitVal;
/* Wait on the event */
dwWaitVal = WaitForSingleObject(hPerformancePageEvent, 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)
return 0;
if (dwWaitVal == WAIT_OBJECT_0)
{
ULONG CpuUsage;
ULONG CpuKernelUsage;
int nBarsUsed1;
int nBarsUsed2;
/* Reset our event */
ResetEvent(hPerformancePageEvent);
/*
* Update the commit charge info
*/
CommitChargeTotal = PerfDataGetCommitChargeTotalK();
CommitChargeLimit = PerfDataGetCommitChargeLimitK();
CommitChargePeak = PerfDataGetCommitChargePeakK();
_ultoa(CommitChargeTotal, Text, 10);
SetWindowText(hPerformancePageCommitChargeTotalEdit, Text);
_ultoa(CommitChargeLimit, Text, 10);
SetWindowText(hPerformancePageCommitChargeLimitEdit, Text);
_ultoa(CommitChargePeak, Text, 10);
SetWindowText(hPerformancePageCommitChargePeakEdit, Text);
wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit);
SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
/*
* Update the kernel memory info
*/
KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
_ultoa(KernelMemoryTotal, Text, 10);
SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text);
_ultoa(KernelMemoryPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text);
_ultoa(KernelMemoryNonPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
/*
* Update the physical memory info
*/
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
_ultoa(PhysicalMemoryTotal, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text);
_ultoa(PhysicalMemoryAvailable, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text);
_ultoa(PhysicalMemorySystemCache, Text, 10);
SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
/*
* Update the totals info
*/
TotalHandles = PerfDataGetSystemHandleCount();
TotalThreads = PerfDataGetTotalThreadCount();
TotalProcesses = PerfDataGetProcessCount();
_ultoa(TotalHandles, Text, 10);
SetWindowText(hPerformancePageTotalsHandleCountEdit, Text);
_ultoa(TotalThreads, Text, 10);
SetWindowText(hPerformancePageTotalsThreadCountEdit, Text);
_ultoa(TotalProcesses, Text, 10);
SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
/*
* Redraw the graphs
*/
InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
/*
* Get the CPU usage
*/
CpuUsage = PerfDataGetProcessorUsage();
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
if (CpuUsage < 0 ) CpuUsage = 0;
if (CpuUsage > 100) CpuUsage = 100;
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
/*
* Get the memory usage
*/
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
/* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
}
}
return 0;
}
void PerformancePage_OnViewShowKernelTimes(void)
{
HMENU hMenu;

View File

@ -34,8 +34,6 @@
#include "perfdata.h"
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
WNDPROC OldProcessListWndProc;

View File

@ -47,120 +47,100 @@ static int nProcessPageHeight;
static HANDLE hProcessPageEvent = NULL; /* When this event becomes signaled then we refresh the process list */
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam);
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount);
void ProcessPageShowContextMenu(DWORD dwProcessId);
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter);
INT_PTR CALLBACK
ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
static void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount)
{
RECT rc;
int nXDifference;
int nYDifference;
int cx, cy;
TCHAR temp[260];
UINT i, j, k;
switch (message) {
case WM_INITDIALOG:
/*
* Save the width and height
*/
GetClientRect(hDlg, &rc);
nProcessPageWidth = rc.right;
nProcessPageHeight = rc.bottom;
for (i=0,j=0; i<(_tcslen(strNumber) % 3); i++, j++)
temp[j] = strNumber[i];
for (k=0; i<_tcslen(strNumber); i++,j++,k++) {
if ((k % 3 == 0) && (j > 0))
temp[j++] = _T(',');
temp[j] = strNumber[i];
}
temp[j] = _T('\0');
_tcsncpy(strNumber, temp, nMaxCount);
}
/* Update window position */
SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
static void ProcessPageShowContextMenu(DWORD dwProcessId)
{
HMENU hMenu;
HMENU hSubMenu;
HMENU hPriorityMenu;
POINT pt;
SYSTEM_INFO si;
HANDLE hProcess;
DWORD dwProcessPriorityClass;
TCHAR strDebugger[260];
DWORD dwDebuggerSize;
HKEY hKey;
UINT Idx;
/*
* Get handles to the controls
*/
hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);
memset(&si, 0, sizeof(SYSTEM_INFO));
/*
* Set the font, title, and extended window styles for the list control
*/
SendMessage(hProcessPageListCtrl, WM_SETFONT, SendMessage(hProcessPage, WM_GETFONT, 0, 0), TRUE);
SetWindowText(hProcessPageListCtrl, _T("Processes"));
SendMessage(hProcessPageListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
GetCursorPos(&pt);
GetSystemInfo(&si);
AddColumns();
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT));
hSubMenu = GetSubMenu(hMenu, 0);
hPriorityMenu = GetSubMenu(hSubMenu, 4);
/*
* Subclass the process list control so we can intercept WM_ERASEBKGND
*/
OldProcessListWndProc = (WNDPROC)SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
dwProcessPriorityClass = GetPriorityClass(hProcess);
CloseHandle(hProcess);
/* Start our refresh thread */
CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
return TRUE;
case WM_DESTROY:
/* Close the event handle, this will make the */
/* refresh thread exit when the wait fails */
CloseHandle(hProcessPageEvent);
SaveColumnSettings();
if (si.dwNumberOfProcessors < 2)
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
if (!AreDebugChannelsSupported())
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND);
switch (dwProcessPriorityClass) {
case REALTIME_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
break;
case WM_COMMAND:
/* Handle the button clicks */
switch (LOWORD(wParam))
{
case IDC_ENDPROCESS:
ProcessPage_OnEndProcess();
}
case HIGH_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
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)(&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)(&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);
case ABOVE_NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
break;
case WM_NOTIFY:
ProcessPageOnNotify(wParam, lParam);
case NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
break;
case BELOW_NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
break;
case IDLE_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
break;
}
return 0;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
{
for (Idx=0; Idx<_tcslen(strDebugger); Idx++)
strDebugger[Idx] = toupper(strDebugger[Idx]);
if (_tcsstr(strDebugger, _T("DRWTSN32")))
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
else
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
RegCloseKey(hKey);
} else {
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
DestroyMenu(hMenu);
}
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
static void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
{
int idctrl;
LPNMHDR pnmh;
@ -396,98 +376,6 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
}
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount)
{
TCHAR temp[260];
UINT i, j, k;
for (i=0,j=0; i<(_tcslen(strNumber) % 3); i++, j++)
temp[j] = strNumber[i];
for (k=0; i<_tcslen(strNumber); i++,j++,k++) {
if ((k % 3 == 0) && (j > 0))
temp[j++] = _T(',');
temp[j] = strNumber[i];
}
temp[j] = _T('\0');
_tcsncpy(strNumber, temp, nMaxCount);
}
void ProcessPageShowContextMenu(DWORD dwProcessId)
{
HMENU hMenu;
HMENU hSubMenu;
HMENU hPriorityMenu;
POINT pt;
SYSTEM_INFO si;
HANDLE hProcess;
DWORD dwProcessPriorityClass;
TCHAR strDebugger[260];
DWORD dwDebuggerSize;
HKEY hKey;
UINT Idx;
memset(&si, 0, sizeof(SYSTEM_INFO));
GetCursorPos(&pt);
GetSystemInfo(&si);
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT));
hSubMenu = GetSubMenu(hMenu, 0);
hPriorityMenu = GetSubMenu(hSubMenu, 4);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
dwProcessPriorityClass = GetPriorityClass(hProcess);
CloseHandle(hProcess);
if (si.dwNumberOfProcessors < 2)
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
if (!AreDebugChannelsSupported())
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND);
switch (dwProcessPriorityClass) {
case REALTIME_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
break;
case HIGH_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
break;
case ABOVE_NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
break;
case NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
break;
case BELOW_NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
break;
case IDLE_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
break;
}
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
{
for (Idx=0; Idx<_tcslen(strDebugger); Idx++)
strDebugger[Idx] = toupper(strDebugger[Idx]);
if (_tcsstr(strDebugger, _T("DRWTSN32")))
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
else
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
RegCloseKey(hKey);
} else {
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
}
TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
DestroyMenu(hMenu);
}
void RefreshProcessPage(void)
{
/* Signal the event so that our refresh thread */
@ -495,7 +383,7 @@ void RefreshProcessPage(void)
SetEvent(hProcessPageEvent);
}
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
static DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
{
ULONG OldProcessorUsage = 0;
ULONG OldProcessCount = 0;
@ -544,3 +432,111 @@ DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
}
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 font, title, and extended window styles for the list control
*/
SendMessage(hProcessPageListCtrl, WM_SETFONT, SendMessage(hProcessPage, WM_GETFONT, 0, 0), TRUE);
SetWindowText(hProcessPageListCtrl, _T("Processes"));
SendMessage(hProcessPageListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
AddColumns();
/*
* Subclass the process list control so we can intercept WM_ERASEBKGND
*/
OldProcessListWndProc = (WNDPROC)SetWindowLongPtr(hProcessPageListCtrl, GWLP_WNDPROC, (LONG_PTR)ProcessListWndProc);
/* Start our refresh thread */
CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
return TRUE;
case WM_DESTROY:
/* Close the event handle, this will make the */
/* refresh thread exit when the wait fails */
CloseHandle(hProcessPageEvent);
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)(&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)(&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;
}
return 0;
}