ReactOS 0.4.16-dev-340-g0540c21
taskmgr.c File Reference
#include "precomp.h"
#include "perfpage.h"
#include "about.h"
#include "affinity.h"
#include "debug.h"
#include "priority.h"
Include dependency graph for taskmgr.c:

Go to the source code of this file.

Macros

#define STATUS_WINDOW   2001
 
#define ETDT_DISABLE   0x00000001
 
#define ETDT_ENABLE   0x00000002
 
#define ETDT_USETABTEXTURE   0x00000004
 
#define ETDT_ENABLETAB   (ETDT_ENABLE | ETDT_USETABTEXTURE)
 
#define PAGE_OFFSET_LEFT   17
 
#define PAGE_OFFSET_TOP   72
 
#define PAGE_OFFSET_WIDTH   (PAGE_OFFSET_LEFT*2)
 
#define PAGE_OFFSET_HEIGHT   (PAGE_OFFSET_TOP+32)
 

Typedefs

typedef HRESULT(WINAPIETDTProc) (HWND, DWORD)
 

Functions

BOOL EnableDialogTheme (HWND hwnd)
 
int APIENTRY wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 
INT_PTR CALLBACK TaskManagerWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
void FillSolidRect (HDC hDC, LPCRECT lpRect, COLORREF clr)
 
static void SetUpdateSpeed (HWND hWnd)
 
BOOL OnCreate (HWND hWnd)
 
void OnMove (WPARAM nType, int cx, int cy)
 
void OnSize (WPARAM nType, int cx, int cy)
 
void LoadSettings (void)
 
void SaveSettings (void)
 
void TaskManager_OnRestoreMainWindow (void)
 
void TaskManager_OnMenuSelect (HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
 
void TaskManager_OnViewUpdateSpeed (DWORD dwSpeed)
 
void TaskManager_OnTabWndSelChange (void)
 
BOOL ConfirmMessageBox (HWND hWnd, LPCWSTR Text, LPCWSTR Title, UINT Type)
 
VOID ShowWin32Error (DWORD dwError)
 
LPWSTR GetLastErrorText (LPWSTR lpszBuf, DWORD dwSize)
 
DWORD EndLocalThread (HANDLE *hThread, DWORD dwThread)
 

Variables

HINSTANCE hInst
 
HWND hMainWnd
 
HWND hStatusWnd
 
HWND hTabWnd
 
HMENU hWindowMenu = NULL
 
int nMinimumWidth
 
int nMinimumHeight
 
int nOldWidth
 
int nOldHeight
 
BOOL bTrackMenu = FALSE
 
BOOL bWasKeyboardInput = FALSE
 
TASKMANAGER_SETTINGS TaskManagerSettings
 

Macro Definition Documentation

◆ ETDT_DISABLE

#define ETDT_DISABLE   0x00000001

Definition at line 50 of file taskmgr.c.

◆ ETDT_ENABLE

#define ETDT_ENABLE   0x00000002

Definition at line 51 of file taskmgr.c.

◆ ETDT_ENABLETAB

#define ETDT_ENABLETAB   (ETDT_ENABLE | ETDT_USETABTEXTURE)

Definition at line 53 of file taskmgr.c.

◆ ETDT_USETABTEXTURE

#define ETDT_USETABTEXTURE   0x00000004

Definition at line 52 of file taskmgr.c.

◆ PAGE_OFFSET_HEIGHT

#define PAGE_OFFSET_HEIGHT   (PAGE_OFFSET_TOP+32)

◆ PAGE_OFFSET_LEFT

#define PAGE_OFFSET_LEFT   17

◆ PAGE_OFFSET_TOP

#define PAGE_OFFSET_TOP   72

◆ PAGE_OFFSET_WIDTH

#define PAGE_OFFSET_WIDTH   (PAGE_OFFSET_LEFT*2)

◆ STATUS_WINDOW

#define STATUS_WINDOW   2001

Definition at line 17 of file taskmgr.c.

Typedef Documentation

◆ ETDTProc

typedef HRESULT(WINAPI * ETDTProc) (HWND, DWORD)

Definition at line 56 of file taskmgr.c.

Function Documentation

◆ ConfirmMessageBox()

BOOL ConfirmMessageBox ( HWND  hWnd,
LPCWSTR  Text,
LPCWSTR  Title,
UINT  Type 
)

Definition at line 1059 of file taskmgr.c.

1060{
1061 UINT positive = ((Type & 0xF) <= MB_OKCANCEL ? IDOK : IDYES);
1062 if (GetKeyState(VK_SHIFT) < 0)
1063 return TRUE;
1064 return (MessageBoxW(hWnd, Text, Title, Type) == positive);
1065}
Type
Definition: Type.h:7
HWND hWnd
Definition: settings.c:17
char * Text
Definition: combotst.c:136
#define TRUE
Definition: types.h:120
static const WCHAR Title[]
Definition: oid.c:1259
unsigned int UINT
Definition: ndis.h:50
Definition: unary.h:15
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define IDOK
Definition: winuser.h:833
#define MB_OKCANCEL
Definition: winuser.h:807
#define VK_SHIFT
Definition: winuser.h:2205
#define IDYES
Definition: winuser.h:838
SHORT WINAPI GetKeyState(_In_ int)

Referenced by DoSetPriority(), ProcessPage_OnDebug(), ProcessPage_OnEndProcess(), and ProcessPage_OnEndProcessTree().

◆ EnableDialogTheme()

BOOL EnableDialogTheme ( HWND  hwnd)

Definition at line 61 of file taskmgr.c.

62{
63 HMODULE hUXTheme;
65
66 hUXTheme = LoadLibraryA("uxtheme.dll");
67
68 if(hUXTheme)
69 {
71 (ETDTProc)GetProcAddress(hUXTheme, "EnableThemeDialogTexture");
72
74 {
76
77 FreeLibrary(hUXTheme);
78 return TRUE;
79 }
80 else
81 {
82 // Failed to locate API!
83 FreeLibrary(hUXTheme);
84 return FALSE;
85 }
86 }
87 else
88 {
89 // Not running under XP? Just fail gracefully
90 return FALSE;
91 }
92}
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HRESULT(WINAPI * ETDTProc)(HWND, DWORD)
Definition: taskmgr.c:56
#define ETDT_ENABLETAB
Definition: taskmgr.c:53
static ETDTProc fnEnableThemeDialogTexture
Definition: uxthemesupp.c:15
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by OnCreate().

◆ EndLocalThread()

DWORD EndLocalThread ( HANDLE hThread,
DWORD  dwThread 
)

Definition at line 1109 of file taskmgr.c.

1110{
1111 DWORD dwExitCodeThread = 0;
1112
1113 if (*hThread != NULL) {
1114 PostThreadMessage(dwThread,WM_QUIT,0,0);
1115 for (;;) {
1116 MSG msg;
1117
1119 break;
1120 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
1123 }
1124 }
1125 GetExitCodeThread(*hThread, &dwExitCodeThread);
1127 *hThread = NULL;
1128 }
1129 return dwExitCodeThread;
1130}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:541
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE hThread
Definition: wizard.c:28
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define WAIT_OBJECT_0
Definition: winbase.h:432
#define WM_QUIT
Definition: winuser.h:1626
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PostThreadMessage
Definition: winuser.h:5845
#define PM_REMOVE
Definition: winuser.h:1199
#define PeekMessage
Definition: winuser.h:5842
#define DispatchMessage
Definition: winuser.h:5777

