Removed the last of the C++ style comments. Adjusted the coding style a bit.

svn path=/trunk/; revision=7537
This commit is contained in:
Steven Edwards 2004-01-09 23:00:43 +00:00
parent 2c6c5f8a32
commit 7a53ba6050
20 changed files with 3043 additions and 3068 deletions

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -28,47 +28,44 @@
#include <memory.h> #include <memory.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "about.h" #include "about.h"
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void OnAbout(void) void OnAbout(void)
{ {
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, (DLGPROC)AboutDialogWndProc);
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, (DLGPROC)AboutDialogWndProc);
} }
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
HWND hLicenseEditWnd; HWND hLicenseEditWnd;
TCHAR strLicense[0x1000]; TCHAR strLicense[0x1000];
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT); hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
LoadString(hInst, IDS_LICENSE, strLicense, 0x1000); LoadString(hInst, IDS_LICENSE, strLicense, 0x1000);
SetWindowText(hLicenseEditWnd, strLicense); SetWindowText(hLicenseEditWnd, strLicense);
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{ {
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return TRUE; return TRUE;
} }
break; break;
} }
return 0; return 0;
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,318 +29,318 @@
#include <tchar.h> #include <tchar.h>
#include <winnt.h> #include <winnt.h>
#include <stdio.h> #include <stdio.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "procpage.h" #include "procpage.h"
#include "affinity.h" #include "affinity.h"
#include "perfdata.h" #include "perfdata.h"
HANDLE hProcessAffinityHandle; HANDLE hProcessAffinityHandle;
LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void ProcessPage_OnSetAffinity(void) void ProcessPage_OnSetAffinity(void)
{ {
LV_ITEM lvitem; LV_ITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) { for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) {
memset(&lvitem, 0, sizeof(LV_ITEM)); memset(&lvitem, 0, sizeof(LV_ITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcessAffinityHandle) { if (!hProcessAffinityHandle) {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
return; return;
} }
DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, (DLGPROC)AffinityDialogWndProc); DialogBox(hInst, MAKEINTRESOURCE(IDD_AFFINITY_DIALOG), hMainWnd, (DLGPROC)AffinityDialogWndProc);
if (hProcessAffinityHandle) { if (hProcessAffinityHandle) {
CloseHandle(hProcessAffinityHandle); CloseHandle(hProcessAffinityHandle);
hProcessAffinityHandle = NULL; hProcessAffinityHandle = NULL;
} }
} }
LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
DWORD dwProcessAffinityMask = 0; DWORD dwProcessAffinityMask = 0;
DWORD dwSystemAffinityMask = 0; DWORD dwSystemAffinityMask = 0;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
switch (message) { switch (message) {
case WM_INITDIALOG: case WM_INITDIALOG:
/* /*
* Get the current affinity mask for the process and * Get the current affinity mask for the process and
* the number of CPUs present in the system * the number of CPUs present in the system
*/ */
if (!GetProcessAffinityMask(hProcessAffinityHandle, &dwProcessAffinityMask, &dwSystemAffinityMask)) { if (!GetProcessAffinityMask(hProcessAffinityHandle, &dwProcessAffinityMask, &dwSystemAffinityMask)) {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
EndDialog(hDlg, 0); EndDialog(hDlg, 0);
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
} }
/* /*
* Enable a checkbox for each processor present in the system * Enable a checkbox for each processor present in the system
*/ */
if (dwSystemAffinityMask & 0x00000001) if (dwSystemAffinityMask & 0x00000001)
EnableWindow(GetDlgItem(hDlg, IDC_CPU0), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU0), TRUE);
if (dwSystemAffinityMask & 0x00000002) if (dwSystemAffinityMask & 0x00000002)
EnableWindow(GetDlgItem(hDlg, IDC_CPU1), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU1), TRUE);
if (dwSystemAffinityMask & 0x00000004) if (dwSystemAffinityMask & 0x00000004)
EnableWindow(GetDlgItem(hDlg, IDC_CPU2), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU2), TRUE);
if (dwSystemAffinityMask & 0x00000008) if (dwSystemAffinityMask & 0x00000008)
EnableWindow(GetDlgItem(hDlg, IDC_CPU3), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU3), TRUE);
if (dwSystemAffinityMask & 0x00000010) if (dwSystemAffinityMask & 0x00000010)
EnableWindow(GetDlgItem(hDlg, IDC_CPU4), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU4), TRUE);
if (dwSystemAffinityMask & 0x00000020) if (dwSystemAffinityMask & 0x00000020)
EnableWindow(GetDlgItem(hDlg, IDC_CPU5), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU5), TRUE);
if (dwSystemAffinityMask & 0x00000040) if (dwSystemAffinityMask & 0x00000040)
EnableWindow(GetDlgItem(hDlg, IDC_CPU6), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU6), TRUE);
if (dwSystemAffinityMask & 0x00000080) if (dwSystemAffinityMask & 0x00000080)
EnableWindow(GetDlgItem(hDlg, IDC_CPU7), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU7), TRUE);
if (dwSystemAffinityMask & 0x00000100) if (dwSystemAffinityMask & 0x00000100)
EnableWindow(GetDlgItem(hDlg, IDC_CPU8), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU8), TRUE);
if (dwSystemAffinityMask & 0x00000200) if (dwSystemAffinityMask & 0x00000200)
EnableWindow(GetDlgItem(hDlg, IDC_CPU9), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU9), TRUE);
if (dwSystemAffinityMask & 0x00000400) if (dwSystemAffinityMask & 0x00000400)
EnableWindow(GetDlgItem(hDlg, IDC_CPU10), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU10), TRUE);
if (dwSystemAffinityMask & 0x00000800) if (dwSystemAffinityMask & 0x00000800)
EnableWindow(GetDlgItem(hDlg, IDC_CPU11), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU11), TRUE);
if (dwSystemAffinityMask & 0x00001000) if (dwSystemAffinityMask & 0x00001000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU12), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU12), TRUE);
if (dwSystemAffinityMask & 0x00002000) if (dwSystemAffinityMask & 0x00002000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU13), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU13), TRUE);
if (dwSystemAffinityMask & 0x00004000) if (dwSystemAffinityMask & 0x00004000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU14), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU14), TRUE);
if (dwSystemAffinityMask & 0x00008000) if (dwSystemAffinityMask & 0x00008000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU15), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU15), TRUE);
if (dwSystemAffinityMask & 0x00010000) if (dwSystemAffinityMask & 0x00010000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU16), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU16), TRUE);
if (dwSystemAffinityMask & 0x00020000) if (dwSystemAffinityMask & 0x00020000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU17), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU17), TRUE);
if (dwSystemAffinityMask & 0x00040000) if (dwSystemAffinityMask & 0x00040000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU18), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU18), TRUE);
if (dwSystemAffinityMask & 0x00080000) if (dwSystemAffinityMask & 0x00080000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU19), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU19), TRUE);
if (dwSystemAffinityMask & 0x00100000) if (dwSystemAffinityMask & 0x00100000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU20), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU20), TRUE);
if (dwSystemAffinityMask & 0x00200000) if (dwSystemAffinityMask & 0x00200000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU21), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU21), TRUE);
if (dwSystemAffinityMask & 0x00400000) if (dwSystemAffinityMask & 0x00400000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU22), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU22), TRUE);
if (dwSystemAffinityMask & 0x00800000) if (dwSystemAffinityMask & 0x00800000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU23), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU23), TRUE);
if (dwSystemAffinityMask & 0x01000000) if (dwSystemAffinityMask & 0x01000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU24), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU24), TRUE);
if (dwSystemAffinityMask & 0x02000000) if (dwSystemAffinityMask & 0x02000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU25), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU25), TRUE);
if (dwSystemAffinityMask & 0x04000000) if (dwSystemAffinityMask & 0x04000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU26), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU26), TRUE);
if (dwSystemAffinityMask & 0x08000000) if (dwSystemAffinityMask & 0x08000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU27), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU27), TRUE);
if (dwSystemAffinityMask & 0x10000000) if (dwSystemAffinityMask & 0x10000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU28), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU28), TRUE);
if (dwSystemAffinityMask & 0x20000000) if (dwSystemAffinityMask & 0x20000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU29), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU29), TRUE);
if (dwSystemAffinityMask & 0x40000000) if (dwSystemAffinityMask & 0x40000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU30), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU30), TRUE);
if (dwSystemAffinityMask & 0x80000000) if (dwSystemAffinityMask & 0x80000000)
EnableWindow(GetDlgItem(hDlg, IDC_CPU31), TRUE); EnableWindow(GetDlgItem(hDlg, IDC_CPU31), TRUE);
/* /*
* Check each checkbox that the current process * Check each checkbox that the current process
* has affinity with * has affinity with
*/ */
if (dwProcessAffinityMask & 0x00000001) if (dwProcessAffinityMask & 0x00000001)
SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000002) if (dwProcessAffinityMask & 0x00000002)
SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000004) if (dwProcessAffinityMask & 0x00000004)
SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000008) if (dwProcessAffinityMask & 0x00000008)
SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000010) if (dwProcessAffinityMask & 0x00000010)
SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000020) if (dwProcessAffinityMask & 0x00000020)
SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000040) if (dwProcessAffinityMask & 0x00000040)
SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000080) if (dwProcessAffinityMask & 0x00000080)
SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000100) if (dwProcessAffinityMask & 0x00000100)
SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000200) if (dwProcessAffinityMask & 0x00000200)
SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000400) if (dwProcessAffinityMask & 0x00000400)
SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00000800) if (dwProcessAffinityMask & 0x00000800)
SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00001000) if (dwProcessAffinityMask & 0x00001000)
SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00002000) if (dwProcessAffinityMask & 0x00002000)
SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00004000) if (dwProcessAffinityMask & 0x00004000)
SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00008000) if (dwProcessAffinityMask & 0x00008000)
SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00010000) if (dwProcessAffinityMask & 0x00010000)
SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00020000) if (dwProcessAffinityMask & 0x00020000)
SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00040000) if (dwProcessAffinityMask & 0x00040000)
SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00080000) if (dwProcessAffinityMask & 0x00080000)
SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00100000) if (dwProcessAffinityMask & 0x00100000)
SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00200000) if (dwProcessAffinityMask & 0x00200000)
SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00400000) if (dwProcessAffinityMask & 0x00400000)
SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x00800000) if (dwProcessAffinityMask & 0x00800000)
SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x01000000) if (dwProcessAffinityMask & 0x01000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x02000000) if (dwProcessAffinityMask & 0x02000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x04000000) if (dwProcessAffinityMask & 0x04000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x08000000) if (dwProcessAffinityMask & 0x08000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x10000000) if (dwProcessAffinityMask & 0x10000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x20000000) if (dwProcessAffinityMask & 0x20000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x40000000) if (dwProcessAffinityMask & 0x40000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_SETCHECK, BST_CHECKED, 0);
if (dwProcessAffinityMask & 0x80000000) if (dwProcessAffinityMask & 0x80000000)
SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_SETCHECK, BST_CHECKED, 0);
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
/* /*
* If the user has cancelled the dialog box * If the user has cancelled the dialog box
* then just close it * then just close it
*/ */
if (LOWORD(wParam) == IDCANCEL) { if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return TRUE; return TRUE;
} }
/* /*
* The user has clicked OK -- so now we have * The user has clicked OK -- so now we have
* to adjust the process affinity mask * to adjust the process affinity mask
*/ */
if (LOWORD(wParam) == IDOK) { if (LOWORD(wParam) == IDOK) {
/* /*
* First we have to create a mask out of each * First we have to create a mask out of each
* checkbox that the user checked. * checkbox that the user checked.
*/ */
if (SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU0), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000001; dwProcessAffinityMask |= 0x00000001;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU1), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000002; dwProcessAffinityMask |= 0x00000002;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU2), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000004; dwProcessAffinityMask |= 0x00000004;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU3), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000008; dwProcessAffinityMask |= 0x00000008;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU4), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000010; dwProcessAffinityMask |= 0x00000010;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU5), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000020; dwProcessAffinityMask |= 0x00000020;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU6), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000040; dwProcessAffinityMask |= 0x00000040;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU7), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000080; dwProcessAffinityMask |= 0x00000080;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU8), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000100; dwProcessAffinityMask |= 0x00000100;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU9), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000200; dwProcessAffinityMask |= 0x00000200;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU10), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000400; dwProcessAffinityMask |= 0x00000400;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU11), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00000800; dwProcessAffinityMask |= 0x00000800;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU12), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00001000; dwProcessAffinityMask |= 0x00001000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU13), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00002000; dwProcessAffinityMask |= 0x00002000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU14), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00004000; dwProcessAffinityMask |= 0x00004000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU15), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00008000; dwProcessAffinityMask |= 0x00008000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU16), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00010000; dwProcessAffinityMask |= 0x00010000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU17), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00020000; dwProcessAffinityMask |= 0x00020000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU18), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00040000; dwProcessAffinityMask |= 0x00040000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU19), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00080000; dwProcessAffinityMask |= 0x00080000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU20), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00100000; dwProcessAffinityMask |= 0x00100000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU21), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00200000; dwProcessAffinityMask |= 0x00200000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU22), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00400000; dwProcessAffinityMask |= 0x00400000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU23), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x00800000; dwProcessAffinityMask |= 0x00800000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU24), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x01000000; dwProcessAffinityMask |= 0x01000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU25), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x02000000; dwProcessAffinityMask |= 0x02000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU26), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x04000000; dwProcessAffinityMask |= 0x04000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU27), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x08000000; dwProcessAffinityMask |= 0x08000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU28), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x10000000; dwProcessAffinityMask |= 0x10000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU29), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x20000000; dwProcessAffinityMask |= 0x20000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU30), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x40000000; dwProcessAffinityMask |= 0x40000000;
if (SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_GETCHECK, 0, 0)) if (SendMessage(GetDlgItem(hDlg, IDC_CPU31), BM_GETCHECK, 0, 0))
dwProcessAffinityMask |= 0x80000000; dwProcessAffinityMask |= 0x80000000;
/* /*
* Make sure they are giving the process affinity * Make sure they are giving the process affinity
* with at least one processor. I'd hate to see a * with at least one processor. I'd hate to see a
* process that is not in a wait state get deprived * process that is not in a wait state get deprived
* of it's cpu time. * of it's cpu time.
*/ */
if (!dwProcessAffinityMask) { if (!dwProcessAffinityMask) {
MessageBox(hDlg, _T("The process must have affinity with at least one processor."), _T("Invalid Option"), MB_OK|MB_ICONSTOP); MessageBox(hDlg, _T("The process must have affinity with at least one processor."), _T("Invalid Option"), MB_OK|MB_ICONSTOP);
return TRUE; return TRUE;
} }
/* /*
* Try to set the process affinity * Try to set the process affinity
*/ */
if (!SetProcessAffinityMask(hProcessAffinityHandle, dwProcessAffinityMask)) { if (!SetProcessAffinityMask(hProcessAffinityHandle, dwProcessAffinityMask)) {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Access or Set Process Affinity"), MB_OK|MB_ICONSTOP);
} }
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return TRUE; return TRUE;
} }
break; break;
} }
return 0; return 0;
} }

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -885,7 +885,7 @@ void ApplicationPage_OnSwitchTo(void)
SwitchToThisWindow = (PROCSWITCHTOTHISWINDOW)GetProcAddress(hUser32, "SwitchToThisWindow"); SwitchToThisWindow = (PROCSWITCHTOTHISWINDOW)GetProcAddress(hUser32, "SwitchToThisWindow");
if (SwitchToThisWindow) { if (SwitchToThisWindow) {
SwitchToThisWindow(pAPLI->hWnd, TRUE); SwitchToThisWindow(pAPLI->hWnd, TRUE);
} else { } else {
if (IsIconic(pAPLI->hWnd)) if (IsIconic(pAPLI->hWnd))
ShowWindow(pAPLI->hWnd, SW_RESTORE); ShowWindow(pAPLI->hWnd, SW_RESTORE);
BringWindowToTop(pAPLI->hWnd); BringWindowToTop(pAPLI->hWnd);
@ -956,10 +956,10 @@ int CALLBACK ApplicationPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM l
LPAPPLICATION_PAGE_LIST_ITEM Param1; LPAPPLICATION_PAGE_LIST_ITEM Param1;
LPAPPLICATION_PAGE_LIST_ITEM Param2; LPAPPLICATION_PAGE_LIST_ITEM Param2;
if (bSortAscending) { if (bSortAscending) {
Param1 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam1; Param1 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam1;
Param2 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam2; Param2 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam2;
} else { } else {
Param1 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam2; Param1 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam2;
Param2 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam1; Param2 = (LPAPPLICATION_PAGE_LIST_ITEM)lParam1;
} }

View file

@ -19,32 +19,32 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef __APPLICATIONPAGE_H #ifndef __APPLICATIONPAGE_H
#define __APPLICATIONPAGE_H #define __APPLICATIONPAGE_H
extern HWND hApplicationPage; /* Application List Property Page */ extern HWND hApplicationPage; /* Application List Property Page */
extern HWND hApplicationPageListCtrl; /* Application ListCtrl Window */ extern HWND hApplicationPageListCtrl; /* Application ListCtrl Window */
extern HWND hApplicationPageEndTaskButton; /* Application End Task button */ extern HWND hApplicationPageEndTaskButton; /* Application End Task button */
extern HWND hApplicationPageSwitchToButton; /* Application Switch To button */ extern HWND hApplicationPageSwitchToButton; /* Application Switch To button */
extern HWND hApplicationPageNewTaskButton; /* Application New Task button */ extern HWND hApplicationPageNewTaskButton; /* Application New Task button */
LRESULT CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void RefreshApplicationPage(void); void RefreshApplicationPage(void);
void UpdateApplicationListControlViewSetting(void); void UpdateApplicationListControlViewSetting(void);
void ApplicationPage_OnViewLargeIcons(void); void ApplicationPage_OnViewLargeIcons(void);
void ApplicationPage_OnViewSmallIcons(void); void ApplicationPage_OnViewSmallIcons(void);
void ApplicationPage_OnViewDetails(void); void ApplicationPage_OnViewDetails(void);
void ApplicationPage_OnWindowsTileHorizontally(void); void ApplicationPage_OnWindowsTileHorizontally(void);
void ApplicationPage_OnWindowsTileVertically(void); void ApplicationPage_OnWindowsTileVertically(void);
void ApplicationPage_OnWindowsMinimize(void); void ApplicationPage_OnWindowsMinimize(void);
void ApplicationPage_OnWindowsMaximize(void); void ApplicationPage_OnWindowsMaximize(void);
void ApplicationPage_OnWindowsCascade(void); void ApplicationPage_OnWindowsCascade(void);
void ApplicationPage_OnWindowsBringToFront(void); void ApplicationPage_OnWindowsBringToFront(void);
void ApplicationPage_OnSwitchTo(void); void ApplicationPage_OnSwitchTo(void);
void ApplicationPage_OnEndTask(void); void ApplicationPage_OnEndTask(void);
void ApplicationPage_OnGotoProcess(void); void ApplicationPage_OnGotoProcess(void);
#endif /* __APPLICATIONPAGE_H */ #endif /* __APPLICATIONPAGE_H */

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -28,519 +28,519 @@
#include <memory.h> #include <memory.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "column.h" #include "column.h"
#include "procpage.h" #include "procpage.h"
UINT ColumnDataHints[25]; UINT ColumnDataHints[25];
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem); int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem);
LRESULT CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void AddColumns(void) void AddColumns(void)
{ {
int size; int size;
if (TaskManagerSettings.Column_ImageName) if (TaskManagerSettings.Column_ImageName)
InsertColumn(0, _T("Image Name"), LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[0], -1); InsertColumn(0, _T("Image Name"), LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[0], -1);
if (TaskManagerSettings.Column_PID) if (TaskManagerSettings.Column_PID)
InsertColumn(1, _T("PID"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[1], -1); InsertColumn(1, _T("PID"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[1], -1);
if (TaskManagerSettings.Column_UserName) if (TaskManagerSettings.Column_UserName)
InsertColumn(2, _T("Username"), LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[2], -1); InsertColumn(2, _T("Username"), LVCFMT_LEFT, TaskManagerSettings.ColumnSizeArray[2], -1);
if (TaskManagerSettings.Column_SessionID) if (TaskManagerSettings.Column_SessionID)
InsertColumn(3, _T("Session ID"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[3], -1); InsertColumn(3, _T("Session ID"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[3], -1);
if (TaskManagerSettings.Column_CPUUsage) if (TaskManagerSettings.Column_CPUUsage)
InsertColumn(4, _T("CPU"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[4], -1); InsertColumn(4, _T("CPU"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[4], -1);
if (TaskManagerSettings.Column_CPUTime) if (TaskManagerSettings.Column_CPUTime)
InsertColumn(5, _T("CPU Time"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[5], -1); InsertColumn(5, _T("CPU Time"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[5], -1);
if (TaskManagerSettings.Column_MemoryUsage) if (TaskManagerSettings.Column_MemoryUsage)
InsertColumn(6, _T("Mem Usage"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[6], -1); InsertColumn(6, _T("Mem Usage"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[6], -1);
if (TaskManagerSettings.Column_PeakMemoryUsage) if (TaskManagerSettings.Column_PeakMemoryUsage)
InsertColumn(7, _T("Peak Mem Usage"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[7], -1); InsertColumn(7, _T("Peak Mem Usage"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[7], -1);
if (TaskManagerSettings.Column_MemoryUsageDelta) if (TaskManagerSettings.Column_MemoryUsageDelta)
InsertColumn(8, _T("Mem Delta"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[8], -1); InsertColumn(8, _T("Mem Delta"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[8], -1);
if (TaskManagerSettings.Column_PageFaults) if (TaskManagerSettings.Column_PageFaults)
InsertColumn(9, _T("Page Faults"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[9], -1); InsertColumn(9, _T("Page Faults"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[9], -1);
if (TaskManagerSettings.Column_PageFaultsDelta) if (TaskManagerSettings.Column_PageFaultsDelta)
InsertColumn(10, _T("PF Delta"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[10], -1); InsertColumn(10, _T("PF Delta"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[10], -1);
if (TaskManagerSettings.Column_VirtualMemorySize) if (TaskManagerSettings.Column_VirtualMemorySize)
InsertColumn(11, _T("VM Size"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[11], -1); InsertColumn(11, _T("VM Size"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[11], -1);
if (TaskManagerSettings.Column_PagedPool) if (TaskManagerSettings.Column_PagedPool)
InsertColumn(12, _T("Paged Pool"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[12], -1); InsertColumn(12, _T("Paged Pool"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[12], -1);
if (TaskManagerSettings.Column_NonPagedPool) if (TaskManagerSettings.Column_NonPagedPool)
InsertColumn(13, _T("NP Pool"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[13], -1); InsertColumn(13, _T("NP Pool"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[13], -1);
if (TaskManagerSettings.Column_BasePriority) if (TaskManagerSettings.Column_BasePriority)
InsertColumn(14, _T("Base Pri"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[14], -1); InsertColumn(14, _T("Base Pri"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[14], -1);
if (TaskManagerSettings.Column_HandleCount) if (TaskManagerSettings.Column_HandleCount)
InsertColumn(15, _T("Handles"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[15], -1); InsertColumn(15, _T("Handles"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[15], -1);
if (TaskManagerSettings.Column_ThreadCount) if (TaskManagerSettings.Column_ThreadCount)
InsertColumn(16, _T("Threads"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[16], -1); InsertColumn(16, _T("Threads"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[16], -1);
if (TaskManagerSettings.Column_USERObjects) if (TaskManagerSettings.Column_USERObjects)
InsertColumn(17, _T("USER Objects"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[17], -1); InsertColumn(17, _T("USER Objects"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[17], -1);
if (TaskManagerSettings.Column_GDIObjects) if (TaskManagerSettings.Column_GDIObjects)
InsertColumn(18, _T("GDI Objects"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[18], -1); InsertColumn(18, _T("GDI Objects"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[18], -1);
if (TaskManagerSettings.Column_IOReads) if (TaskManagerSettings.Column_IOReads)
InsertColumn(19, _T("I/O Reads"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[19], -1); InsertColumn(19, _T("I/O Reads"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[19], -1);
if (TaskManagerSettings.Column_IOWrites) if (TaskManagerSettings.Column_IOWrites)
InsertColumn(20, _T("I/O Writes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[20], -1); InsertColumn(20, _T("I/O Writes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[20], -1);
if (TaskManagerSettings.Column_IOOther) if (TaskManagerSettings.Column_IOOther)
InsertColumn(21, _T("I/O Other"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[21], -1); InsertColumn(21, _T("I/O Other"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[21], -1);
if (TaskManagerSettings.Column_IOReadBytes) if (TaskManagerSettings.Column_IOReadBytes)
InsertColumn(22, _T("I/O Read Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[22], -1); InsertColumn(22, _T("I/O Read Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[22], -1);
if (TaskManagerSettings.Column_IOWriteBytes) if (TaskManagerSettings.Column_IOWriteBytes)
InsertColumn(23, _T("I/O Write Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[23], -1); InsertColumn(23, _T("I/O Write Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[23], -1);
if (TaskManagerSettings.Column_IOOtherBytes) if (TaskManagerSettings.Column_IOOtherBytes)
InsertColumn(24, _T("I/O Other Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[24], -1); InsertColumn(24, _T("I/O Other Bytes"), LVCFMT_RIGHT, TaskManagerSettings.ColumnSizeArray[24], -1);
size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
SendMessage(hProcessPageHeaderCtrl, HDM_SETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray); SendMessage(hProcessPageHeaderCtrl, HDM_SETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
UpdateColumnDataHints(); UpdateColumnDataHints();
} }
int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem) int InsertColumn(int nCol, LPCTSTR lpszColumnHeading, int nFormat, int nWidth, int nSubItem)
{ {
LVCOLUMN column; LVCOLUMN column;
column.mask = LVCF_TEXT|LVCF_FMT; column.mask = LVCF_TEXT|LVCF_FMT;
column.pszText = (LPTSTR)lpszColumnHeading; column.pszText = (LPTSTR)lpszColumnHeading;
column.fmt = nFormat; column.fmt = nFormat;
if (nWidth != -1) if (nWidth != -1)
{ {
column.mask |= LVCF_WIDTH; column.mask |= LVCF_WIDTH;
column.cx = nWidth; column.cx = nWidth;
} }
if (nSubItem != -1) if (nSubItem != -1)
{ {
column.mask |= LVCF_SUBITEM; column.mask |= LVCF_SUBITEM;
column.iSubItem = nSubItem; column.iSubItem = nSubItem;
} }
return ListView_InsertColumn(hProcessPageListCtrl, nCol, &column); return ListView_InsertColumn(hProcessPageListCtrl, nCol, &column);
} }
void SaveColumnSettings(void) void SaveColumnSettings(void)
{ {
HDITEM hditem; HDITEM hditem;
int i; int i;
TCHAR text[260]; TCHAR text[260];
int size; int size;
/* Reset column data */ /* Reset column data */
for (i=0; i<25; i++) for (i=0; i<25; i++)
TaskManagerSettings.ColumnOrderArray[i] = i; TaskManagerSettings.ColumnOrderArray[i] = i;
TaskManagerSettings.Column_ImageName = FALSE; TaskManagerSettings.Column_ImageName = FALSE;
TaskManagerSettings.Column_PID = FALSE; TaskManagerSettings.Column_PID = FALSE;
TaskManagerSettings.Column_CPUUsage = FALSE; TaskManagerSettings.Column_CPUUsage = FALSE;
TaskManagerSettings.Column_CPUTime = FALSE; TaskManagerSettings.Column_CPUTime = FALSE;
TaskManagerSettings.Column_MemoryUsage = FALSE; TaskManagerSettings.Column_MemoryUsage = FALSE;
TaskManagerSettings.Column_MemoryUsageDelta = FALSE; TaskManagerSettings.Column_MemoryUsageDelta = FALSE;
TaskManagerSettings.Column_PeakMemoryUsage = FALSE; TaskManagerSettings.Column_PeakMemoryUsage = FALSE;
TaskManagerSettings.Column_PageFaults = FALSE; TaskManagerSettings.Column_PageFaults = FALSE;
TaskManagerSettings.Column_USERObjects = FALSE; TaskManagerSettings.Column_USERObjects = FALSE;
TaskManagerSettings.Column_IOReads = FALSE; TaskManagerSettings.Column_IOReads = FALSE;
TaskManagerSettings.Column_IOReadBytes = FALSE; TaskManagerSettings.Column_IOReadBytes = FALSE;
TaskManagerSettings.Column_SessionID = FALSE; TaskManagerSettings.Column_SessionID = FALSE;
TaskManagerSettings.Column_UserName = FALSE; TaskManagerSettings.Column_UserName = FALSE;
TaskManagerSettings.Column_PageFaultsDelta = FALSE; TaskManagerSettings.Column_PageFaultsDelta = FALSE;
TaskManagerSettings.Column_VirtualMemorySize = FALSE; TaskManagerSettings.Column_VirtualMemorySize = FALSE;
TaskManagerSettings.Column_PagedPool = FALSE; TaskManagerSettings.Column_PagedPool = FALSE;
TaskManagerSettings.Column_NonPagedPool = FALSE; TaskManagerSettings.Column_NonPagedPool = FALSE;
TaskManagerSettings.Column_BasePriority = FALSE; TaskManagerSettings.Column_BasePriority = FALSE;
TaskManagerSettings.Column_HandleCount = FALSE; TaskManagerSettings.Column_HandleCount = FALSE;
TaskManagerSettings.Column_ThreadCount = FALSE; TaskManagerSettings.Column_ThreadCount = FALSE;
TaskManagerSettings.Column_GDIObjects = FALSE; TaskManagerSettings.Column_GDIObjects = FALSE;
TaskManagerSettings.Column_IOWrites = FALSE; TaskManagerSettings.Column_IOWrites = FALSE;
TaskManagerSettings.Column_IOWriteBytes = FALSE; TaskManagerSettings.Column_IOWriteBytes = FALSE;
TaskManagerSettings.Column_IOOther = FALSE; TaskManagerSettings.Column_IOOther = FALSE;
TaskManagerSettings.Column_IOOtherBytes = FALSE; TaskManagerSettings.Column_IOOtherBytes = FALSE;
TaskManagerSettings.ColumnSizeArray[0] = 105; TaskManagerSettings.ColumnSizeArray[0] = 105;
TaskManagerSettings.ColumnSizeArray[1] = 50; TaskManagerSettings.ColumnSizeArray[1] = 50;
TaskManagerSettings.ColumnSizeArray[2] = 107; TaskManagerSettings.ColumnSizeArray[2] = 107;
TaskManagerSettings.ColumnSizeArray[3] = 70; TaskManagerSettings.ColumnSizeArray[3] = 70;
TaskManagerSettings.ColumnSizeArray[4] = 35; TaskManagerSettings.ColumnSizeArray[4] = 35;
TaskManagerSettings.ColumnSizeArray[5] = 70; TaskManagerSettings.ColumnSizeArray[5] = 70;
TaskManagerSettings.ColumnSizeArray[6] = 70; TaskManagerSettings.ColumnSizeArray[6] = 70;
TaskManagerSettings.ColumnSizeArray[7] = 100; TaskManagerSettings.ColumnSizeArray[7] = 100;
TaskManagerSettings.ColumnSizeArray[8] = 70; TaskManagerSettings.ColumnSizeArray[8] = 70;
TaskManagerSettings.ColumnSizeArray[9] = 70; TaskManagerSettings.ColumnSizeArray[9] = 70;
TaskManagerSettings.ColumnSizeArray[10] = 70; TaskManagerSettings.ColumnSizeArray[10] = 70;
TaskManagerSettings.ColumnSizeArray[11] = 70; TaskManagerSettings.ColumnSizeArray[11] = 70;
TaskManagerSettings.ColumnSizeArray[12] = 70; TaskManagerSettings.ColumnSizeArray[12] = 70;
TaskManagerSettings.ColumnSizeArray[13] = 70; TaskManagerSettings.ColumnSizeArray[13] = 70;
TaskManagerSettings.ColumnSizeArray[14] = 60; TaskManagerSettings.ColumnSizeArray[14] = 60;
TaskManagerSettings.ColumnSizeArray[15] = 60; TaskManagerSettings.ColumnSizeArray[15] = 60;
TaskManagerSettings.ColumnSizeArray[16] = 60; TaskManagerSettings.ColumnSizeArray[16] = 60;
TaskManagerSettings.ColumnSizeArray[17] = 60; TaskManagerSettings.ColumnSizeArray[17] = 60;
TaskManagerSettings.ColumnSizeArray[18] = 60; TaskManagerSettings.ColumnSizeArray[18] = 60;
TaskManagerSettings.ColumnSizeArray[19] = 70; TaskManagerSettings.ColumnSizeArray[19] = 70;
TaskManagerSettings.ColumnSizeArray[20] = 70; TaskManagerSettings.ColumnSizeArray[20] = 70;
TaskManagerSettings.ColumnSizeArray[21] = 70; TaskManagerSettings.ColumnSizeArray[21] = 70;
TaskManagerSettings.ColumnSizeArray[22] = 70; TaskManagerSettings.ColumnSizeArray[22] = 70;
TaskManagerSettings.ColumnSizeArray[23] = 70; TaskManagerSettings.ColumnSizeArray[23] = 70;
TaskManagerSettings.ColumnSizeArray[24] = 70; TaskManagerSettings.ColumnSizeArray[24] = 70;
/* Get header order */ /* Get header order */
size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); size = SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0);
SendMessage(hProcessPageHeaderCtrl, HDM_GETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray); SendMessage(hProcessPageHeaderCtrl, HDM_GETORDERARRAY, (WPARAM) size, (LPARAM) &TaskManagerSettings.ColumnOrderArray);
/* Get visible columns */ /* Get visible columns */
for (i=0; i<SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); i++) { for (i=0; i<SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); i++) {
memset(&hditem, 0, sizeof(HDITEM)); memset(&hditem, 0, sizeof(HDITEM));
hditem.mask = HDI_TEXT|HDI_WIDTH; hditem.mask = HDI_TEXT|HDI_WIDTH;
hditem.pszText = text; hditem.pszText = text;
hditem.cchTextMax = 260; hditem.cchTextMax = 260;
SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, i, (LPARAM) &hditem); SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, i, (LPARAM) &hditem);
if (_tcsicmp(text, _T("Image Name")) == 0) if (_tcsicmp(text, _T("Image Name")) == 0)
{ {
TaskManagerSettings.Column_ImageName = TRUE; TaskManagerSettings.Column_ImageName = TRUE;
TaskManagerSettings.ColumnSizeArray[0] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[0] = hditem.cxy;
} }
if (_tcsicmp(text, _T("PID")) == 0) if (_tcsicmp(text, _T("PID")) == 0)
{ {
TaskManagerSettings.Column_PID = TRUE; TaskManagerSettings.Column_PID = TRUE;
TaskManagerSettings.ColumnSizeArray[1] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[1] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Username")) == 0) if (_tcsicmp(text, _T("Username")) == 0)
{ {
TaskManagerSettings.Column_UserName = TRUE; TaskManagerSettings.Column_UserName = TRUE;
TaskManagerSettings.ColumnSizeArray[2] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[2] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Session ID")) == 0) if (_tcsicmp(text, _T("Session ID")) == 0)
{ {
TaskManagerSettings.Column_SessionID = TRUE; TaskManagerSettings.Column_SessionID = TRUE;
TaskManagerSettings.ColumnSizeArray[3] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[3] = hditem.cxy;
} }
if (_tcsicmp(text, _T("CPU")) == 0) if (_tcsicmp(text, _T("CPU")) == 0)
{ {
TaskManagerSettings.Column_CPUUsage = TRUE; TaskManagerSettings.Column_CPUUsage = TRUE;
TaskManagerSettings.ColumnSizeArray[4] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[4] = hditem.cxy;
} }
if (_tcsicmp(text, _T("CPU Time")) == 0) if (_tcsicmp(text, _T("CPU Time")) == 0)
{ {
TaskManagerSettings.Column_CPUTime = TRUE; TaskManagerSettings.Column_CPUTime = TRUE;
TaskManagerSettings.ColumnSizeArray[5] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[5] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Mem Usage")) == 0) if (_tcsicmp(text, _T("Mem Usage")) == 0)
{ {
TaskManagerSettings.Column_MemoryUsage = TRUE; TaskManagerSettings.Column_MemoryUsage = TRUE;
TaskManagerSettings.ColumnSizeArray[6] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[6] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Peak Mem Usage")) == 0) if (_tcsicmp(text, _T("Peak Mem Usage")) == 0)
{ {
TaskManagerSettings.Column_PeakMemoryUsage = TRUE; TaskManagerSettings.Column_PeakMemoryUsage = TRUE;
TaskManagerSettings.ColumnSizeArray[7] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[7] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Mem Delta")) == 0) if (_tcsicmp(text, _T("Mem Delta")) == 0)
{ {
TaskManagerSettings.Column_MemoryUsageDelta = TRUE; TaskManagerSettings.Column_MemoryUsageDelta = TRUE;
TaskManagerSettings.ColumnSizeArray[8] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[8] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Page Faults")) == 0) if (_tcsicmp(text, _T("Page Faults")) == 0)
{ {
TaskManagerSettings.Column_PageFaults = TRUE; TaskManagerSettings.Column_PageFaults = TRUE;
TaskManagerSettings.ColumnSizeArray[9] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[9] = hditem.cxy;
} }
if (_tcsicmp(text, _T("PF Delta")) == 0) if (_tcsicmp(text, _T("PF Delta")) == 0)
{ {
TaskManagerSettings.Column_PageFaultsDelta = TRUE; TaskManagerSettings.Column_PageFaultsDelta = TRUE;
TaskManagerSettings.ColumnSizeArray[10] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[10] = hditem.cxy;
} }
if (_tcsicmp(text, _T("VM Size")) == 0) if (_tcsicmp(text, _T("VM Size")) == 0)
{ {
TaskManagerSettings.Column_VirtualMemorySize = TRUE; TaskManagerSettings.Column_VirtualMemorySize = TRUE;
TaskManagerSettings.ColumnSizeArray[11] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[11] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Paged Pool")) == 0) if (_tcsicmp(text, _T("Paged Pool")) == 0)
{ {
TaskManagerSettings.Column_PagedPool = TRUE; TaskManagerSettings.Column_PagedPool = TRUE;
TaskManagerSettings.ColumnSizeArray[12] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[12] = hditem.cxy;
} }
if (_tcsicmp(text, _T("NP Pool")) == 0) if (_tcsicmp(text, _T("NP Pool")) == 0)
{ {
TaskManagerSettings.Column_NonPagedPool = TRUE; TaskManagerSettings.Column_NonPagedPool = TRUE;
TaskManagerSettings.ColumnSizeArray[13] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[13] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Base Pri")) == 0) if (_tcsicmp(text, _T("Base Pri")) == 0)
{ {
TaskManagerSettings.Column_BasePriority = TRUE; TaskManagerSettings.Column_BasePriority = TRUE;
TaskManagerSettings.ColumnSizeArray[14] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[14] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Handles")) == 0) if (_tcsicmp(text, _T("Handles")) == 0)
{ {
TaskManagerSettings.Column_HandleCount = TRUE; TaskManagerSettings.Column_HandleCount = TRUE;
TaskManagerSettings.ColumnSizeArray[15] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[15] = hditem.cxy;
} }
if (_tcsicmp(text, _T("Threads")) == 0) if (_tcsicmp(text, _T("Threads")) == 0)
{ {
TaskManagerSettings.Column_ThreadCount = TRUE; TaskManagerSettings.Column_ThreadCount = TRUE;
TaskManagerSettings.ColumnSizeArray[16] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[16] = hditem.cxy;
} }
if (_tcsicmp(text, _T("USER Objects")) == 0) if (_tcsicmp(text, _T("USER Objects")) == 0)
{ {
TaskManagerSettings.Column_USERObjects = TRUE; TaskManagerSettings.Column_USERObjects = TRUE;
TaskManagerSettings.ColumnSizeArray[17] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[17] = hditem.cxy;
} }
if (_tcsicmp(text, _T("GDI Objects")) == 0) if (_tcsicmp(text, _T("GDI Objects")) == 0)
{ {
TaskManagerSettings.Column_GDIObjects = TRUE; TaskManagerSettings.Column_GDIObjects = TRUE;
TaskManagerSettings.ColumnSizeArray[18] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[18] = hditem.cxy;
} }
if (_tcsicmp(text, _T("I/O Reads")) == 0) if (_tcsicmp(text, _T("I/O Reads")) == 0)
{ {
TaskManagerSettings.Column_IOReads = TRUE; TaskManagerSettings.Column_IOReads = TRUE;
TaskManagerSettings.ColumnSizeArray[19] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[19] = hditem.cxy;
} }
if (_tcsicmp(text, _T("I/O Writes")) == 0) if (_tcsicmp(text, _T("I/O Writes")) == 0)
{ {
TaskManagerSettings.Column_IOWrites = TRUE; TaskManagerSettings.Column_IOWrites = TRUE;
TaskManagerSettings.ColumnSizeArray[20] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[20] = hditem.cxy;
} }
if (_tcsicmp(text, _T("I/O Other")) == 0) if (_tcsicmp(text, _T("I/O Other")) == 0)
{ {
TaskManagerSettings.Column_IOOther = TRUE; TaskManagerSettings.Column_IOOther = TRUE;
TaskManagerSettings.ColumnSizeArray[21] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[21] = hditem.cxy;
} }
if (_tcsicmp(text, _T("I/O Read Bytes")) == 0) if (_tcsicmp(text, _T("I/O Read Bytes")) == 0)
{ {
TaskManagerSettings.Column_IOReadBytes = TRUE; TaskManagerSettings.Column_IOReadBytes = TRUE;
TaskManagerSettings.ColumnSizeArray[22] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[22] = hditem.cxy;
} }
if (_tcsicmp(text, _T("I/O Write Bytes")) == 0) if (_tcsicmp(text, _T("I/O Write Bytes")) == 0)
{ {
TaskManagerSettings.Column_IOWriteBytes = TRUE; TaskManagerSettings.Column_IOWriteBytes = TRUE;
TaskManagerSettings.ColumnSizeArray[23] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[23] = hditem.cxy;
} }
if (_tcsicmp(text, _T("I/O Other Bytes")) == 0) if (_tcsicmp(text, _T("I/O Other Bytes")) == 0)
{ {
TaskManagerSettings.Column_IOOtherBytes = TRUE; TaskManagerSettings.Column_IOOtherBytes = TRUE;
TaskManagerSettings.ColumnSizeArray[24] = hditem.cxy; TaskManagerSettings.ColumnSizeArray[24] = hditem.cxy;
} }
} }
} }
void ProcessPage_OnViewSelectColumns(void) void ProcessPage_OnViewSelectColumns(void)
{ {
int i; int i;
if (DialogBox(hInst, MAKEINTRESOURCE(IDD_COLUMNS_DIALOG), hMainWnd, (DLGPROC)ColumnsDialogWndProc) == IDOK) if (DialogBox(hInst, MAKEINTRESOURCE(IDD_COLUMNS_DIALOG), hMainWnd, (DLGPROC)ColumnsDialogWndProc) == IDOK)
{ {
for (i=Header_GetItemCount(hProcessPageHeaderCtrl)-1; i>=0; i--) for (i=Header_GetItemCount(hProcessPageHeaderCtrl)-1; i>=0; i--)
{ {
ListView_DeleteColumn(hProcessPageListCtrl, i); ListView_DeleteColumn(hProcessPageListCtrl, i);
} }
for (i=0; i<25; i++) for (i=0; i<25; i++)
TaskManagerSettings.ColumnOrderArray[i] = i; TaskManagerSettings.ColumnOrderArray[i] = i;
TaskManagerSettings.ColumnSizeArray[0] = 105; TaskManagerSettings.ColumnSizeArray[0] = 105;
TaskManagerSettings.ColumnSizeArray[1] = 50; TaskManagerSettings.ColumnSizeArray[1] = 50;
TaskManagerSettings.ColumnSizeArray[2] = 107; TaskManagerSettings.ColumnSizeArray[2] = 107;
TaskManagerSettings.ColumnSizeArray[3] = 70; TaskManagerSettings.ColumnSizeArray[3] = 70;
TaskManagerSettings.ColumnSizeArray[4] = 35; TaskManagerSettings.ColumnSizeArray[4] = 35;
TaskManagerSettings.ColumnSizeArray[5] = 70; TaskManagerSettings.ColumnSizeArray[5] = 70;
TaskManagerSettings.ColumnSizeArray[6] = 70; TaskManagerSettings.ColumnSizeArray[6] = 70;
TaskManagerSettings.ColumnSizeArray[7] = 100; TaskManagerSettings.ColumnSizeArray[7] = 100;
TaskManagerSettings.ColumnSizeArray[8] = 70; TaskManagerSettings.ColumnSizeArray[8] = 70;
TaskManagerSettings.ColumnSizeArray[9] = 70; TaskManagerSettings.ColumnSizeArray[9] = 70;
TaskManagerSettings.ColumnSizeArray[10] = 70; TaskManagerSettings.ColumnSizeArray[10] = 70;
TaskManagerSettings.ColumnSizeArray[11] = 70; TaskManagerSettings.ColumnSizeArray[11] = 70;
TaskManagerSettings.ColumnSizeArray[12] = 70; TaskManagerSettings.ColumnSizeArray[12] = 70;
TaskManagerSettings.ColumnSizeArray[13] = 70; TaskManagerSettings.ColumnSizeArray[13] = 70;
TaskManagerSettings.ColumnSizeArray[14] = 60; TaskManagerSettings.ColumnSizeArray[14] = 60;
TaskManagerSettings.ColumnSizeArray[15] = 60; TaskManagerSettings.ColumnSizeArray[15] = 60;
TaskManagerSettings.ColumnSizeArray[16] = 60; TaskManagerSettings.ColumnSizeArray[16] = 60;
TaskManagerSettings.ColumnSizeArray[17] = 60; TaskManagerSettings.ColumnSizeArray[17] = 60;
TaskManagerSettings.ColumnSizeArray[18] = 60; TaskManagerSettings.ColumnSizeArray[18] = 60;
TaskManagerSettings.ColumnSizeArray[19] = 70; TaskManagerSettings.ColumnSizeArray[19] = 70;
TaskManagerSettings.ColumnSizeArray[20] = 70; TaskManagerSettings.ColumnSizeArray[20] = 70;
TaskManagerSettings.ColumnSizeArray[21] = 70; TaskManagerSettings.ColumnSizeArray[21] = 70;
TaskManagerSettings.ColumnSizeArray[22] = 70; TaskManagerSettings.ColumnSizeArray[22] = 70;
TaskManagerSettings.ColumnSizeArray[23] = 70; TaskManagerSettings.ColumnSizeArray[23] = 70;
TaskManagerSettings.ColumnSizeArray[24] = 70; TaskManagerSettings.ColumnSizeArray[24] = 70;
AddColumns(); AddColumns();
} }
} }
LRESULT CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK ColumnsDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
if (TaskManagerSettings.Column_ImageName) if (TaskManagerSettings.Column_ImageName)
SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PID) if (TaskManagerSettings.Column_PID)
SendMessage(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_PID), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_UserName) if (TaskManagerSettings.Column_UserName)
SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_USERNAME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_SessionID) if (TaskManagerSettings.Column_SessionID)
SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_CPUUsage) if (TaskManagerSettings.Column_CPUUsage)
SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_CPUTime) if (TaskManagerSettings.Column_CPUTime)
SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_MemoryUsage) if (TaskManagerSettings.Column_MemoryUsage)
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PeakMemoryUsage) if (TaskManagerSettings.Column_PeakMemoryUsage)
SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_MemoryUsageDelta) if (TaskManagerSettings.Column_MemoryUsageDelta)
SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PageFaults) if (TaskManagerSettings.Column_PageFaults)
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PageFaultsDelta) if (TaskManagerSettings.Column_PageFaultsDelta)
SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_VirtualMemorySize) if (TaskManagerSettings.Column_VirtualMemorySize)
SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_PagedPool) if (TaskManagerSettings.Column_PagedPool)
SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_NonPagedPool) if (TaskManagerSettings.Column_NonPagedPool)
SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_BasePriority) if (TaskManagerSettings.Column_BasePriority)
SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_HandleCount) if (TaskManagerSettings.Column_HandleCount)
SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_ThreadCount) if (TaskManagerSettings.Column_ThreadCount)
SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_USERObjects) if (TaskManagerSettings.Column_USERObjects)
SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_GDIObjects) if (TaskManagerSettings.Column_GDIObjects)
SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOReads) if (TaskManagerSettings.Column_IOReads)
SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOWrites) if (TaskManagerSettings.Column_IOWrites)
SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOOther) if (TaskManagerSettings.Column_IOOther)
SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOReadBytes) if (TaskManagerSettings.Column_IOReadBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOWriteBytes) if (TaskManagerSettings.Column_IOWriteBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_SETCHECK, BST_CHECKED, 0);
if (TaskManagerSettings.Column_IOOtherBytes) if (TaskManagerSettings.Column_IOOtherBytes)
SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0); SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_SETCHECK, BST_CHECKED, 0);
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL) if (LOWORD(wParam) == IDCANCEL)
{ {
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return TRUE; return TRUE;
} }
if (LOWORD(wParam) == IDOK) if (LOWORD(wParam) == IDOK)
{ {
TaskManagerSettings.Column_ImageName = SendMessage(GetDlgItem(hDlg, IDC_IMAGENAME), BM_GETCHECK, 0, 0); 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_PID = SendMessage(GetDlgItem(hDlg, IDC_PID), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_UserName = SendMessage(GetDlgItem(hDlg, IDC_USERNAME), 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_SessionID = SendMessage(GetDlgItem(hDlg, IDC_SESSIONID), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_CPUUsage = SendMessage(GetDlgItem(hDlg, IDC_CPUUSAGE), 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_CPUTime = SendMessage(GetDlgItem(hDlg, IDC_CPUTIME), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_MemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGE), 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_PeakMemoryUsage = SendMessage(GetDlgItem(hDlg, IDC_PEAKMEMORYUSAGE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_MemoryUsageDelta = SendMessage(GetDlgItem(hDlg, IDC_MEMORYUSAGEDELTA), 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_PageFaults = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PageFaultsDelta = SendMessage(GetDlgItem(hDlg, IDC_PAGEFAULTSDELTA), 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_VirtualMemorySize = SendMessage(GetDlgItem(hDlg, IDC_VIRTUALMEMORYSIZE), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_PagedPool = SendMessage(GetDlgItem(hDlg, IDC_PAGEDPOOL), 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_NonPagedPool = SendMessage(GetDlgItem(hDlg, IDC_NONPAGEDPOOL), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_BasePriority = SendMessage(GetDlgItem(hDlg, IDC_BASEPRIORITY), 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_HandleCount = SendMessage(GetDlgItem(hDlg, IDC_HANDLECOUNT), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_ThreadCount = SendMessage(GetDlgItem(hDlg, IDC_THREADCOUNT), 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_USERObjects = SendMessage(GetDlgItem(hDlg, IDC_USEROBJECTS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_GDIObjects = SendMessage(GetDlgItem(hDlg, IDC_GDIOBJECTS), 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_IOReads = SendMessage(GetDlgItem(hDlg, IDC_IOREADS), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOWrites = SendMessage(GetDlgItem(hDlg, IDC_IOWRITES), 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_IOOther = SendMessage(GetDlgItem(hDlg, IDC_IOOTHER), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOReadBytes = SendMessage(GetDlgItem(hDlg, IDC_IOREADBYTES), 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_IOWriteBytes = SendMessage(GetDlgItem(hDlg, IDC_IOWRITEBYTES), BM_GETCHECK, 0, 0);
TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0); TaskManagerSettings.Column_IOOtherBytes = SendMessage(GetDlgItem(hDlg, IDC_IOOTHERBYTES), BM_GETCHECK, 0, 0);
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return TRUE; return TRUE;
} }
break; break;
} }
return 0; return 0;
} }
void UpdateColumnDataHints(void) void UpdateColumnDataHints(void)
{ {
HDITEM hditem; HDITEM hditem;
TCHAR text[260]; TCHAR text[260];
ULONG Index; ULONG Index;
for (Index=0; Index<(ULONG)SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); Index++) for (Index=0; Index<(ULONG)SendMessage(hProcessPageHeaderCtrl, HDM_GETITEMCOUNT, 0, 0); Index++)
{ {
memset(&hditem, 0, sizeof(HDITEM)); memset(&hditem, 0, sizeof(HDITEM));
hditem.mask = HDI_TEXT; hditem.mask = HDI_TEXT;
hditem.pszText = text; hditem.pszText = text;
hditem.cchTextMax = 260; hditem.cchTextMax = 260;
SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, Index, (LPARAM) &hditem); SendMessage(hProcessPageHeaderCtrl, HDM_GETITEM, Index, (LPARAM) &hditem);
if (_tcsicmp(text, _T("Image Name")) == 0) if (_tcsicmp(text, _T("Image Name")) == 0)
ColumnDataHints[Index] = COLUMN_IMAGENAME; ColumnDataHints[Index] = COLUMN_IMAGENAME;
if (_tcsicmp(text, _T("PID")) == 0) if (_tcsicmp(text, _T("PID")) == 0)
ColumnDataHints[Index] = COLUMN_PID; ColumnDataHints[Index] = COLUMN_PID;
if (_tcsicmp(text, _T("Username")) == 0) if (_tcsicmp(text, _T("Username")) == 0)
ColumnDataHints[Index] = COLUMN_USERNAME; ColumnDataHints[Index] = COLUMN_USERNAME;
if (_tcsicmp(text, _T("Session ID")) == 0) if (_tcsicmp(text, _T("Session ID")) == 0)
ColumnDataHints[Index] = COLUMN_SESSIONID; ColumnDataHints[Index] = COLUMN_SESSIONID;
if (_tcsicmp(text, _T("CPU")) == 0) if (_tcsicmp(text, _T("CPU")) == 0)
ColumnDataHints[Index] = COLUMN_CPUUSAGE; ColumnDataHints[Index] = COLUMN_CPUUSAGE;
if (_tcsicmp(text, _T("CPU Time")) == 0) if (_tcsicmp(text, _T("CPU Time")) == 0)
ColumnDataHints[Index] = COLUMN_CPUTIME; ColumnDataHints[Index] = COLUMN_CPUTIME;
if (_tcsicmp(text, _T("Mem Usage")) == 0) if (_tcsicmp(text, _T("Mem Usage")) == 0)
ColumnDataHints[Index] = COLUMN_MEMORYUSAGE; ColumnDataHints[Index] = COLUMN_MEMORYUSAGE;
if (_tcsicmp(text, _T("Peak Mem Usage")) == 0) if (_tcsicmp(text, _T("Peak Mem Usage")) == 0)
ColumnDataHints[Index] = COLUMN_PEAKMEMORYUSAGE; ColumnDataHints[Index] = COLUMN_PEAKMEMORYUSAGE;
if (_tcsicmp(text, _T("Mem Delta")) == 0) if (_tcsicmp(text, _T("Mem Delta")) == 0)
ColumnDataHints[Index] = COLUMN_MEMORYUSAGEDELTA; ColumnDataHints[Index] = COLUMN_MEMORYUSAGEDELTA;
if (_tcsicmp(text, _T("Page Faults")) == 0) if (_tcsicmp(text, _T("Page Faults")) == 0)
ColumnDataHints[Index] = COLUMN_PAGEFAULTS; ColumnDataHints[Index] = COLUMN_PAGEFAULTS;
if (_tcsicmp(text, _T("PF Delta")) == 0) if (_tcsicmp(text, _T("PF Delta")) == 0)
ColumnDataHints[Index] = COLUMN_PAGEFAULTSDELTA; ColumnDataHints[Index] = COLUMN_PAGEFAULTSDELTA;
if (_tcsicmp(text, _T("VM Size")) == 0) if (_tcsicmp(text, _T("VM Size")) == 0)
ColumnDataHints[Index] = COLUMN_VIRTUALMEMORYSIZE; ColumnDataHints[Index] = COLUMN_VIRTUALMEMORYSIZE;
if (_tcsicmp(text, _T("Paged Pool")) == 0) if (_tcsicmp(text, _T("Paged Pool")) == 0)
ColumnDataHints[Index] = COLUMN_PAGEDPOOL; ColumnDataHints[Index] = COLUMN_PAGEDPOOL;
if (_tcsicmp(text, _T("NP Pool")) == 0) if (_tcsicmp(text, _T("NP Pool")) == 0)
ColumnDataHints[Index] = COLUMN_NONPAGEDPOOL; ColumnDataHints[Index] = COLUMN_NONPAGEDPOOL;
if (_tcsicmp(text, _T("Base Pri")) == 0) if (_tcsicmp(text, _T("Base Pri")) == 0)
ColumnDataHints[Index] = COLUMN_BASEPRIORITY; ColumnDataHints[Index] = COLUMN_BASEPRIORITY;
if (_tcsicmp(text, _T("Handles")) == 0) if (_tcsicmp(text, _T("Handles")) == 0)
ColumnDataHints[Index] = COLUMN_HANDLECOUNT; ColumnDataHints[Index] = COLUMN_HANDLECOUNT;
if (_tcsicmp(text, _T("Threads")) == 0) if (_tcsicmp(text, _T("Threads")) == 0)
ColumnDataHints[Index] = COLUMN_THREADCOUNT; ColumnDataHints[Index] = COLUMN_THREADCOUNT;
if (_tcsicmp(text, _T("USER Objects")) == 0) if (_tcsicmp(text, _T("USER Objects")) == 0)
ColumnDataHints[Index] = COLUMN_USEROBJECTS; ColumnDataHints[Index] = COLUMN_USEROBJECTS;
if (_tcsicmp(text, _T("GDI Objects")) == 0) if (_tcsicmp(text, _T("GDI Objects")) == 0)
ColumnDataHints[Index] = COLUMN_GDIOBJECTS; ColumnDataHints[Index] = COLUMN_GDIOBJECTS;
if (_tcsicmp(text, _T("I/O Reads")) == 0) if (_tcsicmp(text, _T("I/O Reads")) == 0)
ColumnDataHints[Index] = COLUMN_IOREADS; ColumnDataHints[Index] = COLUMN_IOREADS;
if (_tcsicmp(text, _T("I/O Writes")) == 0) if (_tcsicmp(text, _T("I/O Writes")) == 0)
ColumnDataHints[Index] = COLUMN_IOWRITES; ColumnDataHints[Index] = COLUMN_IOWRITES;
if (_tcsicmp(text, _T("I/O Other")) == 0) if (_tcsicmp(text, _T("I/O Other")) == 0)
ColumnDataHints[Index] = COLUMN_IOOTHER; ColumnDataHints[Index] = COLUMN_IOOTHER;
if (_tcsicmp(text, _T("I/O Read Bytes")) == 0) if (_tcsicmp(text, _T("I/O Read Bytes")) == 0)
ColumnDataHints[Index] = COLUMN_IOREADBYTES; ColumnDataHints[Index] = COLUMN_IOREADBYTES;
if (_tcsicmp(text, _T("I/O Write Bytes")) == 0) if (_tcsicmp(text, _T("I/O Write Bytes")) == 0)
ColumnDataHints[Index] = COLUMN_IOWRITEBYTES; ColumnDataHints[Index] = COLUMN_IOWRITEBYTES;
if (_tcsicmp(text, _T("I/O Other Bytes")) == 0) if (_tcsicmp(text, _T("I/O Other Bytes")) == 0)
ColumnDataHints[Index] = COLUMN_IOOTHERBYTES; ColumnDataHints[Index] = COLUMN_IOOTHERBYTES;
} }
} }

View file

@ -19,37 +19,37 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef __COLUMN_H #ifndef __COLUMN_H
#define __COLUMN_H #define __COLUMN_H
#define COLUMN_IMAGENAME 0 #define COLUMN_IMAGENAME 0
#define COLUMN_PID 1 #define COLUMN_PID 1
#define COLUMN_USERNAME 2 #define COLUMN_USERNAME 2
#define COLUMN_SESSIONID 3 #define COLUMN_SESSIONID 3
#define COLUMN_CPUUSAGE 4 #define COLUMN_CPUUSAGE 4
#define COLUMN_CPUTIME 5 #define COLUMN_CPUTIME 5
#define COLUMN_MEMORYUSAGE 6 #define COLUMN_MEMORYUSAGE 6
#define COLUMN_PEAKMEMORYUSAGE 7 #define COLUMN_PEAKMEMORYUSAGE 7
#define COLUMN_MEMORYUSAGEDELTA 8 #define COLUMN_MEMORYUSAGEDELTA 8
#define COLUMN_PAGEFAULTS 9 #define COLUMN_PAGEFAULTS 9
#define COLUMN_PAGEFAULTSDELTA 10 #define COLUMN_PAGEFAULTSDELTA 10
#define COLUMN_VIRTUALMEMORYSIZE 11 #define COLUMN_VIRTUALMEMORYSIZE 11
#define COLUMN_PAGEDPOOL 12 #define COLUMN_PAGEDPOOL 12
#define COLUMN_NONPAGEDPOOL 13 #define COLUMN_NONPAGEDPOOL 13
#define COLUMN_BASEPRIORITY 14 #define COLUMN_BASEPRIORITY 14
#define COLUMN_HANDLECOUNT 15 #define COLUMN_HANDLECOUNT 15
#define COLUMN_THREADCOUNT 16 #define COLUMN_THREADCOUNT 16
#define COLUMN_USEROBJECTS 17 #define COLUMN_USEROBJECTS 17
#define COLUMN_GDIOBJECTS 18 #define COLUMN_GDIOBJECTS 18
#define COLUMN_IOREADS 19 #define COLUMN_IOREADS 19
#define COLUMN_IOWRITES 20 #define COLUMN_IOWRITES 20
#define COLUMN_IOOTHER 21 #define COLUMN_IOOTHER 21
#define COLUMN_IOREADBYTES 22 #define COLUMN_IOREADBYTES 22
#define COLUMN_IOWRITEBYTES 23 #define COLUMN_IOWRITEBYTES 23
#define COLUMN_IOOTHERBYTES 24 #define COLUMN_IOOTHERBYTES 24
extern UINT ColumnDataHints[25]; extern UINT ColumnDataHints[25];
void ProcessPage_OnViewSelectColumns(void); void ProcessPage_OnViewSelectColumns(void);
void AddColumns(void); void AddColumns(void);

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,7 +29,7 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "debug.h" #include "debug.h"
#include "procpage.h" #include "procpage.h"
@ -37,80 +37,80 @@
void ProcessPage_OnDebug(void) void ProcessPage_OnDebug(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
HKEY hKey; HKEY hKey;
TCHAR strDebugPath[260]; TCHAR strDebugPath[260];
TCHAR strDebugger[260]; TCHAR strDebugger[260];
DWORD dwDebuggerSize; DWORD dwDebuggerSize;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFO si; STARTUPINFO si;
HANDLE hDebugEvent; HANDLE hDebugEvent;
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Debugging this process may result in loss of data.\nAre you sure you wish to attach the debugger?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Debugging this process may result in loss of data.\nAre you sure you wish to attach the debugger?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) != ERROR_SUCCESS) if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return; return;
} }
dwDebuggerSize = 260; dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS) if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
RegCloseKey(hKey); RegCloseKey(hKey);
return; return;
} }
RegCloseKey(hKey); RegCloseKey(hKey);
hDebugEvent = CreateEvent(NULL, FALSE, FALSE, NULL); hDebugEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!hDebugEvent) if (!hDebugEvent)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return; return;
} }
wsprintf(strDebugPath, strDebugger, dwProcessId, hDebugEvent); wsprintf(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
memset(&pi, 0, sizeof(PROCESS_INFORMATION)); memset(&pi, 0, sizeof(PROCESS_INFORMATION));
memset(&si, 0, sizeof(STARTUPINFO)); memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
if (!CreateProcess(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) if (!CreateProcess(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hDebugEvent); CloseHandle(hDebugEvent);
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,7 +29,7 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "endproc.h" #include "endproc.h"
#include "procpage.h" #include "procpage.h"
@ -37,96 +37,96 @@
void ProcessPage_OnEndProcess(void) void ProcessPage_OnEndProcess(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!TerminateProcess(hProcess, 0)) if (!TerminateProcess(hProcess, 0))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
void ProcessPage_OnEndProcessTree(void) void ProcessPage_OnEndProcessTree(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!TerminateProcess(hProcess, 0)) if (!TerminateProcess(hProcess, 0))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -28,36 +28,36 @@
#include <memory.h> #include <memory.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "font.h" #include "font.h"
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y) void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y)
{ {
HDC hFontDC; HDC hFontDC;
HBITMAP hFontBitmap; HBITMAP hFontBitmap;
HBITMAP hOldBitmap; HBITMAP hOldBitmap;
int i; int i;
hFontDC = CreateCompatibleDC(hDC); hFontDC = CreateCompatibleDC(hDC);
hFontBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FONT)); hFontBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FONT));
hOldBitmap = (HBITMAP)SelectObject(hFontDC, hFontBitmap); hOldBitmap = (HBITMAP)SelectObject(hFontDC, hFontBitmap);
for (i = 0; i < (int)_tcslen(lpszText); i++) { for (i = 0; i < (int)_tcslen(lpszText); i++) {
if ((lpszText[i] >= '0') && (lpszText[i] <= '9')) { if ((lpszText[i] >= '0') && (lpszText[i] <= '9')) {
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, (lpszText[i] - '0') * 8, 0, SRCCOPY); BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, (lpszText[i] - '0') * 8, 0, SRCCOPY);
} }
else if (lpszText[i] == 'K') else if (lpszText[i] == 'K')
{ {
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 80, 0, SRCCOPY); BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 80, 0, SRCCOPY);
} }
else if (lpszText[i] == '%') else if (lpszText[i] == '%')
{ {
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 88, 0, SRCCOPY); BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 88, 0, SRCCOPY);
} }
} }
SelectObject(hFontDC, hOldBitmap); SelectObject(hFontDC, hOldBitmap);
DeleteObject(hFontBitmap); DeleteObject(hFontBitmap);
DeleteDC(hFontDC); DeleteDC(hFontDC);
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,207 +29,207 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "graph.h" #include "graph.h"
#include "font.h" #include "font.h"
#include "perfdata.h" #include "perfdata.h"
LONG OldGraphWndProc; LONG OldGraphWndProc;
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd); void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd);
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd); void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd);
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd); void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd);
LRESULT CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
HDC hdc; HDC hdc;
PAINTSTRUCT ps; PAINTSTRUCT ps;
LONG WindowId; LONG WindowId;
switch (message) switch (message)
{ {
case WM_ERASEBKGND: case WM_ERASEBKGND:
return TRUE; return TRUE;
/* /*
* Filter out mouse & keyboard messages * Filter out mouse & keyboard messages
*/ */
/* case WM_APPCOMMAND: */ /* case WM_APPCOMMAND: */
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_MBUTTONDBLCLK: case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_MBUTTONUP: case WM_MBUTTONUP:
case WM_MOUSEACTIVATE: case WM_MOUSEACTIVATE:
case WM_MOUSEHOVER: case WM_MOUSEHOVER:
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
/* case WM_MOUSEWHEEL: */ /* case WM_MOUSEWHEEL: */
case WM_NCHITTEST: case WM_NCHITTEST:
case WM_NCLBUTTONDBLCLK: case WM_NCLBUTTONDBLCLK:
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
case WM_NCLBUTTONUP: case WM_NCLBUTTONUP:
case WM_NCMBUTTONDBLCLK: case WM_NCMBUTTONDBLCLK:
case WM_NCMBUTTONDOWN: case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP: case WM_NCMBUTTONUP:
/* case WM_NCMOUSEHOVER: */ /* case WM_NCMOUSEHOVER: */
/* case WM_NCMOUSELEAVE: */ /* case WM_NCMOUSELEAVE: */
case WM_NCMOUSEMOVE: case WM_NCMOUSEMOVE:
case WM_NCRBUTTONDBLCLK: case WM_NCRBUTTONDBLCLK:
case WM_NCRBUTTONDOWN: case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP: case WM_NCRBUTTONUP:
/* case WM_NCXBUTTONDBLCLK: */ /* case WM_NCXBUTTONDBLCLK: */
/* case WM_NCXBUTTONDOWN: */ /* case WM_NCXBUTTONDOWN: */
/* case WM_NCXBUTTONUP: */ /* case WM_NCXBUTTONUP: */
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONUP: case WM_RBUTTONUP:
/* case WM_XBUTTONDBLCLK: */ /* case WM_XBUTTONDBLCLK: */
/* case WM_XBUTTONDOWN: */ /* case WM_XBUTTONDOWN: */
/* case WM_XBUTTONUP: */ /* case WM_XBUTTONUP: */
case WM_ACTIVATE: case WM_ACTIVATE:
case WM_CHAR: case WM_CHAR:
case WM_DEADCHAR: case WM_DEADCHAR:
case WM_GETHOTKEY: case WM_GETHOTKEY:
case WM_HOTKEY: case WM_HOTKEY:
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_KEYUP: case WM_KEYUP:
case WM_KILLFOCUS: case WM_KILLFOCUS:
case WM_SETFOCUS: case WM_SETFOCUS:
case WM_SETHOTKEY: case WM_SETHOTKEY:
case WM_SYSCHAR: case WM_SYSCHAR:
case WM_SYSDEADCHAR: case WM_SYSDEADCHAR:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
case WM_SYSKEYUP: case WM_SYSKEYUP:
case WM_NCCALCSIZE: case WM_NCCALCSIZE:
return 0; return 0;
case WM_PAINT: case WM_PAINT:
hdc = BeginPaint(hWnd, &ps); hdc = BeginPaint(hWnd, &ps);
WindowId = GetWindowLong(hWnd, GWL_ID); WindowId = GetWindowLong(hWnd, GWL_ID);
switch (WindowId) switch (WindowId)
{ {
case IDC_CPU_USAGE_GRAPH: case IDC_CPU_USAGE_GRAPH:
Graph_DrawCpuUsageGraph(hdc, hWnd); Graph_DrawCpuUsageGraph(hdc, hWnd);
break; break;
case IDC_MEM_USAGE_GRAPH: case IDC_MEM_USAGE_GRAPH:
Graph_DrawMemUsageGraph(hdc, hWnd); Graph_DrawMemUsageGraph(hdc, hWnd);
break; break;
case IDC_MEM_USAGE_HISTORY_GRAPH: case IDC_MEM_USAGE_HISTORY_GRAPH:
Graph_DrawMemUsageHistoryGraph(hdc, hWnd); Graph_DrawMemUsageHistoryGraph(hdc, hWnd);
break; break;
} }
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
return 0; return 0;
} }
/* /*
* We pass on all non-handled messages * We pass on all non-handled messages
*/ */
return CallWindowProc((WNDPROC)OldGraphWndProc, hWnd, message, wParam, lParam); return CallWindowProc((WNDPROC)OldGraphWndProc, hWnd, message, wParam, lParam);
} }
void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd) void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
{ {
RECT rcClient; RECT rcClient;
RECT rcBarLeft; RECT rcBarLeft;
RECT rcBarRight; RECT rcBarRight;
TCHAR Text[260]; TCHAR Text[260];
ULONG CpuUsage; ULONG CpuUsage;
ULONG CpuKernelUsage; ULONG CpuKernelUsage;
int nBars; int nBars;
int nBarsUsed; int nBarsUsed;
/* Bottom bars that are "used", i.e. are bright green, representing used cpu time */ /* Bottom bars that are "used", i.e. are bright green, representing used cpu time */
int nBarsUsedKernel; int nBarsUsedKernel;
/* Bottom bars that are "used", i.e. are bright green, representing used cpu kernel time */ /* Bottom bars that are "used", i.e. are bright green, representing used cpu kernel time */
int nBarsFree; int nBarsFree;
/* Top bars that are "unused", i.e. are dark green, representing free cpu time */ /* Top bars that are "unused", i.e. are dark green, representing free cpu time */
int i; int i;
/* /*
* Get the client area rectangle * Get the client area rectangle
*/ */
GetClientRect(hWnd, &rcClient); GetClientRect(hWnd, &rcClient);
/* /*
* Fill it with blackness * Fill it with blackness
*/ */
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0)); FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
/* /*
* Get the CPU usage * Get the CPU usage
*/ */
CpuUsage = PerfDataGetProcessorUsage(); CpuUsage = PerfDataGetProcessorUsage();
CpuKernelUsage = PerfDataGetProcessorSystemUsage(); CpuKernelUsage = PerfDataGetProcessorSystemUsage();
if (CpuUsage < 0) CpuUsage = 0; if (CpuUsage < 0) CpuUsage = 0;
if (CpuUsage > 100) CpuUsage = 100; if (CpuUsage > 100) CpuUsage = 100;
if (CpuKernelUsage < 0) CpuKernelUsage = 0; if (CpuKernelUsage < 0) CpuKernelUsage = 0;
if (CpuKernelUsage > 100) CpuKernelUsage = 100; if (CpuKernelUsage > 100) CpuKernelUsage = 100;
/* /*
* Check and see how many digits it will take * Check and see how many digits it will take
* so we get the indentation right every time. * so we get the indentation right every time.
*/ */
if (CpuUsage == 100) if (CpuUsage == 100)
{ {
_stprintf(Text, _T("%d%%"), (int)CpuUsage); _stprintf(Text, _T("%d%%"), (int)CpuUsage);
} }
else if (CpuUsage < 10) else if (CpuUsage < 10)
{ {
_stprintf(Text, _T(" %d%%"), (int)CpuUsage); _stprintf(Text, _T(" %d%%"), (int)CpuUsage);
} }
else else
{ {
_stprintf(Text, _T(" %d%%"), (int)CpuUsage); _stprintf(Text, _T(" %d%%"), (int)CpuUsage);
} }
/* /*
* Draw the font text onto the graph * Draw the font text onto the graph
* The bottom 20 pixels are reserved for the text * The bottom 20 pixels are reserved for the text
*/ */
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - 32) / 2, rcClient.bottom - 11 - 5); Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - 32) / 2, rcClient.bottom - 11 - 5);
/* /*
* Now we have to draw the graph * Now we have to draw the graph
* So first find out how many bars we can fit * So first find out how many bars we can fit
*/ */
nBars = ((rcClient.bottom - rcClient.top) - 25) / 3; nBars = ((rcClient.bottom - rcClient.top) - 25) / 3;
nBarsUsed = (nBars * CpuUsage) / 100; nBarsUsed = (nBars * CpuUsage) / 100;
if ((CpuUsage) && (nBarsUsed == 0)) if ((CpuUsage) && (nBarsUsed == 0))
{ {
nBarsUsed = 1; nBarsUsed = 1;
} }
nBarsFree = nBars - nBarsUsed; nBarsFree = nBars - nBarsUsed;
if (TaskManagerSettings.ShowKernelTimes) if (TaskManagerSettings.ShowKernelTimes)
{ {
nBarsUsedKernel = ((nBars * 2) * CpuKernelUsage) / 100; nBarsUsedKernel = ((nBars * 2) * CpuKernelUsage) / 100;
nBarsUsed -= (nBarsUsedKernel / 2); nBarsUsed -= (nBarsUsedKernel / 2);
} }
else else
{ {
nBarsUsedKernel = 0; nBarsUsedKernel = 0;
} }
/* /*
* Now draw the bar graph * Now draw the bar graph
*/ */
rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2; rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2;
rcBarLeft.right = rcBarLeft.left + 16; rcBarLeft.right = rcBarLeft.left + 16;
rcBarRight.left = rcBarLeft.left + 17; rcBarRight.left = rcBarLeft.left + 17;
rcBarRight.right = rcBarLeft.right + 17; rcBarRight.right = rcBarLeft.right + 17;
rcBarLeft.top = rcBarRight.top = 5; rcBarLeft.top = rcBarRight.top = 5;
rcBarLeft.bottom = rcBarRight.bottom = 7; rcBarLeft.bottom = rcBarRight.bottom = 7;
if (nBarsUsed < 0) nBarsUsed = 0; if (nBarsUsed < 0) nBarsUsed = 0;
if (nBarsUsed > nBars) nBarsUsed = nBars; if (nBarsUsed > nBars) nBarsUsed = nBars;
@ -240,133 +240,133 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
if (nBarsUsedKernel < 0) nBarsUsedKernel = 0; if (nBarsUsedKernel < 0) nBarsUsedKernel = 0;
if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars; if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars;
/* /*
* Draw the "free" bars * Draw the "free" bars
*/ */
for (i=0; i<nBarsFree; i++) for (i=0; i<nBarsFree; i++)
{ {
FillSolidRect(hDC, &rcBarLeft, DARK_GREEN); FillSolidRect(hDC, &rcBarLeft, DARK_GREEN);
FillSolidRect(hDC, &rcBarRight, DARK_GREEN); FillSolidRect(hDC, &rcBarRight, DARK_GREEN);
rcBarLeft.top += 3; rcBarLeft.top += 3;
rcBarLeft.bottom += 3; rcBarLeft.bottom += 3;
rcBarRight.top += 3; rcBarRight.top += 3;
rcBarRight.bottom += 3; rcBarRight.bottom += 3;
} }
/* /*
* Draw the "used" bars * Draw the "used" bars
*/ */
for (i=0; i<nBarsUsed; i++) for (i=0; i<nBarsUsed; i++)
{ {
if (nBarsUsed > 5000) nBarsUsed = 5000; if (nBarsUsed > 5000) nBarsUsed = 5000;
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN); FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN); FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
rcBarLeft.top += 3; rcBarLeft.top += 3;
rcBarLeft.bottom += 3; rcBarLeft.bottom += 3;
rcBarRight.top += 3; rcBarRight.top += 3;
rcBarRight.bottom += 3; rcBarRight.bottom += 3;
} }
/* /*
* Draw the "used" kernel bars * Draw the "used" kernel bars
*/ */
rcBarLeft.bottom--; rcBarLeft.bottom--;
rcBarRight.bottom--; rcBarRight.bottom--;
if (nBarsUsedKernel && nBarsUsedKernel % 2) if (nBarsUsedKernel && nBarsUsedKernel % 2)
{ {
rcBarLeft.top -= 2; rcBarLeft.top -= 2;
rcBarLeft.bottom -= 2; rcBarLeft.bottom -= 2;
rcBarRight.top -= 2; rcBarRight.top -= 2;
rcBarRight.bottom -= 2; rcBarRight.bottom -= 2;
FillSolidRect(hDC, &rcBarLeft, RED); FillSolidRect(hDC, &rcBarLeft, RED);
FillSolidRect(hDC, &rcBarRight, RED); FillSolidRect(hDC, &rcBarRight, RED);
rcBarLeft.top += 2; rcBarLeft.top += 2;
rcBarLeft.bottom += 2; rcBarLeft.bottom += 2;
rcBarRight.top += 2; rcBarRight.top += 2;
rcBarRight.bottom += 2; rcBarRight.bottom += 2;
nBarsUsedKernel--; nBarsUsedKernel--;
} }
for (i=0; i<nBarsUsedKernel; i++) for (i=0; i<nBarsUsedKernel; i++)
{ {
if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000; if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000;
FillSolidRect(hDC, &rcBarLeft, RED); FillSolidRect(hDC, &rcBarLeft, RED);
FillSolidRect(hDC, &rcBarRight, RED); FillSolidRect(hDC, &rcBarRight, RED);
rcBarLeft.top++; rcBarLeft.top++;
rcBarLeft.bottom++; rcBarLeft.bottom++;
rcBarRight.top++; rcBarRight.top++;
rcBarRight.bottom++; rcBarRight.bottom++;
if (i % 2) if (i % 2)
{ {
rcBarLeft.top++; rcBarLeft.top++;
rcBarLeft.bottom++; rcBarLeft.bottom++;
rcBarRight.top++; rcBarRight.top++;
rcBarRight.bottom++; rcBarRight.bottom++;
} }
} }
} }
void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd) void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
{ {
RECT rcClient; RECT rcClient;
RECT rcBarLeft; RECT rcBarLeft;
RECT rcBarRight; RECT rcBarRight;
TCHAR Text[260]; TCHAR Text[260];
ULONGLONG CommitChargeTotal; ULONGLONG CommitChargeTotal;
ULONGLONG CommitChargeLimit; ULONGLONG CommitChargeLimit;
int nBars; int nBars;
int nBarsUsed = 0; int nBarsUsed = 0;
/* Bottom bars that are "used", i.e. are bright green, representing used memory */ /* Bottom bars that are "used", i.e. are bright green, representing used memory */
int nBarsFree; int nBarsFree;
/* Top bars that are "unused", i.e. are dark green, representing free memory */ /* Top bars that are "unused", i.e. are dark green, representing free memory */
int i; int i;
/* /*
* Get the client area rectangle * Get the client area rectangle
*/ */
GetClientRect(hWnd, &rcClient); GetClientRect(hWnd, &rcClient);
/* /*
* Fill it with blackness * Fill it with blackness
*/ */
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0)); FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
/* /*
* Get the memory usage * Get the memory usage
*/ */
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK(); CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK(); CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
_stprintf(Text, _T("%dK"), (int)CommitChargeTotal); _stprintf(Text, _T("%dK"), (int)CommitChargeTotal);
/* /*
* Draw the font text onto the graph * Draw the font text onto the graph
* The bottom 20 pixels are reserved for the text * The bottom 20 pixels are reserved for the text
*/ */
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (_tcslen(Text) * 8)) / 2, rcClient.bottom - 11 - 5); Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (_tcslen(Text) * 8)) / 2, rcClient.bottom - 11 - 5);
/* /*
* Now we have to draw the graph * Now we have to draw the graph
* So first find out how many bars we can fit * So first find out how many bars we can fit
*/ */
nBars = ((rcClient.bottom - rcClient.top) - 25) / 3; nBars = ((rcClient.bottom - rcClient.top) - 25) / 3;
if (CommitChargeLimit) if (CommitChargeLimit)
nBarsUsed = (nBars * (int)((CommitChargeTotal * 100) / CommitChargeLimit)) / 100; nBarsUsed = (nBars * (int)((CommitChargeTotal * 100) / CommitChargeLimit)) / 100;
nBarsFree = nBars - nBarsUsed; nBarsFree = nBars - nBarsUsed;
if (nBarsUsed < 0) nBarsUsed = 0; if (nBarsUsed < 0) nBarsUsed = 0;
if (nBarsUsed > nBars) nBarsUsed = nBars; if (nBarsUsed > nBars) nBarsUsed = nBars;
@ -374,99 +374,99 @@ void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
if (nBarsFree < 0) nBarsFree = 0; if (nBarsFree < 0) nBarsFree = 0;
if (nBarsFree > nBars) nBarsFree = nBars; if (nBarsFree > nBars) nBarsFree = nBars;
/* /*
* Now draw the bar graph * Now draw the bar graph
*/ */
rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2; rcBarLeft.left = ((rcClient.right - rcClient.left) - 33) / 2;
rcBarLeft.right = rcBarLeft.left + 16; rcBarLeft.right = rcBarLeft.left + 16;
rcBarRight.left = rcBarLeft.left + 17; rcBarRight.left = rcBarLeft.left + 17;
rcBarRight.right = rcBarLeft.right + 17; rcBarRight.right = rcBarLeft.right + 17;
rcBarLeft.top = rcBarRight.top = 5; rcBarLeft.top = rcBarRight.top = 5;
rcBarLeft.bottom = rcBarRight.bottom = 7; rcBarLeft.bottom = rcBarRight.bottom = 7;
/* /*
* Draw the "free" bars * Draw the "free" bars
*/ */
for (i=0; i<nBarsFree; i++) for (i=0; i<nBarsFree; i++)
{ {
FillSolidRect(hDC, &rcBarLeft, DARK_GREEN); FillSolidRect(hDC, &rcBarLeft, DARK_GREEN);
FillSolidRect(hDC, &rcBarRight, DARK_GREEN); FillSolidRect(hDC, &rcBarRight, DARK_GREEN);
rcBarLeft.top += 3; rcBarLeft.top += 3;
rcBarLeft.bottom += 3; rcBarLeft.bottom += 3;
rcBarRight.top += 3; rcBarRight.top += 3;
rcBarRight.bottom += 3; rcBarRight.bottom += 3;
} }
/* /*
* Draw the "used" bars * Draw the "used" bars
*/ */
for (i=0; i<nBarsUsed; i++) for (i=0; i<nBarsUsed; i++)
{ {
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN); FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN); FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
rcBarLeft.top += 3; rcBarLeft.top += 3;
rcBarLeft.bottom += 3; rcBarLeft.bottom += 3;
rcBarRight.top += 3; rcBarRight.top += 3;
rcBarRight.bottom += 3; rcBarRight.bottom += 3;
} }
} }
void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd) void Graph_DrawMemUsageHistoryGraph(HDC hDC, HWND hWnd)
{ {
RECT rcClient; RECT rcClient;
ULONGLONG CommitChargeLimit; ULONGLONG CommitChargeLimit;
int i; int i;
static int offset = 0; static int offset = 0;
if (offset++ >= 10) if (offset++ >= 10)
offset = 0; offset = 0;
/* /*
* Get the client area rectangle * Get the client area rectangle
*/ */
GetClientRect(hWnd, &rcClient); GetClientRect(hWnd, &rcClient);
/* /*
* Fill it with blackness * Fill it with blackness
*/ */
FillSolidRect(hDC, &rcClient, RGB(0, 0, 0)); FillSolidRect(hDC, &rcClient, RGB(0, 0, 0));
/* /*
* Get the memory usage * Get the memory usage
*/ */
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK(); CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
/* /*
* Draw the graph background * Draw the graph background
* *
* Draw the horizontal bars * Draw the horizontal bars
*/ */
for (i=0; i<rcClient.bottom; i++) for (i=0; i<rcClient.bottom; i++)
{ {
if ((i % 11) == 0) if ((i % 11) == 0)
{ {
/* FillSolidRect2(hDC, 0, i, rcClient.right, 1, DARK_GREEN); */ /* FillSolidRect2(hDC, 0, i, rcClient.right, 1, DARK_GREEN); */
} }
} }
/* /*
* Draw the vertical bars * Draw the vertical bars
*/ */
for (i=11; i<rcClient.right + offset; i++) for (i=11; i<rcClient.right + offset; i++)
{ {
if ((i % 11) == 0) if ((i % 11) == 0)
{ {
/* FillSolidRect2(hDC, i - offset, 0, 1, rcClient.bottom, DARK_GREEN); */ /* FillSolidRect2(hDC, i - offset, 0, 1, rcClient.bottom, DARK_GREEN); */
} }
} }
/* /*
* Draw the memory usage * Draw the memory usage
*/ */
for (i=rcClient.right; i>=0; i--) for (i=rcClient.right; i>=0; i--)
{ {
} }
} }

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -73,55 +73,55 @@ static void GraphCtrl_Init(TGraphCtrl* this)
this->m_dPreviousPosition[2] = 0.0; this->m_dPreviousPosition[2] = 0.0;
this->m_dPreviousPosition[3] = 0.0; this->m_dPreviousPosition[3] = 0.0;
// public variable for the number of decimal places on the y axis /* public variable for the number of decimal places on the y axis */
this->m_nYDecimals = 3; this->m_nYDecimals = 3;
// set some initial values for the scaling until "SetRange" is called. /* set some initial values for the scaling until "SetRange" is called.
// these are protected varaibles and must be set with SetRange * these are protected varaibles and must be set with SetRange
// in order to ensure that m_dRange is updated accordingly * in order to ensure that m_dRange is updated accordingly
// m_dLowerLimit = -10.0; */
// m_dUpperLimit = 10.0; /* m_dLowerLimit = -10.0; */
/* m_dUpperLimit = 10.0; */
this->m_dLowerLimit = 0.0; this->m_dLowerLimit = 0.0;
this->m_dUpperLimit = 100.0; this->m_dUpperLimit = 100.0;
this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit; // protected member variable this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit; /* protected member variable */
// m_nShiftPixels determines how much the plot shifts (in terms of pixels) /* m_nShiftPixels determines how much the plot shifts (in terms of pixels) */
// with the addition of a new data point /* with the addition of a new data point */
this->m_nShiftPixels = 4; this->m_nShiftPixels = 4;
this->m_nHalfShiftPixels = this->m_nShiftPixels/2; // protected this->m_nHalfShiftPixels = this->m_nShiftPixels/2; /* protected */
this->m_nPlotShiftPixels = this->m_nShiftPixels + this->m_nHalfShiftPixels; // protected this->m_nPlotShiftPixels = this->m_nShiftPixels + this->m_nHalfShiftPixels; /* protected */
// background, grid and data colors /* background, grid and data colors */
// these are public variables and can be set directly /* these are public variables and can be set directly */
this->m_crBackColor = RGB( 0, 0, 0); // see also SetBackgroundColor this->m_crBackColor = RGB( 0, 0, 0); /* see also SetBackgroundColor */
this->m_crGridColor = RGB( 0, 255, 255); // see also SetGridColor this->m_crGridColor = RGB( 0, 255, 255); /* see also SetGridColor */
this->m_crPlotColor[0] = RGB(255, 255, 255); // see also SetPlotColor this->m_crPlotColor[0] = RGB(255, 255, 255); /* see also SetPlotColor */
this->m_crPlotColor[1] = RGB(100, 255, 255); // see also SetPlotColor this->m_crPlotColor[1] = RGB(100, 255, 255); /* see also SetPlotColor */
this->m_crPlotColor[2] = RGB(255, 100, 255); // see also SetPlotColor this->m_crPlotColor[2] = RGB(255, 100, 255); /* see also SetPlotColor */
this->m_crPlotColor[3] = RGB(255, 255, 100); // see also SetPlotColor this->m_crPlotColor[3] = RGB(255, 255, 100); /* see also SetPlotColor */
// protected variables /* protected variables */
for (i = 0; i < MAX_PLOTS; i++) for (i = 0; i < MAX_PLOTS; i++)
{ {
this->m_penPlot[i] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[i]); this->m_penPlot[i] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[i]);
} }
this->m_brushBack = CreateSolidBrush(this->m_crBackColor); this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
// public member variables, can be set directly /* public member variables, can be set directly */
strcpy(this->m_strXUnitsString, "Samples"); // can also be set with SetXUnits strcpy(this->m_strXUnitsString, "Samples"); /* can also be set with SetXUnits */
strcpy(this->m_strYUnitsString, "Y units"); // can also be set with SetYUnits strcpy(this->m_strYUnitsString, "Y units"); /* can also be set with SetYUnits */
// protected bitmaps to restore the memory DC's /* protected bitmaps to restore the memory DC's */
this->m_bitmapOldGrid = NULL; this->m_bitmapOldGrid = NULL;
this->m_bitmapOldPlot = NULL; this->m_bitmapOldPlot = NULL;
} }
#if 0 #if 0
/////////////////////////////////////////////////////////////////////////////
TGraphCtrl::~TGraphCtrl() TGraphCtrl::~TGraphCtrl()
{ {
// just to be picky restore the bitmaps for the two memory dc's /* just to be picky restore the bitmaps for the two memory dc's */
// (these dc's are being destroyed so there shouldn't be any leaks) /* (these dc's are being destroyed so there shouldn't be any leaks) */
if (m_bitmapOldGrid != NULL) SelectObject(m_dcGrid, m_bitmapOldGrid); if (m_bitmapOldGrid != NULL) SelectObject(m_dcGrid, m_bitmapOldGrid);
if (m_bitmapOldPlot != NULL) SelectObject(m_dcPlot, m_bitmapOldPlot); if (m_bitmapOldPlot != NULL) SelectObject(m_dcPlot, m_bitmapOldPlot);
if (m_bitmapGrid != NULL) DeleteObject(m_bitmapGrid); if (m_bitmapGrid != NULL) DeleteObject(m_bitmapGrid);
@ -132,7 +132,6 @@ TGraphCtrl::~TGraphCtrl()
} }
#endif #endif
/////////////////////////////////////////////////////////////////////////////
BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID) BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
{ {
BOOL result = 0; BOOL result = 0;
@ -146,85 +145,78 @@ BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
return result; return result;
} }
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces) void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces)
{ {
//ASSERT(dUpper > dLower); /* ASSERT(dUpper > dLower); */
this->m_dLowerLimit = dLower; this->m_dLowerLimit = dLower;
this->m_dUpperLimit = dUpper; this->m_dUpperLimit = dUpper;
this->m_nYDecimals = nDecimalPlaces; this->m_nYDecimals = nDecimalPlaces;
this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit; this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit;
this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange; this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
// clear out the existing garbage, re-start with a clean plot /* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this); GraphCtrl_InvalidateCtrl(this);
} }
#if 0 #if 0
/////////////////////////////////////////////////////////////////////////////
void TGraphCtrl::SetXUnits(const char* string) void TGraphCtrl::SetXUnits(const char* string)
{ {
strncpy(m_strXUnitsString, string, sizeof(m_strXUnitsString) - 1); strncpy(m_strXUnitsString, string, sizeof(m_strXUnitsString) - 1);
// clear out the existing garbage, re-start with a clean plot /* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl(); InvalidateCtrl();
} }
/////////////////////////////////////////////////////////////////////////////
void TGraphCtrl::SetYUnits(const char* string) void TGraphCtrl::SetYUnits(const char* string)
{ {
strncpy(m_strYUnitsString, string, sizeof(m_strYUnitsString) - 1); strncpy(m_strYUnitsString, string, sizeof(m_strYUnitsString) - 1);
// clear out the existing garbage, re-start with a clean plot /* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl(); InvalidateCtrl();
} }
#endif #endif
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color) void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color)
{ {
this->m_crGridColor = color; this->m_crGridColor = color;
// clear out the existing garbage, re-start with a clean plot /* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this); GraphCtrl_InvalidateCtrl(this);
} }
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF color) void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF color)
{ {
this->m_crPlotColor[plot] = color; this->m_crPlotColor[plot] = color;
DeleteObject(this->m_penPlot[plot]); DeleteObject(this->m_penPlot[plot]);
this->m_penPlot[plot] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[plot]); this->m_penPlot[plot] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[plot]);
// clear out the existing garbage, re-start with a clean plot /* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this); GraphCtrl_InvalidateCtrl(this);
} }
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF color) void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF color)
{ {
this->m_crBackColor = color; this->m_crBackColor = color;
DeleteObject(this->m_brushBack); DeleteObject(this->m_brushBack);
this->m_brushBack = CreateSolidBrush(this->m_crBackColor); this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
// clear out the existing garbage, re-start with a clean plot /* clear out the existing garbage, re-start with a clean plot */
GraphCtrl_InvalidateCtrl(this); GraphCtrl_InvalidateCtrl(this);
} }
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_InvalidateCtrl(TGraphCtrl* this) void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
{ {
// There is a lot of drawing going on here - particularly in terms of /* There is a lot of drawing going on here - particularly in terms of */
// drawing the grid. Don't panic, this is all being drawn (only once) /* drawing the grid. Don't panic, this is all being drawn (only once) */
// to a bitmap. The result is then BitBlt'd to the control whenever needed. /* to a bitmap. The result is then BitBlt'd to the control whenever needed. */
int i, j; int i, j;
int nCharacters; int nCharacters;
int nTopGridPix, nMidGridPix, nBottomGridPix; int nTopGridPix, nMidGridPix, nBottomGridPix;
HPEN oldPen; HPEN oldPen;
HPEN solidPen = CreatePen(PS_SOLID, 0, this->m_crGridColor); HPEN solidPen = CreatePen(PS_SOLID, 0, this->m_crGridColor);
//HFONT axisFont, yUnitFont, oldFont; /* HFONT axisFont, yUnitFont, oldFont; */
//char strTemp[50]; /* char strTemp[50]; */
// in case we haven't established the memory dc's /* in case we haven't established the memory dc's */
//CClientDC dc(this); /* CClientDC dc(this); */
HDC dc = GetDC(this->m_hParentWnd); HDC dc = GetDC(this->m_hParentWnd);
// if we don't have one yet, set up a memory dc for the grid /* if we don't have one yet, set up a memory dc for the grid */
if (this->m_dcGrid == NULL) if (this->m_dcGrid == NULL)
{ {
this->m_dcGrid = CreateCompatibleDC(dc); this->m_dcGrid = CreateCompatibleDC(dc);
@ -234,37 +226,38 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
SetBkColor(this->m_dcGrid, this->m_crBackColor); SetBkColor(this->m_dcGrid, this->m_crBackColor);
// fill the grid background /* fill the grid background */
FillRect(this->m_dcGrid, &this->m_rectClient, this->m_brushBack); FillRect(this->m_dcGrid, &this->m_rectClient, this->m_brushBack);
// draw the plot rectangle: /* draw the plot rectangle: */
// determine how wide the y axis scaling values are /* determine how wide the y axis scaling values are */
nCharacters = abs((int)log10(fabs(this->m_dUpperLimit))); nCharacters = abs((int)log10(fabs(this->m_dUpperLimit)));
nCharacters = max(nCharacters, abs((int)log10(fabs(this->m_dLowerLimit)))); nCharacters = max(nCharacters, abs((int)log10(fabs(this->m_dLowerLimit))));
// add the units digit, decimal point and a minus sign, and an extra space /* add the units digit, decimal point and a minus sign, and an extra space */
// as well as the number of decimal places to display /* as well as the number of decimal places to display */
nCharacters = nCharacters + 4 + this->m_nYDecimals; nCharacters = nCharacters + 4 + this->m_nYDecimals;
// adjust the plot rectangle dimensions /* adjust the plot rectangle dimensions */
// assume 6 pixels per character (this may need to be adjusted) /* assume 6 pixels per character (this may need to be adjusted) */
// m_rectPlot.left = m_rectClient.left + 6*(nCharacters); /* m_rectPlot.left = m_rectClient.left + 6*(nCharacters); */
this->m_rectPlot.left = this->m_rectClient.left; this->m_rectPlot.left = this->m_rectClient.left;
this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;//m_rectPlot.Width(); this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
// draw the plot rectangle /* draw the plot rectangle */
oldPen = (HPEN)SelectObject(this->m_dcGrid, solidPen); oldPen = (HPEN)SelectObject(this->m_dcGrid, solidPen);
MoveToEx(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.top, NULL); MoveToEx(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.top, NULL);
LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.top); LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.top);
LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.bottom+1); LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.bottom+1);
LineTo(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.bottom+1); LineTo(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.bottom+1);
// LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top); /* LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top); */
SelectObject(this->m_dcGrid, oldPen); SelectObject(this->m_dcGrid, oldPen);
DeleteObject(solidPen); DeleteObject(solidPen);
// draw the dotted lines, /* draw the dotted lines,
// use SetPixel instead of a dotted pen - this allows for a * use SetPixel instead of a dotted pen - this allows for a
// finer dotted line and a more "technical" look * finer dotted line and a more "technical" look
*/
nMidGridPix = (this->m_rectPlot.top + this->m_rectPlot.bottom)/2; nMidGridPix = (this->m_rectPlot.top + this->m_rectPlot.bottom)/2;
nTopGridPix = nMidGridPix - this->m_nPlotHeight/4; nTopGridPix = nMidGridPix - this->m_nPlotHeight/4;
nBottomGridPix = nMidGridPix + this->m_nPlotHeight/4; nBottomGridPix = nMidGridPix + this->m_nPlotHeight/4;
@ -281,15 +274,15 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
for (j=this->m_rectPlot.top; j<this->m_rectPlot.bottom; j+=2) for (j=this->m_rectPlot.top; j<this->m_rectPlot.bottom; j+=2)
{ {
SetPixel(this->m_dcGrid, i, j, this->m_crGridColor); SetPixel(this->m_dcGrid, i, j, this->m_crGridColor);
// SetPixel(m_dcGrid, i, j, m_crGridColor); /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
// SetPixel(m_dcGrid, i, j, m_crGridColor); /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
} }
} }
#if 0 #if 0
// create some fonts (horizontal and vertical) /* create some fonts (horizontal and vertical) */
// use a height of 14 pixels and 300 weight /* use a height of 14 pixels and 300 weight */
// (these may need to be adjusted depending on the display) /* (these may need to be adjusted depending on the display) */
axisFont = CreateFont (14, 0, 0, 0, 300, axisFont = CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET, FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS,
@ -303,48 +296,48 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
DEFAULT_QUALITY, DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Arial"); DEFAULT_PITCH|FF_SWISS, "Arial");
// grab the horizontal font /* grab the horizontal font */
oldFont = (HFONT)SelectObject(m_dcGrid, axisFont); oldFont = (HFONT)SelectObject(m_dcGrid, axisFont);
// y max /* y max */
SetTextColor(m_dcGrid, m_crGridColor); SetTextColor(m_dcGrid, m_crGridColor);
SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP); SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
sprintf(strTemp, "%.*lf", m_nYDecimals, m_dUpperLimit); sprintf(strTemp, "%.*lf", m_nYDecimals, m_dUpperLimit);
TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.top, strTemp, _tcslen(strTemp)); TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.top, strTemp, _tcslen(strTemp));
// y min /* y min */
SetTextAlign(m_dcGrid, TA_RIGHT|TA_BASELINE); SetTextAlign(m_dcGrid, TA_RIGHT|TA_BASELINE);
sprintf(strTemp, "%.*lf", m_nYDecimals, m_dLowerLimit); sprintf(strTemp, "%.*lf", m_nYDecimals, m_dLowerLimit);
TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.bottom, strTemp, _tcslen(strTemp)); TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.bottom, strTemp, _tcslen(strTemp));
// x min /* x min */
SetTextAlign(m_dcGrid, TA_LEFT|TA_TOP); SetTextAlign(m_dcGrid, TA_LEFT|TA_TOP);
TextOut(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+4, "0", 1); TextOut(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+4, "0", 1);
// x max /* x max */
SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP); SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
sprintf(strTemp, "%d", m_nPlotWidth/m_nShiftPixels); sprintf(strTemp, "%d", m_nPlotWidth/m_nShiftPixels);
TextOut(m_dcGrid, m_rectPlot.right, m_rectPlot.bottom+4, strTemp, _tcslen(strTemp)); TextOut(m_dcGrid, m_rectPlot.right, m_rectPlot.bottom+4, strTemp, _tcslen(strTemp));
// x units /* x units */
SetTextAlign(m_dcGrid, TA_CENTER|TA_TOP); SetTextAlign(m_dcGrid, TA_CENTER|TA_TOP);
TextOut(m_dcGrid, (m_rectPlot.left+m_rectPlot.right)/2, TextOut(m_dcGrid, (m_rectPlot.left+m_rectPlot.right)/2,
m_rectPlot.bottom+4, m_strXUnitsString, _tcslen(m_strXUnitsString)); m_rectPlot.bottom+4, m_strXUnitsString, _tcslen(m_strXUnitsString));
// restore the font /* restore the font */
SelectObject(m_dcGrid, oldFont); SelectObject(m_dcGrid, oldFont);
// y units /* y units */
oldFont = (HFONT)SelectObject(m_dcGrid, yUnitFont); oldFont = (HFONT)SelectObject(m_dcGrid, yUnitFont);
SetTextAlign(m_dcGrid, TA_CENTER|TA_BASELINE); SetTextAlign(m_dcGrid, TA_CENTER|TA_BASELINE);
TextOut(m_dcGrid, (m_rectClient.left+m_rectPlot.left)/2, TextOut(m_dcGrid, (m_rectClient.left+m_rectPlot.left)/2,
(m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString, _tcslen(m_strYUnitsString)); (m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString, _tcslen(m_strYUnitsString));
SelectObject(m_dcGrid, oldFont); SelectObject(m_dcGrid, oldFont);
#endif #endif
// at this point we are done filling the the grid bitmap, /* at this point we are done filling the the grid bitmap, */
// no more drawing to this bitmap is needed until the setting are changed /* no more drawing to this bitmap is needed until the setting are changed */
// if we don't have one yet, set up a memory dc for the plot /* if we don't have one yet, set up a memory dc for the plot */
if (this->m_dcPlot == NULL) if (this->m_dcPlot == NULL)
{ {
this->m_dcPlot = CreateCompatibleDC(dc); this->m_dcPlot = CreateCompatibleDC(dc);
@ -352,21 +345,20 @@ void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
this->m_bitmapOldPlot = (HBITMAP)SelectObject(this->m_dcPlot, this->m_bitmapPlot); this->m_bitmapOldPlot = (HBITMAP)SelectObject(this->m_dcPlot, this->m_bitmapPlot);
} }
// make sure the plot bitmap is cleared /* make sure the plot bitmap is cleared */
SetBkColor(this->m_dcPlot, this->m_crBackColor); SetBkColor(this->m_dcPlot, this->m_crBackColor);
FillRect(this->m_dcPlot, &this->m_rectClient, this->m_brushBack); FillRect(this->m_dcPlot, &this->m_rectClient, this->m_brushBack);
// finally, force the plot area to redraw /* finally, force the plot area to redraw */
InvalidateRect(this->m_hParentWnd, &this->m_rectClient, TRUE); InvalidateRect(this->m_hParentWnd, &this->m_rectClient, TRUE);
ReleaseDC(this->m_hParentWnd, dc); ReleaseDC(this->m_hParentWnd, dc);
} }
/////////////////////////////////////////////////////////////////////////////
double GraphCtrl_AppendPoint(TGraphCtrl* this, double GraphCtrl_AppendPoint(TGraphCtrl* this,
double dNewPoint0, double dNewPoint1, double dNewPoint0, double dNewPoint1,
double dNewPoint2, double dNewPoint3) double dNewPoint2, double dNewPoint3)
{ {
// append a data point to the plot & return the previous point /* append a data point to the plot & return the previous point */
double dPrevious; double dPrevious;
dPrevious = this->m_dCurrentPosition[0]; dPrevious = this->m_dCurrentPosition[0];
@ -375,40 +367,39 @@ double GraphCtrl_AppendPoint(TGraphCtrl* this,
this->m_dCurrentPosition[2] = dNewPoint2; this->m_dCurrentPosition[2] = dNewPoint2;
this->m_dCurrentPosition[3] = dNewPoint3; this->m_dCurrentPosition[3] = dNewPoint3;
GraphCtrl_DrawPoint(this); GraphCtrl_DrawPoint(this);
//Invalidate(); /* Invalidate(); */
return dPrevious; return dPrevious;
} }
////////////////////////////////////////////////////////////////////////////
void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc) void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc)
{ {
HDC memDC; HDC memDC;
HBITMAP memBitmap; HBITMAP memBitmap;
HBITMAP oldBitmap; // bitmap originally found in CMemDC HBITMAP oldBitmap; /* bitmap originally found in CMemDC */
// RECT rcClient; /* RECT rcClient; */
// GetClientRect(hWnd, &rcClient); /* GetClientRect(hWnd, &rcClient); */
// FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); /* FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); */
// m_nClientWidth = rcClient.right - rcClient.left; /* m_nClientWidth = rcClient.right - rcClient.left; */
// m_nClientHeight = rcClient.bottom - rcClient.top; /* m_nClientHeight = rcClient.bottom - rcClient.top; */
// no real plotting work is performed here, /* no real plotting work is performed here, */
// just putting the existing bitmaps on the client /* just putting the existing bitmaps on the client */
// to avoid flicker, establish a memory dc, draw to it /* to avoid flicker, establish a memory dc, draw to it */
// and then BitBlt it to the client /* and then BitBlt it to the client */
memDC = CreateCompatibleDC(dc); memDC = CreateCompatibleDC(dc);
memBitmap = (HBITMAP)CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight); memBitmap = (HBITMAP)CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
oldBitmap = (HBITMAP)SelectObject(memDC, memBitmap); oldBitmap = (HBITMAP)SelectObject(memDC, memBitmap);
if (memDC != NULL) if (memDC != NULL)
{ {
// first drop the grid on the memory dc /* first drop the grid on the memory dc */
BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcGrid, 0, 0, SRCCOPY); BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcGrid, 0, 0, SRCCOPY);
// now add the plot on top as a "pattern" via SRCPAINT. /* now add the plot on top as a "pattern" via SRCPAINT. */
// works well with dark background and a light plot /* works well with dark background and a light plot */
BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcPlot, 0, 0, SRCPAINT); //SRCPAINT BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcPlot, 0, 0, SRCPAINT); /* SRCPAINT */
// finally send the result to the display /* finally send the result to the display */
BitBlt(dc, 0, 0, this->m_nClientWidth, this->m_nClientHeight, memDC, 0, 0, SRCCOPY); BitBlt(dc, 0, 0, this->m_nClientWidth, this->m_nClientHeight, memDC, 0, 0, SRCCOPY);
} }
SelectObject(memDC, oldBitmap); SelectObject(memDC, oldBitmap);
@ -416,14 +407,13 @@ void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc)
DeleteDC(memDC); DeleteDC(memDC);
} }
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_DrawPoint(TGraphCtrl* this) void GraphCtrl_DrawPoint(TGraphCtrl* this)
{ {
// this does the work of "scrolling" the plot to the left /* this does the work of "scrolling" the plot to the left
// and appending a new data point all of the plotting is * and appending a new data point all of the plotting is
// directed to the memory based bitmap associated with m_dcPlot * directed to the memory based bitmap associated with m_dcPlot
// the will subsequently be BitBlt'd to the client in Paint * the will subsequently be BitBlt'd to the client in Paint
*/
int currX, prevX, currY, prevY; int currX, prevX, currY, prevY;
HPEN oldPen; HPEN oldPen;
RECT rectCleanUp; RECT rectCleanUp;
@ -431,52 +421,52 @@ void GraphCtrl_DrawPoint(TGraphCtrl* this)
if (this->m_dcPlot != NULL) if (this->m_dcPlot != NULL)
{ {
// shift the plot by BitBlt'ing it to itself /* shift the plot by BitBlt'ing it to itself
// note: the m_dcPlot covers the entire client * note: the m_dcPlot covers the entire client
// but we only shift bitmap that is the size * but we only shift bitmap that is the size
// of the plot rectangle * of the plot rectangle
// grab the right side of the plot (exluding m_nShiftPixels on the left) * grab the right side of the plot (exluding m_nShiftPixels on the left)
// move this grabbed bitmap to the left by m_nShiftPixels * move this grabbed bitmap to the left by m_nShiftPixels
*/
BitBlt(this->m_dcPlot, this->m_rectPlot.left, this->m_rectPlot.top+1, BitBlt(this->m_dcPlot, this->m_rectPlot.left, this->m_rectPlot.top+1,
this->m_nPlotWidth, this->m_nPlotHeight, this->m_dcPlot, this->m_nPlotWidth, this->m_nPlotHeight, this->m_dcPlot,
this->m_rectPlot.left+this->m_nShiftPixels, this->m_rectPlot.top+1, this->m_rectPlot.left+this->m_nShiftPixels, this->m_rectPlot.top+1,
SRCCOPY); SRCCOPY);
// establish a rectangle over the right side of plot /* establish a rectangle over the right side of plot */
// which now needs to be cleaned up proir to adding the new point /* which now needs to be cleaned up proir to adding the new point */
rectCleanUp = this->m_rectPlot; rectCleanUp = this->m_rectPlot;
rectCleanUp.left = rectCleanUp.right - this->m_nShiftPixels; rectCleanUp.left = rectCleanUp.right - this->m_nShiftPixels;
// fill the cleanup area with the background /* fill the cleanup area with the background */
FillRect(this->m_dcPlot, &rectCleanUp, this->m_brushBack); FillRect(this->m_dcPlot, &rectCleanUp, this->m_brushBack);
// draw the next line segement /* draw the next line segement */
for (i = 0; i < MAX_PLOTS; i++) for (i = 0; i < MAX_PLOTS; i++)
{ {
// grab the plotting pen /* grab the plotting pen */
oldPen = (HPEN)SelectObject(this->m_dcPlot, this->m_penPlot[i]); oldPen = (HPEN)SelectObject(this->m_dcPlot, this->m_penPlot[i]);
// move to the previous point /* move to the previous point */
prevX = this->m_rectPlot.right-this->m_nPlotShiftPixels; prevX = this->m_rectPlot.right-this->m_nPlotShiftPixels;
prevY = this->m_rectPlot.bottom - prevY = this->m_rectPlot.bottom -
(long)((this->m_dPreviousPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor); (long)((this->m_dPreviousPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor);
MoveToEx(this->m_dcPlot, prevX, prevY, NULL); MoveToEx(this->m_dcPlot, prevX, prevY, NULL);
// draw to the current point /* draw to the current point */
currX = this->m_rectPlot.right-this->m_nHalfShiftPixels; currX = this->m_rectPlot.right-this->m_nHalfShiftPixels;
currY = this->m_rectPlot.bottom - currY = this->m_rectPlot.bottom -
(long)((this->m_dCurrentPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor); (long)((this->m_dCurrentPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor);
LineTo(this->m_dcPlot, currX, currY); LineTo(this->m_dcPlot, currX, currY);
// Restore the pen /* Restore the pen */
SelectObject(this->m_dcPlot, oldPen); SelectObject(this->m_dcPlot, oldPen);
// if the data leaks over the upper or lower plot boundaries /* if the data leaks over the upper or lower plot boundaries
// fill the upper and lower leakage with the background * fill the upper and lower leakage with the background
// this will facilitate clipping on an as needed basis * this will facilitate clipping on an as needed basis
// as opposed to always calling IntersectClipRect * as opposed to always calling IntersectClipRect
*/
if ((prevY <= this->m_rectPlot.top) || (currY <= this->m_rectPlot.top)) if ((prevY <= this->m_rectPlot.top) || (currY <= this->m_rectPlot.top))
{ {
RECT rc; RECT rc;
@ -493,28 +483,27 @@ void GraphCtrl_DrawPoint(TGraphCtrl* this)
rc.left = prevX; rc.left = prevX;
rc.right = currX+1; rc.right = currX+1;
rc.top = this->m_rectPlot.bottom+1; rc.top = this->m_rectPlot.bottom+1;
//RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1); /* RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1); */
FillRect(this->m_dcPlot, &rc, this->m_brushBack); FillRect(this->m_dcPlot, &rc, this->m_brushBack);
} }
// store the current point for connection to the next point /* store the current point for connection to the next point */
this->m_dPreviousPosition[i] = this->m_dCurrentPosition[i]; this->m_dPreviousPosition[i] = this->m_dCurrentPosition[i];
} }
} }
} }
/////////////////////////////////////////////////////////////////////////////
void GraphCtrl_Resize(TGraphCtrl* this) void GraphCtrl_Resize(TGraphCtrl* this)
{ {
// NOTE: Resize automatically gets called during the setup of the control /* NOTE: Resize automatically gets called during the setup of the control */
GetClientRect(this->m_hWnd, &this->m_rectClient); GetClientRect(this->m_hWnd, &this->m_rectClient);
// set some member variables to avoid multiple function calls /* set some member variables to avoid multiple function calls */
this->m_nClientHeight = this->m_rectClient.bottom - this->m_rectClient.top;//m_rectClient.Height(); this->m_nClientHeight = this->m_rectClient.bottom - this->m_rectClient.top;/* m_rectClient.Height(); */
this->m_nClientWidth = this->m_rectClient.right - this->m_rectClient.left;//m_rectClient.Width(); this->m_nClientWidth = this->m_rectClient.right - this->m_rectClient.left;/* m_rectClient.Width(); */
// the "left" coordinate and "width" will be modified in /* the "left" coordinate and "width" will be modified in */
// InvalidateCtrl to be based on the width of the y axis scaling /* InvalidateCtrl to be based on the width of the y axis scaling */
#if 0 #if 0
this->m_rectPlot.left = 20; this->m_rectPlot.left = 20;
this->m_rectPlot.top = 10; this->m_rectPlot.top = 10;
@ -527,21 +516,20 @@ void GraphCtrl_Resize(TGraphCtrl* this)
this->m_rectPlot.bottom = this->m_rectClient.bottom-0; this->m_rectPlot.bottom = this->m_rectClient.bottom-0;
#endif #endif
// set some member variables to avoid multiple function calls /* set some member variables to avoid multiple function calls */
this->m_nPlotHeight = this->m_rectPlot.bottom - this->m_rectPlot.top;//m_rectPlot.Height(); this->m_nPlotHeight = this->m_rectPlot.bottom - this->m_rectPlot.top;/* m_rectPlot.Height(); */
this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;//m_rectPlot.Width(); this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
// set the scaling factor for now, this can be adjusted /* set the scaling factor for now, this can be adjusted */
// in the SetRange functions /* in the SetRange functions */
this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange; this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
} }
#if 0 #if 0
/////////////////////////////////////////////////////////////////////////////
void TGraphCtrl::Reset() void TGraphCtrl::Reset()
{ {
// to clear the existing data (in the form of a bitmap) /* to clear the existing data (in the form of a bitmap) */
// simply invalidate the entire control /* simply invalidate the entire control */
InvalidateCtrl(); InvalidateCtrl();
} }
#endif #endif
@ -553,18 +541,18 @@ extern HWND hPerformancePageMemUsageHistoryGraph;
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
RECT rcClient; RECT rcClient;
HDC hdc; HDC hdc;
PAINTSTRUCT ps; PAINTSTRUCT ps;
switch (message) switch (message)
{ {
case WM_ERASEBKGND: case WM_ERASEBKGND:
return TRUE; return TRUE;
// /*
// Filter out mouse & keyboard messages * Filter out mouse & keyboard messages
// */
//case WM_APPCOMMAND: /* case WM_APPCOMMAND: */
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
case WM_LBUTTONDBLCLK: case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
@ -576,7 +564,7 @@ LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
case WM_MOUSEHOVER: case WM_MOUSEHOVER:
case WM_MOUSELEAVE: case WM_MOUSELEAVE:
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
//case WM_MOUSEWHEEL: /* case WM_MOUSEWHEEL: */
case WM_NCHITTEST: case WM_NCHITTEST:
case WM_NCLBUTTONDBLCLK: case WM_NCLBUTTONDBLCLK:
case WM_NCLBUTTONDOWN: case WM_NCLBUTTONDOWN:
@ -584,21 +572,21 @@ LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
case WM_NCMBUTTONDBLCLK: case WM_NCMBUTTONDBLCLK:
case WM_NCMBUTTONDOWN: case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP: case WM_NCMBUTTONUP:
//case WM_NCMOUSEHOVER: /* case WM_NCMOUSEHOVER: */
//case WM_NCMOUSELEAVE: /* case WM_NCMOUSELEAVE: */
case WM_NCMOUSEMOVE: case WM_NCMOUSEMOVE:
case WM_NCRBUTTONDBLCLK: case WM_NCRBUTTONDBLCLK:
case WM_NCRBUTTONDOWN: case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP: case WM_NCRBUTTONUP:
//case WM_NCXBUTTONDBLCLK: /* case WM_NCXBUTTONDBLCLK: */
//case WM_NCXBUTTONDOWN: /* case WM_NCXBUTTONDOWN: */
//case WM_NCXBUTTONUP: /* case WM_NCXBUTTONUP: */
case WM_RBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONUP: case WM_RBUTTONUP:
//case WM_XBUTTONDBLCLK: /* case WM_XBUTTONDBLCLK: */
//case WM_XBUTTONDOWN: /* case WM_XBUTTONDOWN: */
//case WM_XBUTTONUP: /* case WM_XBUTTONUP: */
case WM_ACTIVATE: case WM_ACTIVATE:
case WM_CHAR: case WM_CHAR:
case WM_DEADCHAR: case WM_DEADCHAR:
@ -641,9 +629,9 @@ LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
return 0; return 0;
} }
// /*
// We pass on all non-handled messages * We pass on all non-handled messages
// */
return CallWindowProc((WNDPROC)OldGraphCtrlWndProc, hWnd, message, wParam, lParam); return CallWindowProc((WNDPROC)OldGraphCtrlWndProc, hWnd, message, wParam, lParam);
} }

View file

@ -19,14 +19,14 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* /*
* options.c * options.c
* *
* Menu item handlers for the options menu. * Menu item handlers for the options menu.
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -34,116 +34,116 @@
#include <memory.h> #include <memory.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "optnmenu.h" #include "optnmenu.h"
#include "procpage.h" #include "procpage.h"
#define OPTIONS_MENU_INDEX 1 #define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void) void TaskManager_OnOptionsAlwaysOnTop(void)
{ {
HMENU hMenu; HMENU hMenu;
HMENU hOptionsMenu; HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd); hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX); hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/* /*
* Check or uncheck the always on top menu item * Check or uncheck the always on top menu item
* and update main window. * and update main window.
*/ */
if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED) if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED)
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.AlwaysOnTop = FALSE; TaskManagerSettings.AlwaysOnTop = FALSE;
SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
} }
else else
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.AlwaysOnTop = TRUE; TaskManagerSettings.AlwaysOnTop = TRUE;
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
} }
} }
void TaskManager_OnOptionsMinimizeOnUse(void) void TaskManager_OnOptionsMinimizeOnUse(void)
{ {
HMENU hMenu; HMENU hMenu;
HMENU hOptionsMenu; HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd); hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX); hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/* /*
* Check or uncheck the minimize on use menu item. * Check or uncheck the minimize on use menu item.
*/ */
if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED) if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.MinimizeOnUse = FALSE; TaskManagerSettings.MinimizeOnUse = FALSE;
} }
else else
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.MinimizeOnUse = TRUE; TaskManagerSettings.MinimizeOnUse = TRUE;
} }
} }
void TaskManager_OnOptionsHideWhenMinimized(void) void TaskManager_OnOptionsHideWhenMinimized(void)
{ {
HMENU hMenu; HMENU hMenu;
HMENU hOptionsMenu; HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd); hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX); hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/* /*
* Check or uncheck the hide when minimized menu item. * Check or uncheck the hide when minimized menu item.
*/ */
if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED) if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.HideWhenMinimized = FALSE; TaskManagerSettings.HideWhenMinimized = FALSE;
} }
else else
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.HideWhenMinimized = TRUE; TaskManagerSettings.HideWhenMinimized = TRUE;
} }
} }
void TaskManager_OnOptionsShow16BitTasks(void) void TaskManager_OnOptionsShow16BitTasks(void)
{ {
HMENU hMenu; HMENU hMenu;
HMENU hOptionsMenu; HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd); hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX); hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/* /*
* FIXME: Currently this is useless because the * FIXME: Currently this is useless because the
* current implemetation doesn't list the 16-bit * current implemetation doesn't list the 16-bit
* processes. I believe that would require querying * processes. I believe that would require querying
* each ntvdm.exe process for it's children. * each ntvdm.exe process for it's children.
*/ */
/* /*
* Check or uncheck the show 16-bit tasks menu item * Check or uncheck the show 16-bit tasks menu item
*/ */
if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED) if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.Show16BitTasks = FALSE; TaskManagerSettings.Show16BitTasks = FALSE;
} }
else else
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.Show16BitTasks = TRUE; TaskManagerSettings.Show16BitTasks = TRUE;
} }
/* /*
* Refresh the list of processes. * Refresh the list of processes.
*/ */
RefreshProcessPage(); RefreshProcessPage();
} }

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -40,51 +40,42 @@
TGraphCtrl PerformancePageCpuUsageHistoryGraph; TGraphCtrl PerformancePageCpuUsageHistoryGraph;
TGraphCtrl PerformancePageMemUsageHistoryGraph; TGraphCtrl PerformancePageMemUsageHistoryGraph;
HWND hPerformancePage; // Performance Property Page HWND hPerformancePage; /* Performance Property Page */
HWND hPerformancePageCpuUsageGraph; /* CPU Usage Graph */
HWND hPerformancePageCpuUsageGraph; // CPU Usage Graph HWND hPerformancePageMemUsageGraph; /* MEM Usage Graph */
HWND hPerformancePageMemUsageGraph; // 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 */
HWND hPerformancePageCommitChargeFrame; /* Commit Charge Frame */
HWND hPerformancePageTotalsFrame; // Totals Frame HWND hPerformancePageKernelMemoryFrame; /* Kernel Memory Frame */
HWND hPerformancePageCommitChargeFrame; // Commit Charge Frame HWND hPerformancePagePhysicalMemoryFrame; /* Physical Memory Frame */
HWND hPerformancePageKernelMemoryFrame; // Kernel Memory Frame
HWND hPerformancePagePhysicalMemoryFrame; // Physical Memory Frame
HWND hPerformancePageCpuUsageFrame; HWND hPerformancePageCpuUsageFrame;
HWND hPerformancePageMemUsageFrame; HWND hPerformancePageMemUsageFrame;
HWND hPerformancePageCpuUsageHistoryFrame; HWND hPerformancePageCpuUsageHistoryFrame;
HWND hPerformancePageMemUsageHistoryFrame; HWND hPerformancePageMemUsageHistoryFrame;
HWND hPerformancePageCommitChargeTotalEdit; /* Commit Charge Total Edit Control */
HWND hPerformancePageCommitChargeTotalEdit; // Commit Charge Total Edit Control HWND hPerformancePageCommitChargeLimitEdit; /* Commit Charge Limit Edit Control */
HWND hPerformancePageCommitChargeLimitEdit; // Commit Charge Limit Edit Control HWND hPerformancePageCommitChargePeakEdit; /* Commit Charge Peak Edit Control */
HWND hPerformancePageCommitChargePeakEdit; // Commit Charge Peak Edit Control HWND hPerformancePageKernelMemoryTotalEdit; /* Kernel Memory Total Edit Control */
HWND hPerformancePageKernelMemoryPagedEdit; /* Kernel Memory Paged Edit Control */
HWND hPerformancePageKernelMemoryTotalEdit; // Kernel Memory Total Edit Control HWND hPerformancePageKernelMemoryNonPagedEdit; /* Kernel Memory NonPaged Edit Control */
HWND hPerformancePageKernelMemoryPagedEdit; // Kernel Memory Paged Edit Control HWND hPerformancePagePhysicalMemoryTotalEdit; /* Physical Memory Total Edit Control */
HWND hPerformancePageKernelMemoryNonPagedEdit; // Kernel Memory NonPaged Edit Control HWND hPerformancePagePhysicalMemoryAvailableEdit; /* Physical Memory Available Edit Control */
HWND hPerformancePagePhysicalMemorySystemCacheEdit; /* Physical Memory System Cache Edit Control */
HWND hPerformancePagePhysicalMemoryTotalEdit; // Physical Memory Total Edit Control HWND hPerformancePageTotalsHandleCountEdit; /* Total Handles Edit Control */
HWND hPerformancePagePhysicalMemoryAvailableEdit; // Physical Memory Available Edit Control HWND hPerformancePageTotalsProcessCountEdit; /* Total Processes Edit Control */
HWND hPerformancePagePhysicalMemorySystemCacheEdit; // Physical Memory System Cache Edit Control HWND hPerformancePageTotalsThreadCountEdit; /* Total Threads Edit Control */
HWND hPerformancePageTotalsHandleCountEdit; // Total Handles Edit Control
HWND hPerformancePageTotalsProcessCountEdit; // Total Processes Edit Control
HWND hPerformancePageTotalsThreadCountEdit; // Total Threads Edit Control
static int nPerformancePageWidth; static int nPerformancePageWidth;
static int nPerformancePageHeight; static int nPerformancePageHeight;
static HANDLE hPerformancePageEvent = NULL; /* When this event becomes signaled then we refresh the performance page */
static HANDLE hPerformancePageEvent = NULL; // When this event becomes signaled then we refresh the performance page
DWORD WINAPI PerformancePageRefreshThread(void *lpParameter); DWORD WINAPI PerformancePageRefreshThread(void *lpParameter);
void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos) void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
{ {
RECT rc; RECT rc;
int cx, cy, sx, sy; int cx, cy, sx, sy;
GetClientRect(hCntrl, &rc); GetClientRect(hCntrl, &rc);
MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT))); MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)));
@ -133,23 +124,23 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
int nXDifference; int nXDifference;
int nYDifference; int nYDifference;
// HDC hdc; /* HDC hdc; */
// PAINTSTRUCT ps; /* PAINTSTRUCT ps; */
switch (message) { switch (message) {
case WM_INITDIALOG: case WM_INITDIALOG:
// Save the width and height /* Save the width and height */
GetClientRect(hDlg, &rc); GetClientRect(hDlg, &rc);
nPerformancePageWidth = rc.right; nPerformancePageWidth = rc.right;
nPerformancePageHeight = rc.bottom; nPerformancePageHeight = rc.bottom;
// Update window position /* Update window position */
SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
// /*
// Get handles to all the controls * Get handles to all the controls
// */
hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME); hPerformancePageTotalsFrame = GetDlgItem(hDlg, IDC_TOTALS_FRAME);
hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME); hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME); hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
@ -179,16 +170,16 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc); GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc);
// create the control /* create the control */
//PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); /* PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); */
GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH); GraphCtrl_Create(&PerformancePageCpuUsageHistoryGraph, hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
// customize the control /* customize the control */
GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10); GraphCtrl_SetRange(&PerformancePageCpuUsageHistoryGraph, 0.0, 100.0, 10);
// PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; /* PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ; */
// PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; /* PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ; */
// PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; /* PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ; */
// PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; /* PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ; */
// PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; /* PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ; */
GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ; GraphCtrl_SetBackgroundColor(&PerformancePageCpuUsageHistoryGraph, RGB(0, 0, 0)) ;
GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ; GraphCtrl_SetGridColor(&PerformancePageCpuUsageHistoryGraph, RGB(152, 205, 152)) ;
GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ; GraphCtrl_SetPlotColor(&PerformancePageCpuUsageHistoryGraph, 0, RGB(255, 0, 0)) ;
@ -200,14 +191,14 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ; GraphCtrl_SetBackgroundColor(&PerformancePageMemUsageHistoryGraph, RGB(0, 0, 0)) ;
GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(152, 215, 152)) ; GraphCtrl_SetGridColor(&PerformancePageMemUsageHistoryGraph, RGB(152, 215, 152)) ;
GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ; GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
// Start our refresh thread /* Start our refresh thread */
#ifdef RUN_PERF_PAGE #ifdef RUN_PERF_PAGE
CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL); CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL);
#endif #endif
// /*
// Subclass graph buttons * Subclass graph buttons
// */
OldGraphWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc); OldGraphWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc); SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
OldGraphCtrlWndProc = SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc); OldGraphCtrlWndProc = SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
@ -246,7 +237,7 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
nPerformancePageHeight = cy; nPerformancePageHeight = cy;
} while (0); } while (0);
// Reposition the performance page's controls /* Reposition the performance page's controls */
AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPerformancePageTotalsFrame, hDlg, 0, nYDifference, 0);
AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPerformancePageCommitChargeFrame, hDlg, 0, nYDifference, 0);
AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0); AdjustFrameSize(hPerformancePageKernelMemoryFrame, hDlg, 0, nYDifference, 0);
@ -315,8 +306,8 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
void RefreshPerformancePage(void) void RefreshPerformancePage(void)
{ {
// 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 */
SetEvent(hPerformancePageEvent); SetEvent(hPerformancePageEvent);
} }
@ -340,10 +331,10 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
TCHAR Text[260]; TCHAR Text[260];
// Create the event /* Create the event */
hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, _T("Performance Page Event")); hPerformancePageEvent = CreateEvent(NULL, TRUE, TRUE, _T("Performance Page Event"));
// If we couldn't create the event then exit the thread /* If we couldn't create the event then exit the thread */
if (!hPerformancePageEvent) if (!hPerformancePageEvent)
return 0; return 0;
@ -351,22 +342,22 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
{ {
DWORD dwWaitVal; DWORD dwWaitVal;
// Wait on the event /* Wait on the event */
dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE); dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);
// If the wait failed then the event object must have been /* If the wait failed then the event object must have been */
// closed and the task manager is exiting so exit this thread /* closed and the task manager is exiting so exit this thread */
if (dwWaitVal == WAIT_FAILED) if (dwWaitVal == WAIT_FAILED)
return 0; return 0;
if (dwWaitVal == WAIT_OBJECT_0) if (dwWaitVal == WAIT_OBJECT_0)
{ {
// Reset our event /* Reset our event */
ResetEvent(hPerformancePageEvent); ResetEvent(hPerformancePageEvent);
// /*
// Update the commit charge info * Update the commit charge info
// */
CommitChargeTotal = PerfDataGetCommitChargeTotalK(); CommitChargeTotal = PerfDataGetCommitChargeTotalK();
CommitChargeLimit = PerfDataGetCommitChargeLimitK(); CommitChargeLimit = PerfDataGetCommitChargeLimitK();
CommitChargePeak = PerfDataGetCommitChargePeakK(); CommitChargePeak = PerfDataGetCommitChargePeakK();
@ -379,9 +370,9 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit); wsprintf(Text, _T("Mem Usage: %dK / %dK"), CommitChargeTotal, CommitChargeLimit);
SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text); SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text);
// /*
// Update the kernel memory info * Update the kernel memory info
// */
KernelMemoryTotal = PerfDataGetKernelMemoryTotalK(); KernelMemoryTotal = PerfDataGetKernelMemoryTotalK();
KernelMemoryPaged = PerfDataGetKernelMemoryPagedK(); KernelMemoryPaged = PerfDataGetKernelMemoryPagedK();
KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK(); KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK();
@ -392,9 +383,9 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
_ultot(KernelMemoryNonPaged, Text, 10); _ultot(KernelMemoryNonPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text); SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
// /*
// Update the physical memory info * Update the physical memory info
// */
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK(); PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK(); PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK(); PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK();
@ -405,9 +396,9 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
_ultot(PhysicalMemorySystemCache, Text, 10); _ultot(PhysicalMemorySystemCache, Text, 10);
SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text); SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
// /*
// Update the totals info * Update the totals info
// */
TotalHandles = PerfDataGetSystemHandleCount(); TotalHandles = PerfDataGetSystemHandleCount();
TotalThreads = PerfDataGetTotalThreadCount(); TotalThreads = PerfDataGetTotalThreadCount();
TotalProcesses = PerfDataGetProcessCount(); TotalProcesses = PerfDataGetProcessCount();
@ -418,13 +409,12 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
_ultot(TotalProcesses, Text, 10); _ultot(TotalProcesses, Text, 10);
SetWindowText(hPerformancePageTotalsProcessCountEdit, Text); SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
// /*
// Redraw the graphs * Redraw the graphs
// */
InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE); InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE); InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
//
ULONG CpuUsage; ULONG CpuUsage;
ULONG CpuKernelUsage; ULONG CpuKernelUsage;
@ -435,9 +425,9 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
int nBarsUsed1; int nBarsUsed1;
int nBarsUsed2; int nBarsUsed2;
// /*
// Get the CPU usage * Get the CPU usage
// */
CpuUsage = PerfDataGetProcessorUsage(); CpuUsage = PerfDataGetProcessorUsage();
CpuKernelUsage = PerfDataGetProcessorSystemUsage(); CpuKernelUsage = PerfDataGetProcessorSystemUsage();
if (CpuUsage < 0 ) CpuUsage = 0; if (CpuUsage < 0 ) CpuUsage = 0;
@ -445,9 +435,9 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
if (CpuKernelUsage < 0) CpuKernelUsage = 0; if (CpuKernelUsage < 0) CpuKernelUsage = 0;
if (CpuKernelUsage > 100) CpuKernelUsage = 100; if (CpuKernelUsage > 100) CpuKernelUsage = 100;
// /*
// Get the memory usage * Get the memory usage
// */
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK(); CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK(); CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0; nBarsUsed1 = CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0;
@ -459,7 +449,7 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0); GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0); GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
//PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE); InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE); InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
} }
@ -475,7 +465,7 @@ void PerformancePage_OnViewShowKernelTimes(void)
hMenu = GetMenu(hMainWnd); hMenu = GetMenu(hMainWnd);
hViewMenu = GetSubMenu(hMenu, 2); hViewMenu = GetSubMenu(hMenu, 2);
// Check or uncheck the show 16-bit tasks menu item /* Check or uncheck the show 16-bit tasks menu item */
if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED) if (GetMenuState(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND) & MF_CHECKED)
{ {
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,7 +29,7 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "priority.h" #include "priority.h"
#include "procpage.h" #include "procpage.h"
@ -37,288 +37,288 @@
void ProcessPage_OnSetPriorityRealTime(void) void ProcessPage_OnSetPriorityRealTime(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS)) if (!SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
void ProcessPage_OnSetPriorityHigh(void) void ProcessPage_OnSetPriorityHigh(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)) if (!SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
void ProcessPage_OnSetPriorityAboveNormal(void) void ProcessPage_OnSetPriorityAboveNormal(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!SetPriorityClass(hProcess, ABOVE_NORMAL_PRIORITY_CLASS)) if (!SetPriorityClass(hProcess, ABOVE_NORMAL_PRIORITY_CLASS))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
void ProcessPage_OnSetPriorityNormal(void) void ProcessPage_OnSetPriorityNormal(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!SetPriorityClass(hProcess, NORMAL_PRIORITY_CLASS)) if (!SetPriorityClass(hProcess, NORMAL_PRIORITY_CLASS))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
void ProcessPage_OnSetPriorityBelowNormal(void) void ProcessPage_OnSetPriorityBelowNormal(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!SetPriorityClass(hProcess, BELOW_NORMAL_PRIORITY_CLASS)) if (!SetPriorityClass(hProcess, BELOW_NORMAL_PRIORITY_CLASS))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }
void ProcessPage_OnSetPriorityLow(void) void ProcessPage_OnSetPriorityLow(void)
{ {
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
DWORD dwProcessId; DWORD dwProcessId;
HANDLE hProcess; HANDLE hProcess;
TCHAR strErrorText[260]; TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
dwProcessId = PerfDataGetProcessId(Index); dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0)) if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return; return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES) if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return; return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess) if (!hProcess)
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
return; return;
} }
if (!SetPriorityClass(hProcess, IDLE_PRIORITY_CLASS)) if (!SetPriorityClass(hProcess, IDLE_PRIORITY_CLASS))
{ {
GetLastErrorText(strErrorText, 260); GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP); MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
} }
CloseHandle(hProcess); CloseHandle(hProcess);
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,94 +29,94 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "procpage.h" #include "procpage.h"
#include "proclist.h" #include "proclist.h"
#include "perfdata.h" #include "perfdata.h"
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LONG OldProcessListWndProc; LONG OldProcessListWndProc;
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
HBRUSH hbrBackground; HBRUSH hbrBackground;
RECT rcItem; RECT rcItem;
RECT rcClip; RECT rcClip;
HDC hDC; HDC hDC;
int DcSave; int DcSave;
switch (message) switch (message)
{ {
case WM_ERASEBKGND: case WM_ERASEBKGND:
/* /*
* The list control produces a nasty flicker * The list control produces a nasty flicker
* when the user is resizing the window because * when the user is resizing the window because
* it erases the background to white, then * it erases the background to white, then
* paints the list items over it. * paints the list items over it.
* *
* We will clip the drawing so that it only * We will clip the drawing so that it only
* erases the parts of the list control that * erases the parts of the list control that
* show only the background. * show only the background.
*/ */
/* /*
* Get the device context and save it's state * Get the device context and save it's state
* to be restored after we're done * to be restored after we're done
*/ */
hDC = (HDC) wParam; hDC = (HDC) wParam;
DcSave = SaveDC(hDC); DcSave = SaveDC(hDC);
/* /*
* Get the background brush * Get the background brush
*/ */
hbrBackground = (HBRUSH) GetClassLong(hWnd, GCL_HBRBACKGROUND); hbrBackground = (HBRUSH) GetClassLong(hWnd, GCL_HBRBACKGROUND);
/* /*
* Calculate the clip rect by getting the RECT * Calculate the clip rect by getting the RECT
* of the first and last items and adding them up. * of the first and last items and adding them up.
* *
* We also have to get the item's icon RECT and * We also have to get the item's icon RECT and
* subtract it from our clip rect because we don't * subtract it from our clip rect because we don't
* use icons in this list control. * use icons in this list control.
*/ */
ListView_GetItemRect(hWnd, 0, &rcClip, LVIR_BOUNDS); ListView_GetItemRect(hWnd, 0, &rcClip, LVIR_BOUNDS);
ListView_GetItemRect(hWnd, ListView_GetItemCount(hWnd) - 1, &rcItem, LVIR_BOUNDS); ListView_GetItemRect(hWnd, ListView_GetItemCount(hWnd) - 1, &rcItem, LVIR_BOUNDS);
rcClip.bottom = rcItem.bottom; rcClip.bottom = rcItem.bottom;
ListView_GetItemRect(hWnd, 0, &rcItem, LVIR_ICON); ListView_GetItemRect(hWnd, 0, &rcItem, LVIR_ICON);
rcClip.left = rcItem.right; rcClip.left = rcItem.right;
/* /*
* Now exclude the clip rect * Now exclude the clip rect
*/ */
ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);
/* /*
* Now erase the background * Now erase the background
* *
* *
* FIXME: Should I erase it myself or * FIXME: Should I erase it myself or
* pass down the updated HDC and let * pass down the updated HDC and let
* the default handler do it? * the default handler do it?
*/ */
GetClientRect(hWnd, &rcItem); GetClientRect(hWnd, &rcItem);
FillRect(hDC, &rcItem, hbrBackground); FillRect(hDC, &rcItem, hbrBackground);
/* /*
* Now restore the DC state that we * Now restore the DC state that we
* saved earlier * saved earlier
*/ */
RestoreDC(hDC, DcSave); RestoreDC(hDC, DcSave);
return TRUE; return TRUE;
} }
/* /*
* We pass on all messages except WM_ERASEBKGND * We pass on all messages except WM_ERASEBKGND
*/ */
return CallWindowProc((WNDPROC)OldProcessListWndProc, hWnd, message, wParam, lParam); return CallWindowProc((WNDPROC)OldProcessListWndProc, hWnd, message, wParam, lParam);
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,7 +29,7 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "procpage.h" #include "procpage.h"
#include "perfdata.h" #include "perfdata.h"
@ -37,17 +37,17 @@
#include "proclist.h" #include "proclist.h"
#include <ctype.h> #include <ctype.h>
HWND hProcessPage; /* Process List Property Page */ 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 */ HWND hProcessPageEndProcessButton; /* Process End Process button */
HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */ HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox */
static int nProcessPageWidth; static int nProcessPageWidth;
static int nProcessPageHeight; static int nProcessPageHeight;
static HANDLE hProcessPageEvent = NULL; /* When this event becomes signaled then we refresh the process list */ static HANDLE hProcessPageEvent = NULL; /* When this event becomes signaled then we refresh the process list */
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam); void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam);
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount); void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount);
@ -56,487 +56,487 @@ DWORD WINAPI ProcessPageRefreshThread(void *lpParameter);
LRESULT CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
RECT rc; RECT rc;
int nXDifference; int nXDifference;
int nYDifference; int nYDifference;
int cx, cy; int cx, cy;
switch (message) { switch (message) {
case WM_INITDIALOG: case WM_INITDIALOG:
/* /*
* Save the width and height * Save the width and height
*/ */
GetClientRect(hDlg, &rc); GetClientRect(hDlg, &rc);
nProcessPageWidth = rc.right; nProcessPageWidth = rc.right;
nProcessPageHeight = rc.bottom; nProcessPageHeight = rc.bottom;
/* Update window position */ /* Update window position */
SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); SetWindowPos(hDlg, NULL, 15, 30, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
/* /*
* Get handles to the controls * Get handles to the controls
*/ */
hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST); hProcessPageListCtrl = GetDlgItem(hDlg, IDC_PROCESSLIST);
hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl); hProcessPageHeaderCtrl = ListView_GetHeader(hProcessPageListCtrl);
hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS); hProcessPageEndProcessButton = GetDlgItem(hDlg, IDC_ENDPROCESS);
hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES); hProcessPageShowAllProcessesButton = GetDlgItem(hDlg, IDC_SHOWALLPROCESSES);
/* /*
* Set the font, title, and extended window styles for the list control * Set the font, title, and extended window styles for the list control
*/ */
SendMessage(hProcessPageListCtrl, WM_SETFONT, SendMessage(hProcessPage, WM_GETFONT, 0, 0), TRUE); SendMessage(hProcessPageListCtrl, WM_SETFONT, SendMessage(hProcessPage, WM_GETFONT, 0, 0), TRUE);
SetWindowText(hProcessPageListCtrl, _T("Processes")); SetWindowText(hProcessPageListCtrl, _T("Processes"));
ListView_SetExtendedListViewStyle(hProcessPageListCtrl, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP); ListView_SetExtendedListViewStyle(hProcessPageListCtrl, ListView_GetExtendedListViewStyle(hProcessPageListCtrl) | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
AddColumns(); AddColumns();
/* /*
* Subclass the process list control so we can intercept WM_ERASEBKGND * Subclass the process list control so we can intercept WM_ERASEBKGND
*/ */
OldProcessListWndProc = SetWindowLong(hProcessPageListCtrl, GWL_WNDPROC, (LONG)ProcessListWndProc); OldProcessListWndProc = SetWindowLong(hProcessPageListCtrl, GWL_WNDPROC, (LONG)ProcessListWndProc);
/* Start our refresh thread */ /* Start our refresh thread */
CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL); CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
return TRUE; return TRUE;
case WM_DESTROY: case WM_DESTROY:
/* Close the event handle, this will make the */ /* Close the event handle, this will make the */
/* refresh thread exit when the wait fails */ /* refresh thread exit when the wait fails */
CloseHandle(hProcessPageEvent); CloseHandle(hProcessPageEvent);
SaveColumnSettings(); SaveColumnSettings();
break; break;
case WM_COMMAND: case WM_COMMAND:
break; break;
case WM_SIZE: case WM_SIZE:
if (wParam == SIZE_MINIMIZED) if (wParam == SIZE_MINIMIZED)
return 0; return 0;
cx = LOWORD(lParam); cx = LOWORD(lParam);
cy = HIWORD(lParam); cy = HIWORD(lParam);
nXDifference = cx - nProcessPageWidth; nXDifference = cx - nProcessPageWidth;
nYDifference = cy - nProcessPageHeight; nYDifference = cy - nProcessPageHeight;
nProcessPageWidth = cx; nProcessPageWidth = cx;
nProcessPageHeight = cy; nProcessPageHeight = cy;
/* Reposition the application page's controls */ /* Reposition the application page's controls */
GetWindowRect(hProcessPageListCtrl, &rc); GetWindowRect(hProcessPageListCtrl, &rc);
cx = (rc.right - rc.left) + nXDifference; cx = (rc.right - rc.left) + nXDifference;
cy = (rc.bottom - rc.top) + nYDifference; cy = (rc.bottom - rc.top) + nYDifference;
SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER); SetWindowPos(hProcessPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
InvalidateRect(hProcessPageListCtrl, NULL, TRUE); InvalidateRect(hProcessPageListCtrl, NULL, TRUE);
GetClientRect(hProcessPageEndProcessButton, &rc); GetClientRect(hProcessPageEndProcessButton, &rc);
MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) ); MapWindowPoints(hProcessPageEndProcessButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
cx = rc.left + nXDifference; cx = rc.left + nXDifference;
cy = rc.top + nYDifference; cy = rc.top + nYDifference;
SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); SetWindowPos(hProcessPageEndProcessButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE); InvalidateRect(hProcessPageEndProcessButton, NULL, TRUE);
GetClientRect(hProcessPageShowAllProcessesButton, &rc); GetClientRect(hProcessPageShowAllProcessesButton, &rc);
MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) ); MapWindowPoints(hProcessPageShowAllProcessesButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
cx = rc.left; cx = rc.left;
cy = rc.top + nYDifference; cy = rc.top + nYDifference;
SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER); SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE); InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
break; break;
case WM_NOTIFY: case WM_NOTIFY:
ProcessPageOnNotify(wParam, lParam); ProcessPageOnNotify(wParam, lParam);
break; break;
} }
return 0; return 0;
} }
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam) void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
{ {
int idctrl; int idctrl;
LPNMHDR pnmh; LPNMHDR pnmh;
LPNMLISTVIEW pnmv; LPNMLISTVIEW pnmv;
NMLVDISPINFO* pnmdi; NMLVDISPINFO* pnmdi;
LPNMHEADER pnmhdr; LPNMHEADER pnmhdr;
LVITEM lvitem; LVITEM lvitem;
ULONG Index; ULONG Index;
ULONG ColumnIndex; ULONG ColumnIndex;
IO_COUNTERS iocounters; IO_COUNTERS iocounters;
TIME time; TIME time;
idctrl = (int) wParam; idctrl = (int) wParam;
pnmh = (LPNMHDR) lParam; pnmh = (LPNMHDR) lParam;
pnmv = (LPNMLISTVIEW) lParam; pnmv = (LPNMLISTVIEW) lParam;
pnmdi = (NMLVDISPINFO*) lParam; pnmdi = (NMLVDISPINFO*) lParam;
pnmhdr = (LPNMHEADER) lParam; pnmhdr = (LPNMHEADER) lParam;
if (pnmh->hwndFrom == hProcessPageListCtrl) if (pnmh->hwndFrom == hProcessPageListCtrl)
{ {
switch (pnmh->code) switch (pnmh->code)
{ {
#if 0 #if 0
case LVN_ITEMCHANGED: case LVN_ITEMCHANGED:
ProcessPageUpdate(); ProcessPageUpdate();
break; break;
#endif #endif
case LVN_GETDISPINFO: case LVN_GETDISPINFO:
if (!(pnmdi->item.mask & LVIF_TEXT)) if (!(pnmdi->item.mask & LVIF_TEXT))
break; break;
ColumnIndex = pnmdi->item.iSubItem; ColumnIndex = pnmdi->item.iSubItem;
Index = pnmdi->item.iItem; Index = pnmdi->item.iItem;
if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME) if (ColumnDataHints[ColumnIndex] == COLUMN_IMAGENAME)
PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); PerfDataGetImageName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax);
if (ColumnDataHints[ColumnIndex] == COLUMN_PID) if (ColumnDataHints[ColumnIndex] == COLUMN_PID)
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetProcessId(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetProcessId(Index));
if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME) if (ColumnDataHints[ColumnIndex] == COLUMN_USERNAME)
PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax); PerfDataGetUserName(Index, pnmdi->item.pszText, pnmdi->item.cchTextMax);
if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID) if (ColumnDataHints[ColumnIndex] == COLUMN_SESSIONID)
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetSessionId(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetSessionId(Index));
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE) if (ColumnDataHints[ColumnIndex] == COLUMN_CPUUSAGE)
wsprintf(pnmdi->item.pszText, _T("%02d"), PerfDataGetCPUUsage(Index)); wsprintf(pnmdi->item.pszText, _T("%02d"), PerfDataGetCPUUsage(Index));
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME) if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME)
{ {
DWORD dwHours; DWORD dwHours;
DWORD dwMinutes; DWORD dwMinutes;
DWORD dwSeconds; DWORD dwSeconds;
time = PerfDataGetCPUTime(Index); time = PerfDataGetCPUTime(Index);
#ifdef _MSC_VER #ifdef _MSC_VER
dwHours = (DWORD)(time.QuadPart / 36000000000L); dwHours = (DWORD)(time.QuadPart / 36000000000L);
dwMinutes = (DWORD)((time.QuadPart % 36000000000L) / 600000000L); dwMinutes = (DWORD)((time.QuadPart % 36000000000L) / 600000000L);
dwSeconds = (DWORD)(((time.QuadPart % 36000000000L) % 600000000L) / 10000000L); dwSeconds = (DWORD)(((time.QuadPart % 36000000000L) % 600000000L) / 10000000L);
#else #else
dwHours = (DWORD)(time.QuadPart / 36000000000LL); dwHours = (DWORD)(time.QuadPart / 36000000000LL);
dwMinutes = (DWORD)((time.QuadPart % 36000000000LL) / 600000000LL); dwMinutes = (DWORD)((time.QuadPart % 36000000000LL) / 600000000LL);
dwSeconds = (DWORD)(((time.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL); dwSeconds = (DWORD)(((time.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL);
#endif #endif
wsprintf(pnmdi->item.pszText, _T("%d:%02d:%02d"), dwHours, dwMinutes, dwSeconds); wsprintf(pnmdi->item.pszText, _T("%d:%02d:%02d"), dwHours, dwMinutes, dwSeconds);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE) if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeBytes(Index) / 1024); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeBytes(Index) / 1024);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
_tcscat(pnmdi->item.pszText, _T(" K")); _tcscat(pnmdi->item.pszText, _T(" K"));
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE) if (ColumnDataHints[ColumnIndex] == COLUMN_PEAKMEMORYUSAGE)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPeakWorkingSetSizeBytes(Index) / 1024);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
_tcscat(pnmdi->item.pszText, _T(" K")); _tcscat(pnmdi->item.pszText, _T(" K"));
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA) if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGEDELTA)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeDelta(Index) / 1024); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetWorkingSetSizeDelta(Index) / 1024);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
_tcscat(pnmdi->item.pszText, _T(" K")); _tcscat(pnmdi->item.pszText, _T(" K"));
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS) if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTS)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCount(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCount(Index));
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA) if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEFAULTSDELTA)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCountDelta(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPageFaultCountDelta(Index));
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE) if (ColumnDataHints[ColumnIndex] == COLUMN_VIRTUALMEMORYSIZE)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetVirtualMemorySizeBytes(Index) / 1024); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetVirtualMemorySizeBytes(Index) / 1024);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
_tcscat(pnmdi->item.pszText, _T(" K")); _tcscat(pnmdi->item.pszText, _T(" K"));
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL) if (ColumnDataHints[ColumnIndex] == COLUMN_PAGEDPOOL)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPagedPoolUsagePages(Index) / 1024); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetPagedPoolUsagePages(Index) / 1024);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
_tcscat(pnmdi->item.pszText, _T(" K")); _tcscat(pnmdi->item.pszText, _T(" K"));
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL) if (ColumnDataHints[ColumnIndex] == COLUMN_NONPAGEDPOOL)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetNonPagedPoolUsagePages(Index) / 1024); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetNonPagedPoolUsagePages(Index) / 1024);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
_tcscat(pnmdi->item.pszText, _T(" K")); _tcscat(pnmdi->item.pszText, _T(" K"));
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY) if (ColumnDataHints[ColumnIndex] == COLUMN_BASEPRIORITY)
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetBasePriority(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetBasePriority(Index));
if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT) if (ColumnDataHints[ColumnIndex] == COLUMN_HANDLECOUNT)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetHandleCount(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetHandleCount(Index));
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT) if (ColumnDataHints[ColumnIndex] == COLUMN_THREADCOUNT)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetThreadCount(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetThreadCount(Index));
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS) if (ColumnDataHints[ColumnIndex] == COLUMN_USEROBJECTS)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetUSERObjectCount(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetUSERObjectCount(Index));
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS) if (ColumnDataHints[ColumnIndex] == COLUMN_GDIOBJECTS)
{ {
wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetGDIObjectCount(Index)); wsprintf(pnmdi->item.pszText, _T("%d"), PerfDataGetGDIObjectCount(Index));
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS) if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADS)
{ {
PerfDataGetIOCounters(Index, &iocounters); PerfDataGetIOCounters(Index, &iocounters);
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadOperationCount); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadOperationCount); */
#ifdef UNICODE #ifdef UNICODE
#define _ui64toa _ui64tow #define _ui64toa _ui64tow
#else #else
#endif #endif
_ui64toa(iocounters.ReadOperationCount, pnmdi->item.pszText, 10); _ui64toa(iocounters.ReadOperationCount, pnmdi->item.pszText, 10);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES) if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITES)
{ {
PerfDataGetIOCounters(Index, &iocounters); PerfDataGetIOCounters(Index, &iocounters);
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteOperationCount); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteOperationCount); */
_ui64toa(iocounters.WriteOperationCount, pnmdi->item.pszText, 10); _ui64toa(iocounters.WriteOperationCount, pnmdi->item.pszText, 10);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER) if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHER)
{ {
PerfDataGetIOCounters(Index, &iocounters); PerfDataGetIOCounters(Index, &iocounters);
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherOperationCount); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherOperationCount); */
_ui64toa(iocounters.OtherOperationCount, pnmdi->item.pszText, 10); _ui64toa(iocounters.OtherOperationCount, pnmdi->item.pszText, 10);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES) if (ColumnDataHints[ColumnIndex] == COLUMN_IOREADBYTES)
{ {
PerfDataGetIOCounters(Index, &iocounters); PerfDataGetIOCounters(Index, &iocounters);
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadTransferCount); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.ReadTransferCount); */
_ui64toa(iocounters.ReadTransferCount, pnmdi->item.pszText, 10); _ui64toa(iocounters.ReadTransferCount, pnmdi->item.pszText, 10);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES) if (ColumnDataHints[ColumnIndex] == COLUMN_IOWRITEBYTES)
{ {
PerfDataGetIOCounters(Index, &iocounters); PerfDataGetIOCounters(Index, &iocounters);
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteTransferCount); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.WriteTransferCount); */
_ui64toa(iocounters.WriteTransferCount, pnmdi->item.pszText, 10); _ui64toa(iocounters.WriteTransferCount, pnmdi->item.pszText, 10);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES) if (ColumnDataHints[ColumnIndex] == COLUMN_IOOTHERBYTES)
{ {
PerfDataGetIOCounters(Index, &iocounters); PerfDataGetIOCounters(Index, &iocounters);
//wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherTransferCount); /* wsprintf(pnmdi->item.pszText, _T("%d"), iocounters.OtherTransferCount); */
_ui64toa(iocounters.OtherTransferCount, pnmdi->item.pszText, 10); _ui64toa(iocounters.OtherTransferCount, pnmdi->item.pszText, 10);
CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax); CommaSeparateNumberString(pnmdi->item.pszText, pnmdi->item.cchTextMax);
} }
break; break;
case NM_RCLICK: case NM_RCLICK:
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++) for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{ {
memset(&lvitem, 0, sizeof(LVITEM)); memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE; lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED; lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index; lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem); ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED) if (lvitem.state & LVIS_SELECTED)
break; break;
} }
if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) && if ((ListView_GetSelectedCount(hProcessPageListCtrl) == 1) &&
(PerfDataGetProcessId(Index) != 0)) (PerfDataGetProcessId(Index) != 0))
{ {
ProcessPageShowContextMenu(PerfDataGetProcessId(Index)); ProcessPageShowContextMenu(PerfDataGetProcessId(Index));
} }
break; break;
} }
} }
else if (pnmh->hwndFrom == hProcessPageHeaderCtrl) else if (pnmh->hwndFrom == hProcessPageHeaderCtrl)
{ {
switch (pnmh->code) switch (pnmh->code)
{ {
case HDN_ITEMCLICK: case HDN_ITEMCLICK:
/* /*
* FIXME: Fix the column sorting * FIXME: Fix the column sorting
* *
*ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL); *ListView_SortItems(hApplicationPageListCtrl, ApplicationPageCompareFunc, NULL);
*bSortAscending = !bSortAscending; *bSortAscending = !bSortAscending;
*/ */
break; break;
case HDN_ITEMCHANGED: case HDN_ITEMCHANGED:
UpdateColumnDataHints(); UpdateColumnDataHints();
break; break;
case HDN_ENDDRAG: case HDN_ENDDRAG:
UpdateColumnDataHints(); UpdateColumnDataHints();
break; break;
} }
} }
} }
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount) void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount)
{ {
TCHAR temp[260]; TCHAR temp[260];
UINT i, j, k; UINT i, j, k;
for (i=0,j=0; i<(_tcslen(strNumber) % 3); i++, j++) for (i=0,j=0; i<(_tcslen(strNumber) % 3); i++, j++)
temp[j] = strNumber[i]; temp[j] = strNumber[i];
for (k=0; i<_tcslen(strNumber); i++,j++,k++) { for (k=0; i<_tcslen(strNumber); i++,j++,k++) {
if ((k % 3 == 0) && (j > 0)) if ((k % 3 == 0) && (j > 0))
temp[j++] = _T(','); temp[j++] = _T(',');
temp[j] = strNumber[i]; temp[j] = strNumber[i];
} }
temp[j] = _T('\0'); temp[j] = _T('\0');
_tcsncpy(strNumber, temp, nMaxCount); _tcsncpy(strNumber, temp, nMaxCount);
} }
void ProcessPageShowContextMenu(DWORD dwProcessId) void ProcessPageShowContextMenu(DWORD dwProcessId)
{ {
HMENU hMenu; HMENU hMenu;
HMENU hSubMenu; HMENU hSubMenu;
HMENU hPriorityMenu; HMENU hPriorityMenu;
POINT pt; POINT pt;
SYSTEM_INFO si; SYSTEM_INFO si;
HANDLE hProcess; HANDLE hProcess;
DWORD dwProcessPriorityClass; DWORD dwProcessPriorityClass;
TCHAR strDebugger[260]; TCHAR strDebugger[260];
DWORD dwDebuggerSize; DWORD dwDebuggerSize;
HKEY hKey; HKEY hKey;
UINT Idx; UINT Idx;
memset(&si, 0, sizeof(SYSTEM_INFO)); memset(&si, 0, sizeof(SYSTEM_INFO));
GetCursorPos(&pt); GetCursorPos(&pt);
GetSystemInfo(&si); GetSystemInfo(&si);
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT)); hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PROCESS_PAGE_CONTEXT));
hSubMenu = GetSubMenu(hMenu, 0); hSubMenu = GetSubMenu(hMenu, 0);
hPriorityMenu = GetSubMenu(hSubMenu, 4); hPriorityMenu = GetSubMenu(hSubMenu, 4);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId); hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
dwProcessPriorityClass = GetPriorityClass(hProcess); dwProcessPriorityClass = GetPriorityClass(hProcess);
CloseHandle(hProcess); CloseHandle(hProcess);
if (si.dwNumberOfProcessors < 2) if (si.dwNumberOfProcessors < 2)
RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND); RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);
switch (dwProcessPriorityClass) { switch (dwProcessPriorityClass) {
case REALTIME_PRIORITY_CLASS: case REALTIME_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND); CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
break; break;
case HIGH_PRIORITY_CLASS: case HIGH_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND); CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
break; break;
case ABOVE_NORMAL_PRIORITY_CLASS: case ABOVE_NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND); CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
break; break;
case NORMAL_PRIORITY_CLASS: case NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND); CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
break; break;
case BELOW_NORMAL_PRIORITY_CLASS: case BELOW_NORMAL_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND); CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
break; break;
case IDLE_PRIORITY_CLASS: case IDLE_PRIORITY_CLASS:
CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND); CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
break; break;
} }
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) == ERROR_SUCCESS) if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{ {
dwDebuggerSize = 260; dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS) if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
{ {
for (Idx=0; Idx<_tcslen(strDebugger); Idx++) for (Idx=0; Idx<_tcslen(strDebugger); Idx++)
strDebugger[Idx] = toupper(strDebugger[Idx]); strDebugger[Idx] = toupper(strDebugger[Idx]);
if (_tcsstr(strDebugger, _T("DRWTSN32"))) if (_tcsstr(strDebugger, _T("DRWTSN32")))
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
} }
else else
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
RegCloseKey(hKey); RegCloseKey(hKey);
} else { } else {
EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); 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); TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
DestroyMenu(hMenu); DestroyMenu(hMenu);
} }
void RefreshProcessPage(void) void RefreshProcessPage(void)
{ {
/* Signal the event so that our refresh thread */ /* Signal the event so that our refresh thread */
/* will wake up and refresh the process page */ /* will wake up and refresh the process page */
SetEvent(hProcessPageEvent); SetEvent(hProcessPageEvent);
} }
DWORD WINAPI ProcessPageRefreshThread(void *lpParameter) DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
{ {
ULONG OldProcessorUsage = 0; ULONG OldProcessorUsage = 0;
ULONG OldProcessCount = 0; ULONG OldProcessCount = 0;
/* Create the event */ /* Create the event */
hProcessPageEvent = CreateEvent(NULL, TRUE, TRUE, _T("Process Page Event")); hProcessPageEvent = CreateEvent(NULL, TRUE, TRUE, _T("Process Page Event"));
/* If we couldn't create the event then exit the thread */ /* If we couldn't create the event then exit the thread */
if (!hProcessPageEvent) if (!hProcessPageEvent)
return 0; return 0;
while (1) { while (1) {
DWORD dwWaitVal; DWORD dwWaitVal;
/* Wait on the event */ /* Wait on the event */
dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE); dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);
/* If the wait failed then the event object must have been */ /* If the wait failed then the event object must have been */
/* closed and the task manager is exiting so exit this thread */ /* closed and the task manager is exiting so exit this thread */
if (dwWaitVal == WAIT_FAILED) if (dwWaitVal == WAIT_FAILED)
return 0; return 0;
if (dwWaitVal == WAIT_OBJECT_0) { if (dwWaitVal == WAIT_OBJECT_0) {
TCHAR text[260]; TCHAR text[260];
/* Reset our event */ /* Reset our event */
ResetEvent(hProcessPageEvent); ResetEvent(hProcessPageEvent);
if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount()) if ((ULONG)SendMessage(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0) != PerfDataGetProcessCount())
SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL); SendMessage(hProcessPageListCtrl, LVM_SETITEMCOUNT, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL);
if (IsWindowVisible(hProcessPage)) if (IsWindowVisible(hProcessPage))
InvalidateRect(hProcessPageListCtrl, NULL, FALSE); InvalidateRect(hProcessPageListCtrl, NULL, FALSE);
if (OldProcessorUsage != PerfDataGetProcessorUsage()) { if (OldProcessorUsage != PerfDataGetProcessorUsage()) {
OldProcessorUsage = PerfDataGetProcessorUsage(); OldProcessorUsage = PerfDataGetProcessorUsage();
wsprintf(text, _T("CPU Usage: %3d%%"), OldProcessorUsage); wsprintf(text, _T("CPU Usage: %3d%%"), OldProcessorUsage);
SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text); SendMessage(hStatusWnd, SB_SETTEXT, 1, (LPARAM)text);
} }
if (OldProcessCount != PerfDataGetProcessCount()) { if (OldProcessCount != PerfDataGetProcessCount()) {
OldProcessCount = PerfDataGetProcessCount(); OldProcessCount = PerfDataGetProcessCount();
wsprintf(text, _T("Processes: %d"), OldProcessCount); wsprintf(text, _T("Processes: %d"), OldProcessCount);
SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text); SendMessage(hStatusWnd, SB_SETTEXT, 0, (LPARAM)text);
} }
} }
} }
return 0; return 0;
} }

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -28,38 +28,38 @@
#include <memory.h> #include <memory.h>
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "run.h" #include "run.h"
void TaskManager_OnFileNew(void) void TaskManager_OnFileNew(void)
{ {
HMODULE hShell32; HMODULE hShell32;
RUNFILEDLG RunFileDlg; RUNFILEDLG RunFileDlg;
OSVERSIONINFO versionInfo; OSVERSIONINFO versionInfo;
WCHAR wTitle[40]; WCHAR wTitle[40];
WCHAR wText[256]; WCHAR wText[256];
char szTitle[40] = "Create New Task"; char szTitle[40] = "Create New Task";
char szText[256] = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you."; char szText[256] = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you.";
hShell32 = LoadLibrary(_T("SHELL32.DLL")); hShell32 = LoadLibrary(_T("SHELL32.DLL"));
RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D)); RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D));
/* Show "Run..." dialog */ /* Show "Run..." dialog */
if (RunFileDlg) if (RunFileDlg)
{ {
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&versionInfo); GetVersionEx(&versionInfo);
if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{ {
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256); MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256);
RunFileDlg(hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY); RunFileDlg(hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
} }
else else
RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
} }
FreeLibrary(hShell32); FreeLibrary(hShell32);
} }

