4 * TaskMgr.c : Defines the entry point for the application.
6 * Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
7 * 2005 Klemens Friedl <frik85@reactos.at>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #define STATUS_WINDOW 2001
28 /* Global Variables: */
29 HINSTANCE hInst
; /* current instance */
31 HWND hMainWnd
; /* Main Window */
32 HWND hStatusWnd
; /* Status Bar Window */
33 HWND hTabWnd
; /* Tab Control Window */
35 int nMinimumWidth
; /* Minimum width of the dialog (OnSize()'s cx) */
36 int nMinimumHeight
; /* Minimum height of the dialog (OnSize()'s cy) */
38 int nOldWidth
; /* Holds the previous client area width */
39 int nOldHeight
; /* Holds the previous client area height */
41 BOOL bInMenuLoop
= FALSE
; /* Tells us if we are in the menu loop */
43 TASKMANAGER_SETTINGS TaskManagerSettings
;
46 int APIENTRY
WinMain(HINSTANCE hInstance
,
47 HINSTANCE hPrevInstance
,
55 /* Initialize global variables */
58 /* Change our priority class to HIGH */
59 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, GetCurrentProcessId());
60 SetPriorityClass(hProcess
, HIGH_PRIORITY_CLASS
);
61 CloseHandle(hProcess
);
63 /* Now lets get the SE_DEBUG_NAME privilege
64 * so that we can debug processes
67 /* Get a token for this process. */
68 if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
| TOKEN_QUERY
, &hToken
)) {
69 /* Get the LUID for the debug privilege. */
70 LookupPrivilegeValue(NULL
, SE_DEBUG_NAME
, &tkp
.Privileges
[0].Luid
);
72 tkp
.PrivilegeCount
= 1; /* one privilege to set */
73 tkp
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
75 /* Get the debug privilege for this process. */
76 AdjustTokenPrivileges(hToken
, FALSE
, &tkp
, 0, (PTOKEN_PRIVILEGES
)NULL
, 0);
79 /* Load our settings from the registry */
82 /* Initialize perf data */
83 if (!PerfDataInitialize()) {
87 DialogBox(hInst
, (LPCTSTR
)IDD_TASKMGR_DIALOG
, NULL
, TaskManagerWndProc
);
89 /* Save our settings to the registry */
91 PerfDataUninitialize();
95 /* Message handler for dialog box. */
97 TaskManagerWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
110 return OnCreate(hDlg
);
113 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
) {
114 EndDialog(hDlg
, LOWORD(wParam
));
117 /* Process menu commands */
118 switch (LOWORD(wParam
))
121 TaskManager_OnFileNew();
123 case ID_OPTIONS_ALWAYSONTOP
:
124 TaskManager_OnOptionsAlwaysOnTop();
126 case ID_OPTIONS_MINIMIZEONUSE
:
127 TaskManager_OnOptionsMinimizeOnUse();
129 case ID_OPTIONS_HIDEWHENMINIMIZED
:
130 TaskManager_OnOptionsHideWhenMinimized();
132 case ID_OPTIONS_SHOW16BITTASKS
:
133 TaskManager_OnOptionsShow16BitTasks();
136 TaskManager_OnRestoreMainWindow();
139 ApplicationPage_OnViewLargeIcons();
142 ApplicationPage_OnViewSmallIcons();
144 case ID_VIEW_DETAILS
:
145 ApplicationPage_OnViewDetails();
147 case ID_VIEW_SHOWKERNELTIMES
:
148 PerformancePage_OnViewShowKernelTimes();
150 case ID_VIEW_CPUHISTORY_ONEGRAPHALL
:
151 PerformancePage_OnViewCPUHistoryOneGraphAll();
153 case ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
:
154 PerformancePage_OnViewCPUHistoryOneGraphPerCPU();
156 case ID_VIEW_UPDATESPEED_HIGH
:
157 TaskManager_OnViewUpdateSpeedHigh();
159 case ID_VIEW_UPDATESPEED_NORMAL
:
160 TaskManager_OnViewUpdateSpeedNormal();
162 case ID_VIEW_UPDATESPEED_LOW
:
163 TaskManager_OnViewUpdateSpeedLow();
165 case ID_VIEW_UPDATESPEED_PAUSED
:
166 TaskManager_OnViewUpdateSpeedPaused();
168 case ID_VIEW_SELECTCOLUMNS
:
169 ProcessPage_OnViewSelectColumns();
171 case ID_VIEW_REFRESH
:
172 PostMessage(hDlg
, WM_TIMER
, 0, 0);
174 case ID_WINDOWS_TILEHORIZONTALLY
:
175 ApplicationPage_OnWindowsTileHorizontally();
177 case ID_WINDOWS_TILEVERTICALLY
:
178 ApplicationPage_OnWindowsTileVertically();
180 case ID_WINDOWS_MINIMIZE
:
181 ApplicationPage_OnWindowsMinimize();
183 case ID_WINDOWS_MAXIMIZE
:
184 ApplicationPage_OnWindowsMaximize();
186 case ID_WINDOWS_CASCADE
:
187 ApplicationPage_OnWindowsCascade();
189 case ID_WINDOWS_BRINGTOFRONT
:
190 ApplicationPage_OnWindowsBringToFront();
192 case ID_APPLICATION_PAGE_SWITCHTO
:
193 ApplicationPage_OnSwitchTo();
195 case ID_APPLICATION_PAGE_ENDTASK
:
196 ApplicationPage_OnEndTask();
198 case ID_APPLICATION_PAGE_GOTOPROCESS
:
199 ApplicationPage_OnGotoProcess();
201 case ID_PROCESS_PAGE_ENDPROCESS
:
202 ProcessPage_OnEndProcess();
204 case ID_PROCESS_PAGE_ENDPROCESSTREE
:
205 ProcessPage_OnEndProcessTree();
207 case ID_PROCESS_PAGE_DEBUG
:
208 ProcessPage_OnDebug();
210 case ID_PROCESS_PAGE_SETAFFINITY
:
211 ProcessPage_OnSetAffinity();
213 case ID_PROCESS_PAGE_SETPRIORITY_REALTIME
:
214 ProcessPage_OnSetPriorityRealTime();
216 case ID_PROCESS_PAGE_SETPRIORITY_HIGH
:
217 ProcessPage_OnSetPriorityHigh();
219 case ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL
:
220 ProcessPage_OnSetPriorityAboveNormal();
222 case ID_PROCESS_PAGE_SETPRIORITY_NORMAL
:
223 ProcessPage_OnSetPriorityNormal();
225 case ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL
:
226 ProcessPage_OnSetPriorityBelowNormal();
228 case ID_PROCESS_PAGE_SETPRIORITY_LOW
:
229 ProcessPage_OnSetPriorityLow();
231 case ID_PROCESS_PAGE_DEBUGCHANNELS
:
232 ProcessPage_OnDebugChannels();
238 EndDialog(hDlg
, IDOK
);
250 HMENU hMenu
, hPopupMenu
;
254 OnTop
= ((GetWindowLong(hMainWnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
) != 0);
256 hMenu
= LoadMenu(hInst
, MAKEINTRESOURCE(IDR_TRAY_POPUP
));
257 hPopupMenu
= GetSubMenu(hMenu
, 0);
259 if(IsWindowVisible(hMainWnd
))
261 DeleteMenu(hPopupMenu
, ID_RESTORE
, MF_BYCOMMAND
);
265 SetMenuDefaultItem(hPopupMenu
, ID_RESTORE
, FALSE
);
270 CheckMenuItem(hPopupMenu
, ID_OPTIONS_ALWAYSONTOP
, MF_BYCOMMAND
| MF_CHECKED
);
273 SetForegroundWindow(hMainWnd
);
274 TrackPopupMenuEx(hPopupMenu
, 0, pt
.x
, pt
.y
, hMainWnd
, NULL
);
279 case WM_LBUTTONDBLCLK
:
280 TaskManager_OnRestoreMainWindow();
286 idctrl
= (int)wParam
;
287 pnmh
= (LPNMHDR
)lParam
;
288 if ((pnmh
->hwndFrom
== hTabWnd
) &&
289 (pnmh
->idFrom
== IDC_TAB
) &&
290 (pnmh
->code
== TCN_SELCHANGE
))
292 TaskManager_OnTabWndSelChange();
298 GetClientRect(hDlg
, &rc
);
299 Draw3dRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.top
+ 2, GetSysColor(COLOR_3DSHADOW
), GetSysColor(COLOR_3DHILIGHT
));
300 ReleaseDC(hDlg
, hdc
);
304 hdc
= BeginPaint(hDlg
, &ps
);
305 GetClientRect(hDlg
, &rc
);
306 Draw3dRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.top
+ 2, GetSysColor(COLOR_3DSHADOW
), GetSysColor(COLOR_3DHILIGHT
));
311 /* Make sure the user is sizing the dialog */
312 /* in an acceptable range */
313 pRC
= (LPRECT
)lParam
;
314 if ((wParam
== WMSZ_LEFT
) || (wParam
== WMSZ_TOPLEFT
) || (wParam
== WMSZ_BOTTOMLEFT
)) {
315 /* If the width is too small enlarge it to the minimum */
316 if (nMinimumWidth
> (pRC
->right
- pRC
->left
))
317 pRC
->left
= pRC
->right
- nMinimumWidth
;
319 /* If the width is too small enlarge it to the minimum */
320 if (nMinimumWidth
> (pRC
->right
- pRC
->left
))
321 pRC
->right
= pRC
->left
+ nMinimumWidth
;
323 if ((wParam
== WMSZ_TOP
) || (wParam
== WMSZ_TOPLEFT
) || (wParam
== WMSZ_TOPRIGHT
)) {
324 /* If the height is too small enlarge it to the minimum */
325 if (nMinimumHeight
> (pRC
->bottom
- pRC
->top
))
326 pRC
->top
= pRC
->bottom
- nMinimumHeight
;
328 /* If the height is too small enlarge it to the minimum */
329 if (nMinimumHeight
> (pRC
->bottom
- pRC
->top
))
330 pRC
->bottom
= pRC
->top
+ nMinimumHeight
;
336 /* Handle the window sizing in it's own function */
337 OnSize(wParam
, LOWORD(lParam
), HIWORD(lParam
));
341 /* Handle the window moving in it's own function */
342 OnMove(wParam
, LOWORD(lParam
), HIWORD(lParam
));
346 ShowWindow(hDlg
, SW_HIDE
);
347 TrayIcon_ShellRemoveTrayIcon();
348 wp
.length
= sizeof(WINDOWPLACEMENT
);
349 GetWindowPlacement(hDlg
, &wp
);
350 TaskManagerSettings
.Left
= wp
.rcNormalPosition
.left
;
351 TaskManagerSettings
.Top
= wp
.rcNormalPosition
.top
;
352 TaskManagerSettings
.Right
= wp
.rcNormalPosition
.right
;
353 TaskManagerSettings
.Bottom
= wp
.rcNormalPosition
.bottom
;
354 if (IsZoomed(hDlg
) || (wp
.flags
& WPF_RESTORETOMAXIMIZED
))
355 TaskManagerSettings
.Maximized
= TRUE
;
357 TaskManagerSettings
.Maximized
= FALSE
;
358 return DefWindowProc(hDlg
, message
, wParam
, lParam
);
361 /* Refresh the performance data */
363 RefreshApplicationPage();
364 RefreshProcessPage();
365 RefreshPerformancePage();
366 TrayIcon_ShellUpdateTrayIcon();
369 case WM_ENTERMENULOOP
:
370 TaskManager_OnEnterMenuLoop(hDlg
);
372 case WM_EXITMENULOOP
:
373 TaskManager_OnExitMenuLoop(hDlg
);
376 TaskManager_OnMenuSelect(hDlg
, LOWORD(wParam
), HIWORD(wParam
), (HMENU
)lParam
);
383 void FillSolidRect(HDC hDC
, LPCRECT lpRect
, COLORREF clr
)
385 SetBkColor(hDC
, clr
);
386 ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, lpRect
, NULL
, 0, NULL
);
389 void FillSolidRect2(HDC hDC
, int x
, int y
, int cx
, int cy
, COLORREF clr
)
393 SetBkColor(hDC
, clr
);
397 rect
.bottom
= y
+ cy
;
398 ExtTextOut(hDC
, 0, 0, ETO_OPAQUE
, &rect
, NULL
, 0, NULL
);
401 void Draw3dRect(HDC hDC
, int x
, int y
, int cx
, int cy
, COLORREF clrTopLeft
, COLORREF clrBottomRight
)
403 FillSolidRect2(hDC
, x
, y
, cx
- 1, 1, clrTopLeft
);
404 FillSolidRect2(hDC
, x
, y
, 1, cy
- 1, clrTopLeft
);
405 FillSolidRect2(hDC
, x
+ cx
, y
, -1, cy
, clrBottomRight
);
406 FillSolidRect2(hDC
, x
, y
+ cy
, cx
, -1, clrBottomRight
);
409 void Draw3dRect2(HDC hDC
, LPRECT lpRect
, COLORREF clrTopLeft
, COLORREF clrBottomRight
)
411 Draw3dRect(hDC
, lpRect
->left
, lpRect
->top
, lpRect
->right
- lpRect
->left
,
412 lpRect
->bottom
- lpRect
->top
, clrTopLeft
, clrBottomRight
);
415 BOOL
OnCreate(HWND hWnd
)
420 HMENU hUpdateSpeedMenu
;
421 HMENU hCPUHistoryMenu
;
428 SendMessage(hMainWnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)LoadIcon(hInst
, MAKEINTRESOURCE(IDI_TASKMANAGER
)));
430 /* Initialize the Windows Common Controls DLL */
431 InitCommonControls();
433 /* Get the minimum window sizes */
434 GetWindowRect(hWnd
, &rc
);
435 nMinimumWidth
= (rc
.right
- rc
.left
);
436 nMinimumHeight
= (rc
.bottom
- rc
.top
);
438 /* Create the status bar */
439 hStatusWnd
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
, _T(""), hWnd
, STATUS_WINDOW
);
443 /* Create the status bar panes */
447 SendMessage(hStatusWnd
, SB_SETPARTS
, 3, (LPARAM
) (LPINT
) nParts
);
449 /* Create tab pages */
450 hTabWnd
= GetDlgItem(hWnd
, IDC_TAB
);
452 hApplicationPage
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_APPLICATION_PAGE
), hWnd
, ApplicationPageWndProc
);
453 hProcessPage
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PROCESS_PAGE
), hWnd
, ProcessPageWndProc
);
454 hPerformancePage
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PERFORMANCE_PAGE
), hWnd
, PerformancePageWndProc
);
456 hApplicationPage
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_APPLICATION_PAGE
), hTabWnd
, ApplicationPageWndProc
);
457 hProcessPage
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PROCESS_PAGE
), hTabWnd
, ProcessPageWndProc
);
458 hPerformancePage
= CreateDialog(hInst
, MAKEINTRESOURCE(IDD_PERFORMANCE_PAGE
), hTabWnd
, PerformancePageWndProc
);
462 LoadString(hInst
, IDS_TAB_APPS
, szTemp
, 256);
463 memset(&item
, 0, sizeof(TCITEM
));
464 item
.mask
= TCIF_TEXT
;
465 item
.pszText
= szTemp
;
466 (void)TabCtrl_InsertItem(hTabWnd
, 0, &item
);
467 LoadString(hInst
, IDS_TAB_PROCESSES
, szTemp
, 256);
468 memset(&item
, 0, sizeof(TCITEM
));
469 item
.mask
= TCIF_TEXT
;
470 item
.pszText
= szTemp
;
471 (void)TabCtrl_InsertItem(hTabWnd
, 1, &item
);
472 LoadString(hInst
, IDS_TAB_PERFORMANCE
, szTemp
, 256);
473 memset(&item
, 0, sizeof(TCITEM
));
474 item
.mask
= TCIF_TEXT
;
475 item
.pszText
= szTemp
;
476 (void)TabCtrl_InsertItem(hTabWnd
, 2, &item
);
478 /* Size everything correctly */
479 GetClientRect(hWnd
, &rc
);
480 nOldWidth
= rc
.right
;
481 nOldHeight
= rc
.bottom
;
482 /* nOldStartX = rc.left; */
483 /*nOldStartY = rc.top; */
485 #define PAGE_OFFSET_LEFT 17
486 #define PAGE_OFFSET_TOP 72
487 #define PAGE_OFFSET_WIDTH (PAGE_OFFSET_LEFT*2)
488 #define PAGE_OFFSET_HEIGHT (PAGE_OFFSET_TOP+32)
490 if ((TaskManagerSettings
.Left
!= 0) ||
491 (TaskManagerSettings
.Top
!= 0) ||
492 (TaskManagerSettings
.Right
!= 0) ||
493 (TaskManagerSettings
.Bottom
!= 0))
495 MoveWindow(hWnd
, TaskManagerSettings
.Left
, TaskManagerSettings
.Top
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
, TRUE
);
496 #ifdef __GNUC__TEST__
497 MoveWindow(hApplicationPage
, TaskManagerSettings
.Left
+ PAGE_OFFSET_LEFT
, TaskManagerSettings
.Top
+ PAGE_OFFSET_TOP
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
- PAGE_OFFSET_WIDTH
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
- PAGE_OFFSET_HEIGHT
, FALSE
);
498 MoveWindow(hProcessPage
, TaskManagerSettings
.Left
+ PAGE_OFFSET_LEFT
, TaskManagerSettings
.Top
+ PAGE_OFFSET_TOP
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
- PAGE_OFFSET_WIDTH
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
- PAGE_OFFSET_HEIGHT
, FALSE
);
499 MoveWindow(hPerformancePage
, TaskManagerSettings
.Left
+ PAGE_OFFSET_LEFT
, TaskManagerSettings
.Top
+ PAGE_OFFSET_TOP
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
- PAGE_OFFSET_WIDTH
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
- PAGE_OFFSET_HEIGHT
, FALSE
);
502 if (TaskManagerSettings
.Maximized
)
503 ShowWindow(hWnd
, SW_MAXIMIZE
);
505 /* Set the always on top style */
506 hMenu
= GetMenu(hWnd
);
507 hEditMenu
= GetSubMenu(hMenu
, 1);
508 hViewMenu
= GetSubMenu(hMenu
, 2);
509 hUpdateSpeedMenu
= GetSubMenu(hViewMenu
, 1);
510 hCPUHistoryMenu
= GetSubMenu(hViewMenu
, 7);
512 /* Check or uncheck the always on top menu item */
513 if (TaskManagerSettings
.AlwaysOnTop
) {
514 CheckMenuItem(hEditMenu
, ID_OPTIONS_ALWAYSONTOP
, MF_BYCOMMAND
|MF_CHECKED
);
515 SetWindowPos(hWnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
517 CheckMenuItem(hEditMenu
, ID_OPTIONS_ALWAYSONTOP
, MF_BYCOMMAND
|MF_UNCHECKED
);
518 SetWindowPos(hWnd
, HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
521 /* Check or uncheck the minimize on use menu item */
522 if (TaskManagerSettings
.MinimizeOnUse
)
523 CheckMenuItem(hEditMenu
, ID_OPTIONS_MINIMIZEONUSE
, MF_BYCOMMAND
|MF_CHECKED
);
525 CheckMenuItem(hEditMenu
, ID_OPTIONS_MINIMIZEONUSE
, MF_BYCOMMAND
|MF_UNCHECKED
);
527 /* Check or uncheck the hide when minimized menu item */
528 if (TaskManagerSettings
.HideWhenMinimized
)
529 CheckMenuItem(hEditMenu
, ID_OPTIONS_HIDEWHENMINIMIZED
, MF_BYCOMMAND
|MF_CHECKED
);
531 CheckMenuItem(hEditMenu
, ID_OPTIONS_HIDEWHENMINIMIZED
, MF_BYCOMMAND
|MF_UNCHECKED
);
533 /* Check or uncheck the show 16-bit tasks menu item */
534 if (TaskManagerSettings
.Show16BitTasks
)
535 CheckMenuItem(hEditMenu
, ID_OPTIONS_SHOW16BITTASKS
, MF_BYCOMMAND
|MF_CHECKED
);
537 CheckMenuItem(hEditMenu
, ID_OPTIONS_SHOW16BITTASKS
, MF_BYCOMMAND
|MF_UNCHECKED
);
539 if (TaskManagerSettings
.View_LargeIcons
)
540 CheckMenuRadioItem(hViewMenu
, ID_VIEW_LARGE
, ID_VIEW_DETAILS
, ID_VIEW_LARGE
, MF_BYCOMMAND
);
541 else if (TaskManagerSettings
.View_SmallIcons
)
542 CheckMenuRadioItem(hViewMenu
, ID_VIEW_LARGE
, ID_VIEW_DETAILS
, ID_VIEW_SMALL
, MF_BYCOMMAND
);
544 CheckMenuRadioItem(hViewMenu
, ID_VIEW_LARGE
, ID_VIEW_DETAILS
, ID_VIEW_DETAILS
, MF_BYCOMMAND
);
546 if (TaskManagerSettings
.ShowKernelTimes
)
547 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_CHECKED
);
549 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_UNCHECKED
);
551 if (TaskManagerSettings
.UpdateSpeed
== 1)
552 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_HIGH
, MF_BYCOMMAND
);
553 else if (TaskManagerSettings
.UpdateSpeed
== 2)
554 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_NORMAL
, MF_BYCOMMAND
);
555 else if (TaskManagerSettings
.UpdateSpeed
== 4)
556 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_LOW
, MF_BYCOMMAND
);
558 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_PAUSED
, MF_BYCOMMAND
);
560 if (TaskManagerSettings
.CPUHistory_OneGraphPerCPU
)
561 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, MF_BYCOMMAND
);
563 CheckMenuRadioItem(hCPUHistoryMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, MF_BYCOMMAND
);
565 nActivePage
= TaskManagerSettings
.ActiveTabPage
;
566 TabCtrl_SetCurFocus
/*Sel*/(hTabWnd
, 0);
567 TabCtrl_SetCurFocus
/*Sel*/(hTabWnd
, 1);
568 TabCtrl_SetCurFocus
/*Sel*/(hTabWnd
, 2);
569 TabCtrl_SetCurFocus
/*Sel*/(hTabWnd
, nActivePage
);
571 if (TaskManagerSettings
.UpdateSpeed
== 1)
572 SetTimer(hWnd
, 1, 1000, NULL
);
573 else if (TaskManagerSettings
.UpdateSpeed
== 2)
574 SetTimer(hWnd
, 1, 2000, NULL
);
575 else if (TaskManagerSettings
.UpdateSpeed
== 4)
576 SetTimer(hWnd
, 1, 4000, NULL
);
579 * Refresh the performance data
580 * Sample it twice so we can establish
581 * the delta values & cpu usage
586 RefreshApplicationPage();
587 RefreshProcessPage();
588 RefreshPerformancePage();
590 TrayIcon_ShellAddTrayIcon();
596 * This function handles all the moving events for the application
597 * It moves every child window that needs moving
599 void OnMove( WPARAM nType
, int cx
, int cy
)
601 #ifdef __GNUC__TEST__
602 MoveWindow(hApplicationPage
, TaskManagerSettings
.Left
+ PAGE_OFFSET_LEFT
, TaskManagerSettings
.Top
+ PAGE_OFFSET_TOP
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
- PAGE_OFFSET_WIDTH
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
- PAGE_OFFSET_HEIGHT
, FALSE
);
603 MoveWindow(hProcessPage
, TaskManagerSettings
.Left
+ PAGE_OFFSET_LEFT
, TaskManagerSettings
.Top
+ PAGE_OFFSET_TOP
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
- PAGE_OFFSET_WIDTH
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
- PAGE_OFFSET_HEIGHT
, FALSE
);
604 MoveWindow(hPerformancePage
, TaskManagerSettings
.Left
+ PAGE_OFFSET_LEFT
, TaskManagerSettings
.Top
+ PAGE_OFFSET_TOP
, TaskManagerSettings
.Right
- TaskManagerSettings
.Left
- PAGE_OFFSET_WIDTH
, TaskManagerSettings
.Bottom
- TaskManagerSettings
.Top
- PAGE_OFFSET_HEIGHT
, FALSE
);
609 * This function handles all the sizing events for the application
610 * It re-sizes every window, and child window that needs re-sizing
612 void OnSize( WPARAM nType
, int cx
, int cy
)
619 if (nType
== SIZE_MINIMIZED
)
621 if(TaskManagerSettings
.HideWhenMinimized
)
623 ShowWindow(hMainWnd
, SW_HIDE
);
628 nXDifference
= cx
- nOldWidth
;
629 nYDifference
= cy
- nOldHeight
;
633 /* Update the status bar size */
634 GetWindowRect(hStatusWnd
, &rc
);
635 SendMessage(hStatusWnd
, WM_SIZE
, nType
, MAKELPARAM(cx
, cy
+ (rc
.bottom
- rc
.top
)));
637 /* Update the status bar pane sizes */
638 nParts
[0] = bInMenuLoop
? -1 : 100;
641 SendMessage(hStatusWnd
, SB_SETPARTS
, bInMenuLoop
? 1 : 3, (LPARAM
) (LPINT
) nParts
);
643 /* Resize the tab control */
644 GetWindowRect(hTabWnd
, &rc
);
645 cx
= (rc
.right
- rc
.left
) + nXDifference
;
646 cy
= (rc
.bottom
- rc
.top
) + nYDifference
;
647 SetWindowPos(hTabWnd
, NULL
, 0, 0, cx
, cy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOMOVE
|SWP_NOZORDER
);
649 /* Resize the application page */
650 GetWindowRect(hApplicationPage
, &rc
);
651 cx
= (rc
.right
- rc
.left
) + nXDifference
;
652 cy
= (rc
.bottom
- rc
.top
) + nYDifference
;
653 SetWindowPos(hApplicationPage
, NULL
, 0, 0, cx
, cy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOMOVE
|SWP_NOZORDER
);
655 /* Resize the process page */
656 GetWindowRect(hProcessPage
, &rc
);
657 cx
= (rc
.right
- rc
.left
) + nXDifference
;
658 cy
= (rc
.bottom
- rc
.top
) + nYDifference
;
659 SetWindowPos(hProcessPage
, NULL
, 0, 0, cx
, cy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOMOVE
|SWP_NOZORDER
);
661 /* Resize the performance page */
662 GetWindowRect(hPerformancePage
, &rc
);
663 cx
= (rc
.right
- rc
.left
) + nXDifference
;
664 cy
= (rc
.bottom
- rc
.top
) + nYDifference
;
665 SetWindowPos(hPerformancePage
, NULL
, 0, 0, cx
, cy
, SWP_NOACTIVATE
|SWP_NOOWNERZORDER
|SWP_NOMOVE
|SWP_NOZORDER
);
668 void LoadSettings(void)
671 TCHAR szSubKey
[] = _T("Software\\ReactWare\\TaskManager");
675 /* Window size & position settings */
676 TaskManagerSettings
.Maximized
= FALSE
;
677 TaskManagerSettings
.Left
= 0;
678 TaskManagerSettings
.Top
= 0;
679 TaskManagerSettings
.Right
= 0;
680 TaskManagerSettings
.Bottom
= 0;
683 TaskManagerSettings
.ActiveTabPage
= 0;
685 /* Options menu settings */
686 TaskManagerSettings
.AlwaysOnTop
= FALSE
;
687 TaskManagerSettings
.MinimizeOnUse
= TRUE
;
688 TaskManagerSettings
.HideWhenMinimized
= TRUE
;
689 TaskManagerSettings
.Show16BitTasks
= TRUE
;
691 /* Update speed settings */
692 TaskManagerSettings
.UpdateSpeed
= 2;
694 /* Applications page settings */
695 TaskManagerSettings
.View_LargeIcons
= FALSE
;
696 TaskManagerSettings
.View_SmallIcons
= FALSE
;
697 TaskManagerSettings
.View_Details
= TRUE
;
699 /* Processes page settings */
700 TaskManagerSettings
.ShowProcessesFromAllUsers
= FALSE
; /* Server-only? */
701 TaskManagerSettings
.Column_ImageName
= TRUE
;
702 TaskManagerSettings
.Column_PID
= TRUE
;
703 TaskManagerSettings
.Column_CPUUsage
= TRUE
;
704 TaskManagerSettings
.Column_CPUTime
= TRUE
;
705 TaskManagerSettings
.Column_MemoryUsage
= TRUE
;
706 TaskManagerSettings
.Column_MemoryUsageDelta
= FALSE
;
707 TaskManagerSettings
.Column_PeakMemoryUsage
= FALSE
;
708 TaskManagerSettings
.Column_PageFaults
= FALSE
;
709 TaskManagerSettings
.Column_USERObjects
= FALSE
;
710 TaskManagerSettings
.Column_IOReads
= FALSE
;
711 TaskManagerSettings
.Column_IOReadBytes
= FALSE
;
712 TaskManagerSettings
.Column_SessionID
= FALSE
; /* Server-only? */
713 TaskManagerSettings
.Column_UserName
= FALSE
; /* Server-only? */
714 TaskManagerSettings
.Column_PageFaultsDelta
= FALSE
;
715 TaskManagerSettings
.Column_VirtualMemorySize
= FALSE
;
716 TaskManagerSettings
.Column_PagedPool
= FALSE
;
717 TaskManagerSettings
.Column_NonPagedPool
= FALSE
;
718 TaskManagerSettings
.Column_BasePriority
= FALSE
;
719 TaskManagerSettings
.Column_HandleCount
= FALSE
;
720 TaskManagerSettings
.Column_ThreadCount
= FALSE
;
721 TaskManagerSettings
.Column_GDIObjects
= FALSE
;
722 TaskManagerSettings
.Column_IOWrites
= FALSE
;
723 TaskManagerSettings
.Column_IOWriteBytes
= FALSE
;
724 TaskManagerSettings
.Column_IOOther
= FALSE
;
725 TaskManagerSettings
.Column_IOOtherBytes
= FALSE
;
727 for (i
= 0; i
< 25; i
++) {
728 TaskManagerSettings
.ColumnOrderArray
[i
] = i
;
730 TaskManagerSettings
.ColumnSizeArray
[0] = 105;
731 TaskManagerSettings
.ColumnSizeArray
[1] = 50;
732 TaskManagerSettings
.ColumnSizeArray
[2] = 107;
733 TaskManagerSettings
.ColumnSizeArray
[3] = 70;
734 TaskManagerSettings
.ColumnSizeArray
[4] = 35;
735 TaskManagerSettings
.ColumnSizeArray
[5] = 70;
736 TaskManagerSettings
.ColumnSizeArray
[6] = 70;
737 TaskManagerSettings
.ColumnSizeArray
[7] = 100;
738 TaskManagerSettings
.ColumnSizeArray
[8] = 70;
739 TaskManagerSettings
.ColumnSizeArray
[9] = 70;
740 TaskManagerSettings
.ColumnSizeArray
[10] = 70;
741 TaskManagerSettings
.ColumnSizeArray
[11] = 70;
742 TaskManagerSettings
.ColumnSizeArray
[12] = 70;
743 TaskManagerSettings
.ColumnSizeArray
[13] = 70;
744 TaskManagerSettings
.ColumnSizeArray
[14] = 60;
745 TaskManagerSettings
.ColumnSizeArray
[15] = 60;
746 TaskManagerSettings
.ColumnSizeArray
[16] = 60;
747 TaskManagerSettings
.ColumnSizeArray
[17] = 60;
748 TaskManagerSettings
.ColumnSizeArray
[18] = 60;
749 TaskManagerSettings
.ColumnSizeArray
[19] = 70;
750 TaskManagerSettings
.ColumnSizeArray
[20] = 70;
751 TaskManagerSettings
.ColumnSizeArray
[21] = 70;
752 TaskManagerSettings
.ColumnSizeArray
[22] = 70;
753 TaskManagerSettings
.ColumnSizeArray
[23] = 70;
754 TaskManagerSettings
.ColumnSizeArray
[24] = 70;
756 TaskManagerSettings
.SortColumn
= 1;
757 TaskManagerSettings
.SortAscending
= TRUE
;
759 /* Performance page settings */
760 TaskManagerSettings
.CPUHistory_OneGraphPerCPU
= TRUE
;
761 TaskManagerSettings
.ShowKernelTimes
= FALSE
;
764 if (RegOpenKeyEx(HKEY_CURRENT_USER
, szSubKey
, 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
766 /* Read the settings */
767 dwSize
= sizeof(TASKMANAGER_SETTINGS
);
768 RegQueryValueEx(hKey
, _T("Preferences"), NULL
, NULL
, (LPBYTE
)&TaskManagerSettings
, &dwSize
);
774 void SaveSettings(void)
777 TCHAR szSubKey1
[] = _T("Software");
778 TCHAR szSubKey2
[] = _T("Software\\ReactWare");
779 TCHAR szSubKey3
[] = _T("Software\\ReactWare\\TaskManager");
781 /* Open (or create) the key */
783 RegCreateKeyEx(HKEY_CURRENT_USER
, szSubKey1
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
786 RegCreateKeyEx(HKEY_CURRENT_USER
, szSubKey2
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
);
789 if (RegCreateKeyEx(HKEY_CURRENT_USER
, szSubKey3
, 0, NULL
, REG_OPTION_NON_VOLATILE
, KEY_WRITE
, NULL
, &hKey
, NULL
) != ERROR_SUCCESS
)
791 /* Save the settings */
792 RegSetValueEx(hKey
, _T("Preferences"), 0, REG_BINARY
, (LPBYTE
)&TaskManagerSettings
, sizeof(TASKMANAGER_SETTINGS
));
797 void TaskManager_OnRestoreMainWindow(void)
799 HMENU hMenu
, hOptionsMenu
;
802 hMenu
= GetMenu(hMainWnd
);
803 hOptionsMenu
= GetSubMenu(hMenu
, OPTIONS_MENU_INDEX
);
804 OnTop
= ((GetWindowLong(hMainWnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
) != 0);
807 SetForegroundWindow(hMainWnd
);
808 SetWindowPos(hMainWnd
, (OnTop
? HWND_TOPMOST
: HWND_TOP
), 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_SHOWWINDOW
);
811 void TaskManager_OnEnterMenuLoop(HWND hWnd
)
815 /* Update the status bar pane sizes */
817 SendMessage(hStatusWnd
, SB_SETPARTS
, 1, (LPARAM
) (LPINT
)&nParts
);
819 SendMessage(hStatusWnd
, SB_SETTEXT
, (WPARAM
)0, (LPARAM
)_T(""));
822 void TaskManager_OnExitMenuLoop(HWND hWnd
)
827 TCHAR szCpuUsage
[256], szProcesses
[256];
829 LoadString(hInst
, IDS_STATUS_CPUUSAGE
, szCpuUsage
, 256);
830 LoadString(hInst
, IDS_STATUS_PROCESSES
, szProcesses
, 256);
833 /* Update the status bar pane sizes */
834 GetClientRect(hWnd
, &rc
);
837 nParts
[2] = rc
.right
;
838 SendMessage(hStatusWnd
, SB_SETPARTS
, 3, (LPARAM
) (LPINT
) nParts
);
839 SendMessage(hStatusWnd
, SB_SETTEXT
, 0, (LPARAM
)_T(""));
840 wsprintf(text
, szCpuUsage
, PerfDataGetProcessorUsage());
841 SendMessage(hStatusWnd
, SB_SETTEXT
, 1, (LPARAM
)text
);
842 wsprintf(text
, szProcesses
, PerfDataGetProcessCount());
843 SendMessage(hStatusWnd
, SB_SETTEXT
, 0, (LPARAM
)text
);
846 void TaskManager_OnMenuSelect(HWND hWnd
, UINT nItemID
, UINT nFlags
, HMENU hSysMenu
)
850 _tcscpy(str
, TEXT(""));
851 if (LoadString(hInst
, nItemID
, str
, 100)) {
852 /* load appropriate string */
854 /* first newline terminates actual string */
855 lpsz
= _tcschr(lpsz
, '\n');
859 SendMessage(hStatusWnd
, SB_SETTEXT
, 0, (LPARAM
)str
);
862 void TaskManager_OnViewUpdateSpeedHigh(void)
866 HMENU hUpdateSpeedMenu
;
868 hMenu
= GetMenu(hMainWnd
);
869 hViewMenu
= GetSubMenu(hMenu
, 2);
870 hUpdateSpeedMenu
= GetSubMenu(hViewMenu
, 1);
872 TaskManagerSettings
.UpdateSpeed
= 1;
873 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_HIGH
, MF_BYCOMMAND
);
875 KillTimer(hMainWnd
, 1);
876 SetTimer(hMainWnd
, 1, 500, NULL
);
879 void TaskManager_OnViewUpdateSpeedNormal(void)
883 HMENU hUpdateSpeedMenu
;
885 hMenu
= GetMenu(hMainWnd
);
886 hViewMenu
= GetSubMenu(hMenu
, 2);
887 hUpdateSpeedMenu
= GetSubMenu(hViewMenu
, 1);
889 TaskManagerSettings
.UpdateSpeed
= 2;
890 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_NORMAL
, MF_BYCOMMAND
);
892 KillTimer(hMainWnd
, 1);
893 SetTimer(hMainWnd
, 1, 2000, NULL
);
896 void TaskManager_OnViewUpdateSpeedLow(void)
900 HMENU hUpdateSpeedMenu
;
902 hMenu
= GetMenu(hMainWnd
);
903 hViewMenu
= GetSubMenu(hMenu
, 2);
904 hUpdateSpeedMenu
= GetSubMenu(hViewMenu
, 1);
906 TaskManagerSettings
.UpdateSpeed
= 4;
907 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_LOW
, MF_BYCOMMAND
);
909 KillTimer(hMainWnd
, 1);
910 SetTimer(hMainWnd
, 1, 4000, NULL
);
913 void TaskManager_OnViewRefresh(void)
915 PostMessage(hMainWnd
, WM_TIMER
, 0, 0);
918 void TaskManager_OnViewUpdateSpeedPaused(void)
922 HMENU hUpdateSpeedMenu
;
924 hMenu
= GetMenu(hMainWnd
);
925 hViewMenu
= GetSubMenu(hMenu
, 2);
926 hUpdateSpeedMenu
= GetSubMenu(hViewMenu
, 1);
927 TaskManagerSettings
.UpdateSpeed
= 0;
928 CheckMenuRadioItem(hUpdateSpeedMenu
, ID_VIEW_UPDATESPEED_HIGH
, ID_VIEW_UPDATESPEED_PAUSED
, ID_VIEW_UPDATESPEED_PAUSED
, MF_BYCOMMAND
);
929 KillTimer(hMainWnd
, 1);
932 void TaskManager_OnTabWndSelChange(void)
941 hMenu
= GetMenu(hMainWnd
);
942 hViewMenu
= GetSubMenu(hMenu
, 2);
943 hOptionsMenu
= GetSubMenu(hMenu
, 1);
944 TaskManagerSettings
.ActiveTabPage
= TabCtrl_GetCurSel(hTabWnd
);
945 for (i
= GetMenuItemCount(hViewMenu
) - 1; i
> 2; i
--) {
946 hSubMenu
= GetSubMenu(hViewMenu
, i
);
948 DestroyMenu(hSubMenu
);
949 RemoveMenu(hViewMenu
, i
, MF_BYPOSITION
);
951 RemoveMenu(hOptionsMenu
, 3, MF_BYPOSITION
);
952 switch (TaskManagerSettings
.ActiveTabPage
) {
954 ShowWindow(hApplicationPage
, SW_SHOW
);
955 ShowWindow(hProcessPage
, SW_HIDE
);
956 ShowWindow(hPerformancePage
, SW_HIDE
);
957 BringWindowToTop(hApplicationPage
);
959 LoadString(hInst
, IDS_MENU_LARGEICONS
, szTemp
, 256);
960 AppendMenu(hViewMenu
, MF_STRING
, ID_VIEW_LARGE
, szTemp
);
962 LoadString(hInst
, IDS_MENU_SMALLICONS
, szTemp
, 256);
963 AppendMenu(hViewMenu
, MF_STRING
, ID_VIEW_SMALL
, szTemp
);
965 LoadString(hInst
, IDS_MENU_DETAILS
, szTemp
, 256);
966 AppendMenu(hViewMenu
, MF_STRING
, ID_VIEW_DETAILS
, szTemp
);
968 if (GetMenuItemCount(hMenu
) <= 4) {
969 hSubMenu
= LoadMenu(hInst
, MAKEINTRESOURCE(IDR_WINDOWSMENU
));
971 LoadString(hInst
, IDS_MENU_WINDOWS
, szTemp
, 256);
972 InsertMenu(hMenu
, 3, MF_BYPOSITION
|MF_POPUP
, (UINT_PTR
) hSubMenu
, szTemp
);
974 DrawMenuBar(hMainWnd
);
976 if (TaskManagerSettings
.View_LargeIcons
)
977 CheckMenuRadioItem(hViewMenu
, ID_VIEW_LARGE
, ID_VIEW_DETAILS
, ID_VIEW_LARGE
, MF_BYCOMMAND
);
978 else if (TaskManagerSettings
.View_SmallIcons
)
979 CheckMenuRadioItem(hViewMenu
, ID_VIEW_LARGE
, ID_VIEW_DETAILS
, ID_VIEW_SMALL
, MF_BYCOMMAND
);
981 CheckMenuRadioItem(hViewMenu
, ID_VIEW_LARGE
, ID_VIEW_DETAILS
, ID_VIEW_DETAILS
, MF_BYCOMMAND
);
983 * Give the application list control focus
985 SetFocus(hApplicationPageListCtrl
);
989 ShowWindow(hApplicationPage
, SW_HIDE
);
990 ShowWindow(hProcessPage
, SW_SHOW
);
991 ShowWindow(hPerformancePage
, SW_HIDE
);
992 BringWindowToTop(hProcessPage
);
994 LoadString(hInst
, IDS_MENU_SELECTCOLUMNS
, szTemp
, 256);
995 AppendMenu(hViewMenu
, MF_STRING
, ID_VIEW_SELECTCOLUMNS
, szTemp
);
997 LoadString(hInst
, IDS_MENU_16BITTASK
, szTemp
, 256);
998 AppendMenu(hOptionsMenu
, MF_STRING
, ID_OPTIONS_SHOW16BITTASKS
, szTemp
);
1000 if (TaskManagerSettings
.Show16BitTasks
)
1001 CheckMenuItem(hOptionsMenu
, ID_OPTIONS_SHOW16BITTASKS
, MF_BYCOMMAND
|MF_CHECKED
);
1002 if (GetMenuItemCount(hMenu
) > 4)
1004 DeleteMenu(hMenu
, 3, MF_BYPOSITION
);
1005 DrawMenuBar(hMainWnd
);
1008 * Give the process list control focus
1010 SetFocus(hProcessPageListCtrl
);
1014 ShowWindow(hApplicationPage
, SW_HIDE
);
1015 ShowWindow(hProcessPage
, SW_HIDE
);
1016 ShowWindow(hPerformancePage
, SW_SHOW
);
1017 BringWindowToTop(hPerformancePage
);
1018 if (GetMenuItemCount(hMenu
) > 4) {
1019 DeleteMenu(hMenu
, 3, MF_BYPOSITION
);
1020 DrawMenuBar(hMainWnd
);
1022 hSubMenu
= CreatePopupMenu();
1024 LoadString(hInst
, IDS_MENU_ONEGRAPHALLCPUS
, szTemp
, 256);
1025 AppendMenu(hSubMenu
, MF_STRING
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, szTemp
);
1027 LoadString(hInst
, IDS_MENU_ONEGRAPHPERCPU
, szTemp
, 256);
1028 AppendMenu(hSubMenu
, MF_STRING
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, szTemp
);
1030 LoadString(hInst
, IDS_MENU_CPUHISTORY
, szTemp
, 256);
1031 AppendMenu(hViewMenu
, MF_STRING
|MF_POPUP
, (UINT_PTR
) hSubMenu
, szTemp
);
1033 LoadString(hInst
, IDS_MENU_SHOWKERNELTIMES
, szTemp
, 256);
1034 AppendMenu(hViewMenu
, MF_STRING
, ID_VIEW_SHOWKERNELTIMES
, szTemp
);
1036 if (TaskManagerSettings
.ShowKernelTimes
)
1037 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_CHECKED
);
1039 CheckMenuItem(hViewMenu
, ID_VIEW_SHOWKERNELTIMES
, MF_BYCOMMAND
|MF_UNCHECKED
);
1040 if (TaskManagerSettings
.CPUHistory_OneGraphPerCPU
)
1041 CheckMenuRadioItem(hSubMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, MF_BYCOMMAND
);
1043 CheckMenuRadioItem(hSubMenu
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
, ID_VIEW_CPUHISTORY_ONEGRAPHALL
, MF_BYCOMMAND
);
1045 * Give the tab control focus
1052 LPTSTR
GetLastErrorText(LPTSTR lpszBuf
, DWORD dwSize
)
1055 LPTSTR lpszTemp
= NULL
;
1057 dwRet
= FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
1065 /* supplied buffer is not long enough */
1066 if (!dwRet
|| ( (long)dwSize
< (long)dwRet
+14)) {
1067 lpszBuf
[0] = TEXT('\0');
1069 lpszTemp
[lstrlen(lpszTemp
)-2] = TEXT('\0'); /*remove cr and newline character */
1070 _stprintf(lpszBuf
, TEXT("%s (0x%x)"), lpszTemp
, (int)GetLastError());
1073 LocalFree((HLOCAL
)lpszTemp
);