Referenced by ApplicationPageWndProc(), PerformancePageWndProc(), and ProcessPageWndProc().

◆ FillSolidRect()

void FillSolidRect ( HDC  hDC,
LPCRECT  lpRect,
COLORREF  clr 
)

Definition at line 491 of file taskmgr.c.

492{
493 SetBkColor(hDC, clr);
494 ExtTextOutW(hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
495}
static HDC hDC
Definition: 3dtext.c:33
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647

Referenced by Graph_DrawCpuUsageGraph(), Graph_DrawMemUsageGraph(), Graph_DrawMemUsageHistoryGraph(), and CBrandBand::OnPaint().

◆ GetLastErrorText()

LPWSTR GetLastErrorText ( LPWSTR  lpszBuf,
DWORD  dwSize 
)

Definition at line 1083 of file taskmgr.c.

1084{
1085 DWORD dwRet;
1086 LPWSTR lpszTemp = NULL;
1087
1089 NULL,
1090 GetLastError(),
1092 (LPWSTR)&lpszTemp,
1093 0,
1094 NULL );
1095
1096 /* supplied buffer is not long enough */
1097 if (!dwRet || ( (long)dwSize < (long)dwRet+14)) {
1098 lpszBuf[0] = L'\0';
1099 } else {
1100 lpszTemp[lstrlenW(lpszTemp)-2] = L'\0'; /*remove cr and newline character */
1101 wsprintfW(lpszBuf, L"%s (0x%x)", lpszTemp, (int)GetLastError());
1102 }
1103 if (lpszTemp) {
1104 LocalFree((HLOCAL)lpszTemp);
1105 }
1106 return lpszBuf;
1107}
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define L(x)
Definition: ntvdm.h:50
#define LANG_NEUTRAL
Definition: nls.h:22
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:450
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AffinityDialogWndProc(), DoSetPriority(), ProcessPage_OnDebug(), ProcessPage_OnEndProcess(), ProcessPage_OnEndProcessTree(), and ProcessPage_OnSetAffinity().

◆ LoadSettings()

void LoadSettings ( void  )

Definition at line 783 of file taskmgr.c.

784{
785 HKEY hKey;
786 WCHAR szSubKey[] = L"Software\\ReactOS\\TaskManager";
787 int i;
789
790 /* Window size & position settings */
796
797 /* Tab settings */
799
800 /* Options menu settings */
805
806 /* Update speed settings */
808
809 /* Applications page settings */
811
812 /* Processes page settings */
813 TaskManagerSettings.ShowProcessesFromAllUsers = FALSE; /* It's the default */
814
815 for (i = 0; i < COLUMN_NMAX; i++) {
819 }
820
823
824 /* Performance page settings */
827
828 /* Open the key */
830 return;
831 /* Read the settings */
834
835 /*
836 * ATM, the 'ImageName' column is always visible
837 * (and grayed in configuration dialog)
838 * This will avoid troubles if the registry gets corrupted.
839 */
840 TaskManagerSettings.Column_ImageName = TRUE;
841
842 /* Close the key */
844}
#define ID_VIEW_DETAILS
Definition: resource.h:36
#define ID_VIEW_UPDATESPEED_NORMAL
Definition: resource.h:151
#define RegCloseKey(hKey)
Definition: registry.h:49
const PresetColumnEntry ColumnPresets[COLUMN_NMAX]
Definition: column.c:16
#define COLUMN_IMAGENAME
Definition: column.h:11
#define COLUMN_NMAX
Definition: column.h:37
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define KEY_READ
Definition: nt_native.h:1023
BOOL bDefaults
Definition: column.h:62
int ColumnSizeArray[COLUMN_NMAX]
Definition: taskmgr.h:49
BOOL HideWhenMinimized
Definition: taskmgr.h:36
BOOL ShowProcessesFromAllUsers
Definition: taskmgr.h:46
int ColumnOrderArray[COLUMN_NMAX]
Definition: taskmgr.h:48
BOOL CPUHistory_OneGraphPerCPU
Definition: taskmgr.h:54
BOOL Columns[COLUMN_NMAX]
Definition: taskmgr.h:47
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:37
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by wWinMain().

◆ OnCreate()

BOOL OnCreate ( HWND  hWnd)

Definition at line 513 of file taskmgr.c.