View file

@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -19,8 +19,8 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h> #include <stdlib.h>
@ -29,7 +29,7 @@
#include <tchar.h> #include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <winnt.h> #include <winnt.h>
#include "taskmgr.h" #include "taskmgr.h"
#include "trayicon.h" #include "trayicon.h"
#include "perfdata.h" #include "perfdata.h"
@ -37,177 +37,177 @@
HICON TrayIcon_GetProcessorUsageIcon(void) HICON TrayIcon_GetProcessorUsageIcon(void)
{ {
HICON hTrayIcon = NULL; HICON hTrayIcon = NULL;
HDC hScreenDC = NULL; HDC hScreenDC = NULL;
HDC hDC = NULL; HDC hDC = NULL;
HBITMAP hBitmap = NULL; HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL; HBITMAP hOldBitmap = NULL;
HBITMAP hBitmapMask = NULL; HBITMAP hBitmapMask = NULL;
ICONINFO iconInfo; ICONINFO iconInfo;
ULONG ProcessorUsage; ULONG ProcessorUsage;
int nLinesToDraw; int nLinesToDraw;
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;
/* /*
* Load the bitmaps * Load the bitmaps
*/ */
hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYICON)); hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYICON));
hBitmapMask = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYMASK)); hBitmapMask = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYMASK));
if (!hBitmap || !hBitmapMask) if (!hBitmap || !hBitmapMask)
goto done; goto done;
hBitmapBrush = CreateSolidBrush(RGB(0, 255, 0)); hBitmapBrush = CreateSolidBrush(RGB(0, 255, 0));
if (!hBitmapBrush) if (!hBitmapBrush)
goto done; goto done;
/* /*
* 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 = (HBITMAP) SelectObject(hDC, hBitmap);
/* /*
* Get the cpu usage * Get the cpu usage
*/ */
ProcessorUsage = PerfDataGetProcessorUsage(); ProcessorUsage = PerfDataGetProcessorUsage();
/* /*
* Calculate how many lines to draw * Calculate how many lines to draw
* since we have 11 rows of space * since we have 11 rows of space
* to draw the cpu usage instead of * to draw the cpu usage instead of
* just having 10. * just having 10.
*/ */
nLinesToDraw = (ProcessorUsage + (ProcessorUsage / 10)) / 11; nLinesToDraw = (ProcessorUsage + (ProcessorUsage / 10)) / 11;
rc.left = 3; rc.left = 3;
rc.top = 12 - nLinesToDraw; rc.top = 12 - nLinesToDraw;
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);
/* /*
* Now that we are done drawing put the * Now that we are done drawing put the
* old bitmap back. * old bitmap back.
*/ */
SelectObject(hDC, hOldBitmap); SelectObject(hDC, hOldBitmap);
hOldBitmap = NULL; hOldBitmap = NULL;
iconInfo.fIcon = TRUE; iconInfo.fIcon = TRUE;
iconInfo.xHotspot = 0; iconInfo.xHotspot = 0;
iconInfo.yHotspot = 0; iconInfo.yHotspot = 0;
iconInfo.hbmMask = hBitmapMask; iconInfo.hbmMask = hBitmapMask;
iconInfo.hbmColor = hBitmap; iconInfo.hbmColor = hBitmap;
hTrayIcon = CreateIconIndirect(&iconInfo); hTrayIcon = CreateIconIndirect(&iconInfo);
done: done:
/* /*
* Cleanup * Cleanup
*/ */
if (hScreenDC) if (hScreenDC)
ReleaseDC(NULL, hScreenDC); ReleaseDC(NULL, hScreenDC);
if (hOldBitmap) if (hOldBitmap)
SelectObject(hDC, hOldBitmap); SelectObject(hDC, hOldBitmap);
if (hDC) if (hDC)
DeleteDC(hDC); DeleteDC(hDC);
if (hBitmapBrush) if (hBitmapBrush)
DeleteObject(hBitmapBrush); DeleteObject(hBitmapBrush);
if (hBitmap) if (hBitmap)
DeleteObject(hBitmap); DeleteObject(hBitmap);
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;
} }
BOOL TrayIcon_ShellAddTrayIcon(void) BOOL TrayIcon_ShellAddTrayIcon(void)
{ {
NOTIFYICONDATA nid; NOTIFYICONDATA nid;
HICON hIcon = NULL; HICON hIcon = NULL;
BOOL bRetVal; BOOL bRetVal;
memset(&nid, 0, sizeof(NOTIFYICONDATA)); memset(&nid, 0, sizeof(NOTIFYICONDATA));
hIcon = TrayIcon_GetProcessorUsageIcon(); hIcon = TrayIcon_GetProcessorUsageIcon();
nid.cbSize = sizeof(NOTIFYICONDATA); nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hMainWnd; nid.hWnd = hMainWnd;
nid.uID = 0; nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */ /* nid.uCallbackMessage = ??; */
nid.hIcon = hIcon; nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage()); wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
bRetVal = Shell_NotifyIcon(NIM_ADD, &nid); bRetVal = Shell_NotifyIcon(NIM_ADD, &nid);
if (hIcon) if (hIcon)
DeleteObject(hIcon); DeleteObject(hIcon);
return bRetVal; return bRetVal;
} }
BOOL TrayIcon_ShellRemoveTrayIcon(void) BOOL TrayIcon_ShellRemoveTrayIcon(void)
{ {
NOTIFYICONDATA nid; NOTIFYICONDATA nid;
BOOL bRetVal; BOOL bRetVal;
memset(&nid, 0, sizeof(NOTIFYICONDATA)); memset(&nid, 0, sizeof(NOTIFYICONDATA));
nid.cbSize = sizeof(NOTIFYICONDATA); nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hMainWnd; nid.hWnd = hMainWnd;
nid.uID = 0; nid.uID = 0;
nid.uFlags = 0; nid.uFlags = 0;
/* nid.uCallbackMessage = ??; */ /* nid.uCallbackMessage = ??; */
bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid); bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid);
return bRetVal; return bRetVal;
} }
BOOL TrayIcon_ShellUpdateTrayIcon(void) BOOL TrayIcon_ShellUpdateTrayIcon(void)
{ {
NOTIFYICONDATA nid; NOTIFYICONDATA nid;
HICON hIcon = NULL; HICON hIcon = NULL;
BOOL bRetVal; BOOL bRetVal;
memset(&nid, 0, sizeof(NOTIFYICONDATA)); memset(&nid, 0, sizeof(NOTIFYICONDATA));
hIcon = TrayIcon_GetProcessorUsageIcon(); hIcon = TrayIcon_GetProcessorUsageIcon();
nid.cbSize = sizeof(NOTIFYICONDATA); nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hMainWnd; nid.hWnd = hMainWnd;
nid.uID = 0; nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */ /* nid.uCallbackMessage = ??; */
nid.hIcon = hIcon; nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage()); wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
bRetVal = Shell_NotifyIcon(NIM_MODIFY, &nid); bRetVal = Shell_NotifyIcon(NIM_MODIFY, &nid);
if (hIcon) if (hIcon)
DeleteObject(hIcon); DeleteObject(hIcon);
return bRetVal; return bRetVal;
} }