514{
515 HMENU hMenu;
516 HMENU hEditMenu;
517 HMENU hViewMenu;
518 HMENU hShutMenu;
519 HMENU hUpdateSpeedMenu;
520 HMENU hCPUHistoryMenu;
521 int nActivePage;
522 int nParts[3];
523 RECT rc;
524 WCHAR szTemp[256];
525 WCHAR szLogOffItem[MAX_PATH];
526 LPWSTR lpUserName;
527 TCITEM item;
528 DWORD len = 0;
529
531
532 /* Initialize the Windows Common Controls DLL */
534
535 /* Get the minimum window sizes */
536 GetWindowRect(hWnd, &rc);
537 nMinimumWidth = (rc.right - rc.left);
538 nMinimumHeight = (rc.bottom - rc.top);
539
540 /* Create the status bar */
542 if(!hStatusWnd)
543 return FALSE;
544
545 /* Create the status bar panes */
546 nParts[0] = STATUS_SIZE1;
547 nParts[1] = STATUS_SIZE2;
548 nParts[2] = STATUS_SIZE3;
550
551 /* Create tab pages */
553#if 1
557#else
561#endif
562
563 /* Insert tabs */
564 LoadStringW(hInst, IDS_TAB_APPS, szTemp, 256);
565 memset(&item, 0, sizeof(TCITEM));
566 item.mask = TCIF_TEXT;
567 item.pszText = szTemp;
569 LoadStringW(hInst, IDS_TAB_PROCESSES, szTemp, 256);
570 memset(&item, 0, sizeof(TCITEM));
571 item.mask = TCIF_TEXT;
572 item.pszText = szTemp;
575 memset(&item, 0, sizeof(TCITEM));
576 item.mask = TCIF_TEXT;
577 item.pszText = szTemp;
579
580 /* Size everything correctly */
581 GetClientRect(hWnd, &rc);
582 nOldWidth = rc.right;
583 nOldHeight = rc.bottom;
584 /* nOldStartX = rc.left; */
585 /*nOldStartY = rc.top; */
586
587#define PAGE_OFFSET_LEFT 17
588#define PAGE_OFFSET_TOP 72
589#define PAGE_OFFSET_WIDTH (PAGE_OFFSET_LEFT*2)
590#define PAGE_OFFSET_HEIGHT (PAGE_OFFSET_TOP+32)
591
592 if ((TaskManagerSettings.Left != 0) ||
593 (TaskManagerSettings.Top != 0) ||
594 (TaskManagerSettings.Right != 0) ||
596 {
598#ifdef __GNUC__TEST__
602#endif
603 }
606
607 /* Set the always on top style */
608 hMenu = GetMenu(hWnd);
609 hEditMenu = GetSubMenu(hMenu, 1);
610 hViewMenu = GetSubMenu(hMenu, 2);
611 hShutMenu = GetSubMenu(hMenu, 4);
612 hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
613 hCPUHistoryMenu = GetSubMenu(hViewMenu, 7);
614
615 /* Check or uncheck the always on top menu item */
619 } else {
622 }
623
624 /* Check or uncheck the minimize on use menu item */
627 else
629
630 /* Check or uncheck the hide when minimized menu item */
633 else
635
636 /* Check or uncheck the show 16-bit tasks menu item */
639 else
641
642 /* Set the view mode */
644
647 else
649
651
654 else
656
658 TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 0);
659 TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 1);
660 TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 2);
661 TabCtrl_SetCurFocus/*Sel*/(hTabWnd, nActivePage);
662
663 /* Set the username in the "Log Off %s" item of the Shutdown menu */
664
665 /* 1- Get the menu item text and store it temporarily */
666 GetMenuStringW(hShutMenu, ID_SHUTDOWN_LOGOFF, szTemp, 256, MF_BYCOMMAND);
667
668 /* 2- Retrieve the username length first, then allocate a buffer for it and call it again */
670 {
671 lpUserName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
672 if (lpUserName && GetUserNameW(lpUserName, &len))
673 {
674 _snwprintf(szLogOffItem, _countof(szLogOffItem), szTemp, lpUserName);
675 szLogOffItem[_countof(szLogOffItem) - 1] = UNICODE_NULL;
676 }
677 else
678 {
679 _snwprintf(szLogOffItem, _countof(szLogOffItem), szTemp, L"n/a");
680 }
681
682 if (lpUserName) HeapFree(GetProcessHeap(), 0, lpUserName);
683 }
684 else
685 {
686 _snwprintf(szLogOffItem, _countof(szLogOffItem), szTemp, L"n/a");
687 }
688
689 /* 3- Set the menu item text to its formatted counterpart */
691
692 /* Setup update speed */
694
695 /*
696 * Refresh the performance data
697 * Sample it twice so we can establish
698 * the delta values & cpu usage
699 */
702
706
708
709 return TRUE;
710}
void RefreshApplicationPage(void)
Definition: applpage.c:223
HWND hApplicationPage
Definition: applpage.c:20
INT_PTR CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: applpage.c:89
#define IDC_TAB
Definition: resource.h:12
#define ID_VIEW_LARGE
Definition: resource.h:33
#define IDD_APPLICATION_PAGE
Definition: resource.h:15
#define IDD_PERFORMANCE_PAGE
Definition: resource.h:22
#define IDS_TAB_APPS
Definition: resource.h:202
#define ID_VIEW_SHOWKERNELTIMES
Definition: resource.h:166
#define ID_OPTIONS_ALWAYSONTOP
Definition: resource.h:143
#define ID_VIEW_UPDATESPEED_PAUSED
Definition: resource.h:153
#define ID_OPTIONS_MINIMIZEONUSE
Definition: resource.h:144
#define IDS_TAB_PERFORMANCE
Definition: resource.h:204
#define ID_OPTIONS_SHOW16BITTASKS
Definition: resource.h:163
#define IDS_TAB_PROCESSES
Definition: resource.h:203
#define ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
Definition: resource.h:168
#define IDD_PROCESS_PAGE
Definition: resource.h:21
#define ID_VIEW_UPDATESPEED_HIGH
Definition: resource.h:150
#define ID_SHUTDOWN_LOGOFF
Definition: resource.h:194
#define ID_OPTIONS_HIDEWHENMINIMIZED
Definition: resource.h:145
#define IDI_TASKMANAGER
Definition: resource.h:24
#define ID_VIEW_CPUHISTORY_ONEGRAPHALL
Definition: resource.h:167
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:870
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLenum GLsizei len
Definition: glext.h:6722
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static ATOM item
Definition: dde.c:856
#define UNICODE_NULL
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
void PerfDataRefresh(void)
Definition: perfdata.c:158
INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: perfpage.c:98
void RefreshPerformancePage(void)
Definition: perfpage.c:288
HWND hPerformancePage
Definition: perfpage.c:14
INT_PTR CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: procpage.c:121
HWND hProcessPage
Definition: procpage.c:26
void RefreshProcessPage(void)
Definition: procpage.c:448
#define CreateStatusWindow
Definition: commctrl.h:1938
#define SBT_NOBORDERS
Definition: commctrl.h:1976
#define TCITEM
Definition: commctrl.h:4034
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4056
#define SB_SETPARTS
Definition: commctrl.h:1959
#define TCIF_TEXT
Definition: commctrl.h:3976
#define TabCtrl_SetCurFocus(hwnd, i)
Definition: commctrl.h:4107
#define memset(x, y, z)
Definition: compat.h:39
#define _countof(array)
Definition: sndvol32.h:70
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int nOldWidth
Definition: taskmgr.c:31
int nOldHeight
Definition: taskmgr.c:32
int nMinimumWidth
Definition: taskmgr.c:28
HWND hStatusWnd
Definition: taskmgr.c:23
#define PAGE_OFFSET_LEFT
HINSTANCE hInst
Definition: taskmgr.c:20
BOOL EnableDialogTheme(HWND hwnd)
Definition: taskmgr.c:61
#define PAGE_OFFSET_WIDTH
HWND hMainWnd
Definition: taskmgr.c:22
int nMinimumHeight
Definition: taskmgr.c:29
#define PAGE_OFFSET_TOP
#define PAGE_OFFSET_HEIGHT
static void SetUpdateSpeed(HWND hWnd)
Definition: taskmgr.c:497
#define STATUS_WINDOW
Definition: taskmgr.c:17
HWND hTabWnd
Definition: taskmgr.c:24
#define STATUS_SIZE2
Definition: taskmgr.h:18
#define STATUS_SIZE1
Definition: taskmgr.h:17
#define STATUS_SIZE3
Definition: taskmgr.h:19
#define ICON_BIG
Definition: tnclass.cpp:51
BOOL TrayIcon_AddIcon(VOID)
Definition: trayicon.c:138
LONG_PTR LPARAM
Definition: windef.h:208
int * LPINT
Definition: windef.h:178
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define HWND_TOPMOST
Definition: winuser.h:1211
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI GetMenuStringW(_In_ HMENU hMenu, _In_ UINT uIDItem, _Out_writes_opt_(cchMax) LPWSTR lpString, _In_ int cchMax, _In_ UINT flags)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1247
#define MF_STRING
Definition: winuser.h:138
#define MF_CHECKED
Definition: winuser.h:132
#define SWP_NOSIZE
Definition: winuser.h:1248
#define MF_UNCHECKED
Definition: winuser.h:204
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4284
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI ModifyMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SW_MAXIMIZE
Definition: winuser.h:775
#define HWND_NOTOPMOST
Definition: winuser.h:1209
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2127
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HMENU WINAPI GetMenu(_In_ HWND)

Referenced by TaskManagerWndProc().

◆ OnMove()

◆ OnSize()

void OnSize ( WPARAM  nType,
int  cx,
int  cy 
)

Definition at line 729 of file taskmgr.c.

730{
731 int nParts[3];
732 int nXDifference;
733 int nYDifference;
734 RECT rc;
735
736 if (nType == SIZE_MINIMIZED)
737 {
740 return;
741 }
742
743 nXDifference = cx - nOldWidth;
744 nYDifference = cy - nOldHeight;
745 nOldWidth = cx;
746 nOldHeight = cy;
747
748 /* Update the status bar size */
751
752 /* Update the status bar pane sizes */
753 nParts[0] = STATUS_SIZE1;
754 nParts[1] = STATUS_SIZE2;
755 nParts[2] = cx;
757
758 /* Resize the tab control */
760 cx = (rc.right - rc.left) + nXDifference;
761 cy = (rc.bottom - rc.top) + nYDifference;
763
764 /* Resize the application page */
766 cx = (rc.right - rc.left) + nXDifference;
767 cy = (rc.bottom - rc.top) + nYDifference;
769
770 /* Resize the process page */
772 cx = (rc.right - rc.left) + nXDifference;
773 cy = (rc.bottom - rc.top) + nYDifference;
775
776 /* Resize the performance page */
778 cx = (rc.right - rc.left) + nXDifference;
779 cy = (rc.bottom - rc.top) + nYDifference;
781}
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define SW_HIDE
Definition: winuser.h:771
#define SWP_NOACTIVATE
Definition: winuser.h:1245
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
#define WM_SIZE
Definition: winuser.h:1614
#define SIZE_MINIMIZED
Definition: winuser.h:2509
#define SWP_NOOWNERZORDER
Definition: winuser.h:1252
#define SWP_NOZORDER
Definition: winuser.h:1250

Referenced by TaskManagerWndProc().

◆ SaveSettings()

void SaveSettings ( void  )

Definition at line 846 of file taskmgr.c.

847{
848 HKEY hKey;
849 WCHAR szSubKey[] = L"Software\\ReactOS\\TaskManager";
850
851 /* Open (or create) the key */
853 return;
854 /* Save the settings */
856 /* Close the key */
858}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031

Referenced by wWinMain().

◆ SetUpdateSpeed()

static void SetUpdateSpeed ( HWND  hWnd)
static

Definition at line 497 of file taskmgr.c.

498{
499 /* Setup update speed (pause=fall down) */
502 SetTimer(hWnd, 1, 500, NULL);
503 break;
505 SetTimer(hWnd, 1, 2000, NULL);
506 break;
508 SetTimer(hWnd, 1, 4000, NULL);
509 break;
510 }
511}
#define ID_VIEW_UPDATESPEED_LOW
Definition: resource.h:152
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

Referenced by OnCreate(), and TaskManager_OnViewUpdateSpeed().

◆ ShowWin32Error()

VOID ShowWin32Error ( DWORD  dwError)

Definition at line 1067 of file taskmgr.c.

1068{
1069 LPWSTR lpMessageBuffer;
1070
1072 NULL,
1073 dwError,
1075 (LPWSTR)&lpMessageBuffer,
1076 0, NULL) != 0)
1077 {
1078 MessageBoxW(hMainWnd, lpMessageBuffer, NULL, MB_OK | MB_ICONERROR);
1079 if (lpMessageBuffer) LocalFree(lpMessageBuffer);
1080 }
1081}
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define MB_ICONERROR
Definition: winuser.h:790
#define MB_OK
Definition: winuser.h:793

◆ TaskManager_OnMenuSelect()

void TaskManager_OnMenuSelect ( HWND  hWnd,
UINT  nItemID,
UINT  nFlags,
HMENU  hSysMenu 
)

Definition at line 871 of file taskmgr.c.

872{
873 WCHAR str[100] = L"";
874
875 /*
876 * Reset the status bar if we close the current menu, or
877 * we open the system menu or hover above a menu separator.
878 * Adapted from comctl32!MenuHelp().
879 */
880 if ((LOWORD(nFlags) == 0xFFFF && hSysMenu == NULL) ||
881 (nFlags & (MF_SEPARATOR | MF_SYSMENU)))
882 {
883 /* Set the status bar for multiple-parts output */
886
887 /* Trigger update of status bar columns and performance page asynchronously */
889 return;
890 }
891
892 /* Otherwise, retrieve the appropriate menu hint string */
893 if (LoadStringW(hInst, nItemID, str, _countof(str)))
894 {
895 /* First newline terminates actual string */
896 LPWSTR lpsz = wcschr(str, '\n');
897 if (lpsz != NULL)
898 *lpsz = '\0';
899 }
900
901 /* Set the status bar for single-part output, if needed... */
902 if (!bTrackMenu)
905
906 /* ... and display the menu hint */
908}
#define wcschr
Definition: compat.h:17
#define SB_SIMPLEID
Definition: precomp.h:15
#define LOWORD(l)
Definition: pedump.c:82
#define SB_SIMPLE
Definition: commctrl.h:1963
#define SB_SETTEXT
Definition: commctrl.h:1954
const WCHAR * str
BOOL bTrackMenu
Definition: taskmgr.c:34
UINT_PTR WPARAM
Definition: windef.h:207
#define MF_SYSMENU
Definition: winuser.h:141
#define MF_SEPARATOR
Definition: winuser.h:137

Referenced by TaskManagerWndProc().

◆ TaskManager_OnRestoreMainWindow()

void TaskManager_OnRestoreMainWindow ( void  )

Definition at line 860 of file taskmgr.c.

861{
862 BOOL OnTop;
863
865
869}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define GetWindowLongPtrW
Definition: winuser.h:4832
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI OpenIcon(_In_ HWND)
#define HWND_TOP
Definition: winuser.h:1210
#define SWP_SHOWWINDOW
Definition: winuser.h:1251
#define GWL_EXSTYLE
Definition: winuser.h:854

Referenced by TaskManagerWndProc().

◆ TaskManager_OnTabWndSelChange()

void TaskManager_OnTabWndSelChange ( void  )

Definition at line 928 of file taskmgr.c.

929{
930 int i;
931 HMENU hMenu;
932 HMENU hOptionsMenu;
933 HMENU hViewMenu;
934 HMENU hSubMenu;
935 WCHAR szTemp[256];
936 SYSTEM_INFO sysInfo;
937
938 hMenu = GetMenu(hMainWnd);
939 hViewMenu = GetSubMenu(hMenu, 2);
940 hOptionsMenu = GetSubMenu(hMenu, 1);
942 for (i = GetMenuItemCount(hViewMenu) - 1; i > 2; i--) {
943 hSubMenu = GetSubMenu(hViewMenu, i);
944 if (hSubMenu)
945 DestroyMenu(hSubMenu);
946 RemoveMenu(hViewMenu, i, MF_BYPOSITION);
947 }
948 RemoveMenu(hOptionsMenu, 3, MF_BYPOSITION);
949 if (hWindowMenu)
952 case 0:
957
959 AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_LARGE, szTemp);
960
962 AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SMALL, szTemp);
963
964 LoadStringW(hInst, IDS_MENU_DETAILS, szTemp, 256);
965 AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_DETAILS, szTemp);
966
967 if (GetMenuItemCount(hMenu) <= 5) {
969
970 LoadStringW(hInst, IDS_MENU_WINDOWS, szTemp, 256);
972
974 }
976
977 /*
978 * Give the application list control focus
979 */
982 break;
983
984 case 1:
989
991 AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SELECTCOLUMNS, szTemp);
992
993 LoadStringW(hInst, IDS_MENU_16BITTASK, szTemp, 256);
994 AppendMenuW(hOptionsMenu, MF_STRING, ID_OPTIONS_SHOW16BITTASKS, szTemp);
995
998 if (GetMenuItemCount(hMenu) > 5)
999 {
1000 DeleteMenu(hMenu, 3, MF_BYPOSITION);
1002 }
1003 /*
1004 * Give the process list control focus
1005 */
1006 if (!bWasKeyboardInput)
1008 break;
1009
1010 case 2:
1015 if (GetMenuItemCount(hMenu) > 5) {
1016 DeleteMenu(hMenu, 3, MF_BYPOSITION);
1018 }
1019
1020 GetSystemInfo(&sysInfo);
1021
1022 /* Hide CPU graph options on single CPU systems */
1023 if (sysInfo.dwNumberOfProcessors > 1)
1024 {
1025 hSubMenu = CreatePopupMenu();
1026
1029
1032
1033 LoadStringW(hInst, IDS_MENU_CPUHISTORY, szTemp, 256);
1034 AppendMenuW(hViewMenu, MF_STRING|MF_POPUP, (UINT_PTR) hSubMenu, szTemp);
1035
1038 else
1040 }
1041
1043 AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, szTemp);
1044
1047 else
1049
1050 /*
1051 * Give the tab control focus
1052 */
1053 if (!bWasKeyboardInput)
1055 break;
1056 }
1057}
HWND hApplicationPageListCtrl
Definition: applpage.c:21
#define ID_VIEW_SMALL
Definition: resource.h:34
#define IDS_MENU_SELECTCOLUMNS
Definition: resource.h:234
#define IDS_MENU_SHOWKERNELTIMES
Definition: resource.h:243
#define IDS_MENU_DETAILS
Definition: resource.h:239
#define IDR_WINDOWSMENU
Definition: resource.h:23
#define IDS_MENU_CPUHISTORY
Definition: resource.h:242
#define IDS_MENU_SMALLICONS
Definition: resource.h:238
#define IDS_MENU_ONEGRAPHPERCPU
Definition: resource.h:241
#define IDS_MENU_ONEGRAPHALLCPUS
Definition: resource.h:240
#define IDS_MENU_WINDOWS
Definition: resource.h:236
#define IDS_MENU_16BITTASK
Definition: resource.h:235
#define ID_VIEW_SELECTCOLUMNS
Definition: resource.h:165
#define IDS_MENU_LARGEICONS
Definition: resource.h:237
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
HWND hProcessPageListCtrl
Definition: procpage.c:28
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4068
DWORD dwNumberOfProcessors
Definition: winbase.h:1202
BOOL bWasKeyboardInput
Definition: taskmgr.c:35
HMENU hWindowMenu
Definition: taskmgr.c:26
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI InsertMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_POPUP
Definition: winuser.h:136
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define SW_SHOW
Definition: winuser.h:778
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI BringWindowToTop(_In_ HWND)
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)

Referenced by TaskManagerWndProc().

◆ TaskManager_OnViewUpdateSpeed()

void TaskManager_OnViewUpdateSpeed ( DWORD  dwSpeed)

Definition at line 910 of file taskmgr.c.

911{
912 HMENU hMenu;
913 HMENU hViewMenu;
914 HMENU hUpdateSpeedMenu;
915
916 hMenu = GetMenu(hMainWnd);
917 hViewMenu = GetSubMenu(hMenu, 2);
918 hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
919
922
924
926}
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by TaskManagerWndProc().

◆ TaskManagerWndProc()

INT_PTR CALLBACK TaskManagerWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 183 of file taskmgr.c.

184{
185#if 0
186 HDC hdc;
187 PAINTSTRUCT ps;
188 RECT rc;
189#endif
190 LPRECT pRC;
191 LPNMHDR pnmh;
193
194 switch (message) {
195 case WM_INITDIALOG:
196 // For now, the Help dialog menu item is disabled because of lacking of HTML Help support
198 hMainWnd = hDlg;
199 return OnCreate(hDlg);
200
201 case WM_COMMAND:
202 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
203 EndDialog(hDlg, LOWORD(wParam));
204 return TRUE;
205 }
206 /* Process menu commands */
207 switch (LOWORD(wParam))
208 {
209 case ID_FILE_NEW:
211 break;
214 break;
217 break;
220 break;
223 break;
224 case ID_RESTORE:
226 break;
227 case ID_VIEW_LARGE:
228 case ID_VIEW_SMALL:
229 case ID_VIEW_DETAILS:
231 break;
234 break;
237 break;
240 break;
246 break;
249 break;
250 case ID_VIEW_REFRESH:
251 PostMessageW(hDlg, WM_TIMER, 0, 0);
252 break;
255 break;
258 break;
261 break;
264 break;
267 break;
270 break;
273 break;
276 break;
279 break;
282 break;
285 break;
288 break;
291 break;
294 break;
297 break;
300 break;
303 break;
306 break;
309 break;
312 break;
315 break;
316
317/* ShutDown items */
320 break;
323 break;
326 break;
329 break;
332 break;
335 break;
338 break;
341 break;
344 break;
345
346 case ID_HELP_ABOUT:
347 OnAbout();
348 break;
349 case ID_FILE_EXIT:
350 EndDialog(hDlg, IDOK);
351 break;
352 }
353 break;
354
355 case WM_ONTRAYICON:
356 switch(lParam)
357 {
358 case WM_RBUTTONDOWN:
359 {
360 POINT pt;
361 BOOL OnTop;
362 HMENU hMenu, hPopupMenu;
363
365
367
369 hPopupMenu = GetSubMenu(hMenu, 0);
370
372 DeleteMenu(hPopupMenu, ID_RESTORE, MF_BYCOMMAND);
373 else
374 SetMenuDefaultItem(hPopupMenu, ID_RESTORE, FALSE);
375
376 if(OnTop)
378 else
380
382 TrackPopupMenuEx(hPopupMenu, 0, pt.x, pt.y, hMainWnd, NULL);
383
384 DestroyMenu(hMenu);
385 break;
386 }
387 case WM_LBUTTONDBLCLK:
389 break;
390 }
391 break;
392
393 case WM_NOTIFY:
394 pnmh = (LPNMHDR)lParam;
395 if ((pnmh->hwndFrom == hTabWnd) &&
396 (pnmh->idFrom == IDC_TAB))
397 {
398 switch (pnmh->code)
399 {
400 case TCN_SELCHANGE:
402 break;
403 case TCN_KEYDOWN:
405 break;
406 case NM_CLICK:
408 break;
409 }
410 }
411 break;
412
413 case WM_SIZING:
414 /* Make sure the user is sizing the dialog */
415 /* in an acceptable range */
416 pRC = (LPRECT)lParam;
417 if ((wParam == WMSZ_LEFT) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_BOTTOMLEFT)) {
418 /* If the width is too small enlarge it to the minimum */
419 if (nMinimumWidth > (pRC->right - pRC->left))
420 pRC->left = pRC->right - nMinimumWidth;
421 } else {
422 /* If the width is too small enlarge it to the minimum */
423 if (nMinimumWidth > (pRC->right - pRC->left))
424 pRC->right = pRC->left + nMinimumWidth;
425 }
426 if ((wParam == WMSZ_TOP) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_TOPRIGHT)) {
427 /* If the height is too small enlarge it to the minimum */
428 if (nMinimumHeight > (pRC->bottom - pRC->top))
429 pRC->top = pRC->bottom - nMinimumHeight;
430 } else {
431 /* If the height is too small enlarge it to the minimum */
432 if (nMinimumHeight > (pRC->bottom - pRC->top))
433 pRC->bottom = pRC->top + nMinimumHeight;
434 }
435 return TRUE;
436 break;
437
438 case WM_SIZE:
439 /* Handle the window sizing in it's own function */
441 break;
442
443 case WM_MOVE:
444 /* Handle the window moving in it's own function */
446 break;
447
448 case WM_DESTROY:
449 ShowWindow(hDlg, SW_HIDE);
451 wp.length = sizeof(WINDOWPLACEMENT);
452 GetWindowPlacement(hDlg, &wp);
457 if (IsZoomed(hDlg) || (wp.flags & WPF_RESTORETOMAXIMIZED))
459 else
461 /* Get rid of the allocated command line cache, if any */
463 if (hWindowMenu)
465 return DefWindowProcW(hDlg, message, wParam, lParam);
466
467 case WM_TIMER:
468 /* Refresh the performance data */
474 break;
475
476 case WM_MENUSELECT:
478 break;
479
481 /* Forward WM_SYSCOLORCHANGE to common controls */
485 break;
486 }
487
488 return 0;
489}
void ProcessPage_OnSetAffinity(void)
Definition: affinity.c:26
void ApplicationPage_OnEndTask(void)
Definition: applpage.c:827
void ApplicationPage_OnWindowsCascade(void)
Definition: applpage.c:751
void ApplicationPage_OnWindowsBringToFront(void)
Definition: applpage.c:780
void ApplicationPage_OnWindowsMinimize(void)
Definition: applpage.c:709
void ApplicationPage_OnView(DWORD dwMode)
Definition: applpage.c:664
void ApplicationPage_OnWindowsTile(DWORD dwMode)
Definition: applpage.c:678
void ApplicationPage_OnGotoProcess(void)
Definition: applpage.c:851
void ApplicationPage_OnSwitchTo(void)
Definition: applpage.c:802
void ApplicationPage_OnWindowsMaximize(void)
Definition: applpage.c:730
#define ID_VIEW_REFRESH
Definition: resource.h:42
#define ID_HELP_ABOUT
Definition: resource.h:61
#define ID_FILE_EXIT
Definition: resource.h:46
#define ID_FILE_NEW
Definition: resource.h:40
void OnAbout(void)
Definition: about.c:10
void ProcessPage_OnDebug(void)
Definition: debug.c:11
#define ID_APPLICATION_PAGE_SWITCHTO
Definition: resource.h:170
#define ID_PROCESS_PAGE_SETPRIORITY_NORMAL
Definition: resource.h:184
#define ID_PROCESS_PAGE_PROPERTIES
Definition: resource.h:187
#define ID_SHUTDOWN_REBOOT
Definition: resource.h:193
#define ID_SHUTDOWN_EJECT_COMPUTER
Definition: resource.h:198
#define ID_WINDOWS_MINIMIZE
Definition: resource.h:156
#define ID_SHUTDOWN_SWITCHUSER
Definition: resource.h:195
#define ID_PROCESS_PAGE_SETPRIORITY_REALTIME
Definition: resource.h:181
#define ID_RESTORE
Definition: resource.h:173
#define ID_WINDOWS_MAXIMIZE
Definition: resource.h:157
#define ID_PROCESS_PAGE_ENDPROCESS
Definition: resource.h:177
#define ID_WINDOWS_BRINGTOFRONT
Definition: resource.h:159
#define ID_WINDOWS_TILEHORIZONTALLY
Definition: resource.h:154
#define ID_APPLICATION_PAGE_ENDTASK
Definition: resource.h:174
#define ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL
Definition: resource.h:185
#define IDR_TRAY_POPUP
Definition: resource.h:29
#define ID_SHUTDOWN_LOCKCOMPUTER
Definition: resource.h:196
#define ID_SHUTDOWN_DISCONNECT
Definition: resource.h:197
#define ID_SHUTDOWN_STANDBY
Definition: resource.h:190
#define ID_PROCESS_PAGE_DEBUG
Definition: resource.h:179
#define ID_WINDOWS_TILEVERTICALLY
Definition: resource.h:155
#define ID_PROCESS_PAGE_OPENFILELOCATION
Definition: resource.h:188
#define ID_PROCESS_PAGE_ENDPROCESSTREE
Definition: resource.h:178
#define ID_PROCESS_PAGE_SETAFFINITY
Definition: resource.h:180
#define ID_SHUTDOWN_POWEROFF
Definition: resource.h:192
#define ID_APPLICATION_PAGE_GOTOPROCESS
Definition: resource.h:175
#define ID_PROCESS_PAGE_SETPRIORITY_LOW
Definition: resource.h:186
#define ID_SHUTDOWN_HIBERNATE
Definition: resource.h:191
#define ID_PROCESS_PAGE_SETPRIORITY_HIGH
Definition: resource.h:182
#define ID_WINDOWS_CASCADE
Definition: resource.h:158
#define ID_HELP_TOPICS
Definition: resource.h:160
#define ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL
Definition: resource.h:183
void TaskManager_OnFileNew(void)
Definition: run.c:11
VOID ShutDown_Reboot(VOID)
Definition: shutdown.c:128
VOID ShutDown_StandBy(VOID)
Definition: shutdown.c:46
VOID ShutDown_SwitchUser(VOID)
Definition: shutdown.c:162
VOID ShutDown_EjectComputer(VOID)
Definition: shutdown.c:179
VOID ShutDown_Hibernate(VOID)
Definition: shutdown.c:73
VOID ShutDown_PowerOff(VOID)
Definition: shutdown.c:100
VOID ShutDown_LogOffUser(VOID)
Definition: shutdown.c:155
VOID ShutDown_Disconnect(VOID)
Definition: shutdown.c:174
VOID ShutDown_LockComputer(VOID)
Definition: shutdown.c:167
void ProcessPage_OnViewSelectColumns(void)
Definition: column.c:130
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define pt(x, y)
Definition: drawing.c:79
void ProcessPage_OnEndProcessTree(void)
Definition: endproc.c:146
void ProcessPage_OnEndProcess(void)
Definition: endproc.c:15
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
void TaskManager_OnOptionsAlwaysOnTop(void)
Definition: optnmenu.c:10
void TaskManager_OnOptionsHideWhenMinimized(void)
Definition: optnmenu.c:59
void TaskManager_OnOptionsShow16BitTasks(void)
Definition: optnmenu.c:82
void TaskManager_OnOptionsMinimizeOnUse(void)
Definition: optnmenu.c:36
void PerfDataDeallocCommandLineCache()
Definition: perfdata.c:633
void PerformancePage_OnViewShowKernelTimes(void)
Definition: perfpage.c:453
void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
Definition: perfpage.c:493
void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
Definition: perfpage.c:479
void DoSetPriority(DWORD priority)
Definition: priority.c:11
void ProcessPage_OnOpenFileLocation(void)
Definition: procpage.c:1220
HWND hProcessPageHeaderCtrl
Definition: procpage.c:29
void ProcessPage_OnProperties(void)
Definition: procpage.c:1181
#define TCN_KEYDOWN
Definition: commctrl.h:4123
#define NM_CLICK
Definition: commctrl.h:130
#define TCN_SELCHANGE
Definition: commctrl.h:4137
#define WM_NOTIFY
Definition: richedit.h:61
RECT rcNormalPosition
Definition: winuser.h:3298
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
void TaskManager_OnRestoreMainWindow(void)
Definition: taskmgr.c:860
BOOL OnCreate(HWND hWnd)
Definition: taskmgr.c:513
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: taskmgr.c:871
void TaskManager_OnViewUpdateSpeed(DWORD dwSpeed)
Definition: taskmgr.c:910
void OnMove(WPARAM nType, int cx, int cy)
Definition: taskmgr.c:716
void OnSize(WPARAM nType, int cx, int cy)
Definition: taskmgr.c:729
void TaskManager_OnTabWndSelChange(void)
Definition: taskmgr.c:928
BOOL TrayIcon_RemoveIcon(VOID)
Definition: trayicon.c:143
BOOL TrayIcon_UpdateIcon(VOID)
Definition: trayicon.c:158
#define WM_ONTRAYICON
Definition: trayicon.h:11
#define HIWORD(l)
Definition: typedefs.h:247
#define LPRECT
Definition: precomp.h:28
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:184
#define REALTIME_PRIORITY_CLASS
Definition: winbase.h:187
#define BELOW_NORMAL_PRIORITY_CLASS
Definition: winbase.h:193
#define HIGH_PRIORITY_CLASS
Definition: winbase.h:186
#define IDLE_PRIORITY_CLASS
Definition: winbase.h:185
#define ABOVE_NORMAL_PRIORITY_CLASS
Definition: winbase.h:194
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2473
#define IDCANCEL
Definition: winuser.h:834
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1781
#define WM_COMMAND
Definition: winuser.h:1743
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2722
#define WMSZ_TOP
Definition: winuser.h:2469
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1629
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
#define WMSZ_LEFT
Definition: winuser.h:2467
#define WM_RBUTTONDOWN
Definition: winuser.h:1782
BOOL WINAPI IsZoomed(_In_ HWND)
#define WMSZ_TOPLEFT
Definition: winuser.h:2470
#define WM_TIMER
Definition: winuser.h:1745
#define WMSZ_TOPRIGHT
Definition: winuser.h:2471
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5855
#define WM_MOVE
Definition: winuser.h:1613
#define WM_SIZING
Definition: winuser.h:1810
#define WPF_RESTORETOMAXIMIZED
Definition: winuser.h:2535
#define MDITILE_HORIZONTAL
Definition: winuser.h:2191
#define WM_DESTROY
Definition: winuser.h:1612
#define MDITILE_VERTICAL
Definition: winuser.h:2192
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define WM_MENUSELECT
Definition: winuser.h:1750
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by wWinMain().

◆ wWinMain()

int APIENTRY wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 94 of file taskmgr.c.

98{
100 HANDLE hToken;
103
104 /* check wether we're already running or not */
105 hMutex = CreateMutexW(NULL, TRUE, L"taskmgrros");
107 {
108 /* Restore existing taskmanager and bring window to front */
109 /* Relies on the fact that the application title string and window title are the same */
110 HWND hTaskMgr;
111 TCHAR szTaskmgr[128];
112
113 LoadString(hInst, IDS_APP_TITLE, szTaskmgr, _countof(szTaskmgr));
114 hTaskMgr = FindWindow(NULL, szTaskmgr);
115
116 if (hTaskMgr != NULL)
117 {
118 SendMessage(hTaskMgr, WM_SYSCOMMAND, SC_RESTORE, 0);
119 SetForegroundWindow(hTaskMgr);
120 }
121
123 return 0;
124 }
125 else if (!hMutex)
126 {
127 return 1;
128 }
129
130 /* Initialize global variables */
132
133 /* Change our priority class to HIGH */
137
138 /* Now lets get the SE_DEBUG_NAME privilege
139 * so that we can debug processes
140 */
141
142 /* Get a token for this process. */
144 {
145 /* Get the LUID for the debug privilege. */
147 {
148 tkp.PrivilegeCount = 1; /* one privilege to set */
150
151 /* Get the debug privilege for this process. */
152 AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
153 }
154 CloseHandle(hToken);
155 }
156
157 /* Load our settings from the registry */
158 LoadSettings();
159
160 /* Initialize perf data */
161 if (!PerfDataInitialize())
162 return -1;
163
164 /*
165 * Set our shutdown parameters: we want to shutdown the very last,
166 * without displaying any end task dialog if needed.
167 */
169
171
172 /* Save our settings to the registry */
173 SaveSettings();
176 if (hWindowMenu)
178 return 0;
179}
#define IDS_APP_TITLE
Definition: resource.h:10
#define IDD_TASKMGR_DIALOG
Definition: resource.h:11
HINSTANCE hInstance
Definition: charmap.c:19
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define GetCurrentProcess()
Definition: compat.h:759
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
BOOL WINAPI SetProcessShutdownParameters(IN DWORD dwLevel, IN DWORD dwFlags)
Definition: proc.c:949
BOOL WINAPI SetPriorityClass(IN HANDLE hProcess, IN DWORD dwPriorityClass)
Definition: proc.c:1698
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
HANDLE hMutex
Definition: mutex.c:11
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
BOOL PerfDataInitialize(void)
Definition: perfdata.c:49
void PerfDataUninitialize(void)
Definition: perfdata.c:70
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
INT_PTR CALLBACK TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: taskmgr.c:183
void SaveSettings(void)
Definition: taskmgr.c:846
void LoadSettings(void)
Definition: taskmgr.c:783
#define SHUTDOWN_NORETRY
Definition: winbase.h:474
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define SE_DEBUG_NAME
Definition: winnt_old.h:414
#define WM_SYSCOMMAND
Definition: winuser.h:1744
#define FindWindow
Definition: winuser.h:5789
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4402
#define LoadString
Definition: winuser.h:5831
#define SC_RESTORE
Definition: winuser.h:2601
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
char TCHAR
Definition: xmlstorage.h:189
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Variable Documentation

◆ bTrackMenu

BOOL bTrackMenu = FALSE

Definition at line 34 of file taskmgr.c.

Referenced by PerformancePageRefreshThread(), and TaskManager_OnMenuSelect().

◆ bWasKeyboardInput

BOOL bWasKeyboardInput = FALSE

Definition at line 35 of file taskmgr.c.

Referenced by TaskManager_OnTabWndSelChange(), and TaskManagerWndProc().

◆ hInst

◆ hMainWnd

◆ hStatusWnd

HWND hStatusWnd

Definition at line 23 of file taskmgr.c.

Referenced by OnCreate(), OnSize(), and TaskManager_OnMenuSelect().

◆ hTabWnd

HWND hTabWnd

Definition at line 24 of file taskmgr.c.

Referenced by OnCreate(), OnSize(), TaskManager_OnTabWndSelChange(), and TaskManagerWndProc().

◆ hWindowMenu

◆ nMinimumHeight

int nMinimumHeight

Definition at line 29 of file taskmgr.c.

Referenced by OnCreate(), and TaskManagerWndProc().

◆ nMinimumWidth

int nMinimumWidth

Definition at line 28 of file taskmgr.c.

Referenced by OnCreate(), and TaskManagerWndProc().

◆ nOldHeight

int nOldHeight

Definition at line 32 of file taskmgr.c.

Referenced by OnCreate(), and OnSize().

◆ nOldWidth

int nOldWidth

Definition at line 31 of file taskmgr.c.

Referenced by HEADER_MouseMove(), OnCreate(), and OnSize().

◆ TaskManagerSettings