ReactOS  0.4.15-dev-440-g5f37b68
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)
 
void FillSolidRect2 (HDC hDC, int x, int y, int cx, int cy, COLORREF clr)
 
void Draw3dRect (HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
 
void Draw3dRect2 (HDC hDC, LPRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight)
 
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_OnEnterMenuLoop (HWND hWnd)
 
void TaskManager_OnExitMenuLoop (HWND hWnd)
 
void TaskManager_OnMenuSelect (HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
 
void TaskManager_OnViewUpdateSpeed (DWORD dwSpeed)
 
void TaskManager_OnTabWndSelChange (void)
 
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 bInMenuLoop = FALSE
 
BOOL bWasKeyboardInput = FALSE
 
TASKMANAGER_SETTINGS TaskManagerSettings
 

Macro Definition Documentation

◆ ETDT_DISABLE

#define ETDT_DISABLE   0x00000001

Definition at line 65 of file taskmgr.c.

◆ ETDT_ENABLE

#define ETDT_ENABLE   0x00000002

Definition at line 66 of file taskmgr.c.

◆ ETDT_ENABLETAB

#define ETDT_ENABLETAB   (ETDT_ENABLE | ETDT_USETABTEXTURE)

Definition at line 68 of file taskmgr.c.

◆ ETDT_USETABTEXTURE

#define ETDT_USETABTEXTURE   0x00000004

Definition at line 67 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 32 of file taskmgr.c.

Typedef Documentation

◆ ETDTProc

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

Definition at line 71 of file taskmgr.c.

Function Documentation

◆ Draw3dRect()

void Draw3dRect ( HDC  hDC,
int  x,
int  y,
int  cx,
int  cy,
COLORREF  clrTopLeft,
COLORREF  clrBottomRight 
)

Definition at line 546 of file taskmgr.c.

547 {
548  FillSolidRect2(hDC, x, y, cx - 1, 1, clrTopLeft);
549  FillSolidRect2(hDC, x, y, 1, cy - 1, clrTopLeft);
550  FillSolidRect2(hDC, x + cx, y, -1, cy, clrBottomRight);
551  FillSolidRect2(hDC, x, y + cy, cx, -1, clrBottomRight);
552 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
void FillSolidRect2(HDC hDC, int x, int y, int cx, int cy, COLORREF clr)
Definition: taskmgr.c:534
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
static HDC hDC
Definition: 3dtext.c:33
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int * cx
Definition: commctrl.h:581

Referenced by Draw3dRect2(), PerformancePageWndProc(), and TaskManagerWndProc().

◆ Draw3dRect2()

void Draw3dRect2 ( HDC  hDC,
LPRECT  lpRect,
COLORREF  clrTopLeft,
COLORREF  clrBottomRight 
)

Definition at line 554 of file taskmgr.c.

555 {
556  Draw3dRect(hDC, lpRect->left, lpRect->top, lpRect->right - lpRect->left,
557  lpRect->bottom - lpRect->top, clrTopLeft, clrBottomRight);
558 }
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
Definition: taskmgr.c:546
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
static HDC hDC
Definition: 3dtext.c:33
LONG bottom
Definition: windef.h:309

◆ EnableDialogTheme()

BOOL EnableDialogTheme ( HWND  hwnd)

Definition at line 76 of file taskmgr.c.

77 {
78  HMODULE hUXTheme;
80 
81  hUXTheme = LoadLibraryA("uxtheme.dll");
82 
83  if(hUXTheme)
84  {
86  (ETDTProc)GetProcAddress(hUXTheme, "EnableThemeDialogTexture");
87 
89  {
91 
92  FreeLibrary(hUXTheme);
93  return TRUE;
94  }
95  else
96  {
97  // Failed to locate API!
98  FreeLibrary(hUXTheme);
99  return FALSE;
100  }
101  }
102  else
103  {
104  // Not running under XP? Just fail gracefully
105  return FALSE;
106  }
107 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HRESULT(WINAPI * ETDTProc)(HWND, DWORD)
Definition: taskmgr.c:71
#define ETDT_ENABLETAB
Definition: taskmgr.c:68
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define FreeLibrary(x)
Definition: compat.h:414
static ETDTProc fnEnableThemeDialogTexture
Definition: uxthemesupp.c:15
#define GetProcAddress(x, y)
Definition: compat.h:419

Referenced by OnCreate().

◆ EndLocalThread()

DWORD EndLocalThread ( HANDLE hThread,
DWORD  dwThread 
)

Definition at line 1175 of file taskmgr.c.

1176 {
1177  DWORD dwExitCodeThread = 0;
1178 
1179  if (*hThread != NULL) {
1180  PostThreadMessage(dwThread,WM_QUIT,0,0);
1181  for (;;) {
1182  MSG msg;
1183 
1185  break;
1186  while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
1188  DispatchMessage(&msg);
1189  }
1190  }
1191  GetExitCodeThread(*hThread, &dwExitCodeThread);
1192  CloseHandle(*hThread);
1193  *hThread = NULL;
1194  }
1195  return dwExitCodeThread;
1196 }
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5805
#define CloseHandle
Definition: compat.h:407
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WM_QUIT
Definition: winuser.h:1605
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
Definition: thread.c:540
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define PostThreadMessage
Definition: winuser.h:5808
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE hThread
Definition: wizard.c:27
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182

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

◆ FillSolidRect()

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

Definition at line 528 of file taskmgr.c.

529 {
530  SetBkColor(hDC, clr);
531  ExtTextOutW(hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
532 }
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)
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
#define ETO_OPAQUE
Definition: wingdi.h:646
smooth NULL
Definition: ftsmooth.c:416
static HDC hDC
Definition: 3dtext.c:33

Referenced by Graph_DrawCpuUsageGraph(), Graph_DrawMemUsageGraph(), and Graph_DrawMemUsageHistoryGraph().

◆ FillSolidRect2()

void FillSolidRect2 ( HDC  hDC,
int  x,
int  y,
int  cx,
int  cy,
COLORREF  clr 
)

Definition at line 534 of file taskmgr.c.

535 {
536  RECT rect;
537 
538  SetBkColor(hDC, clr);
539  rect.left = x;
540  rect.top = y;
541  rect.right = x + cx;
542  rect.bottom = y + cy;
543  ExtTextOutW(hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
544 }
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)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
& rect
Definition: startmenu.cpp:1413
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
#define ETO_OPAQUE
Definition: wingdi.h:646
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
static HDC hDC
Definition: 3dtext.c:33
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int * cx
Definition: commctrl.h:581

Referenced by Draw3dRect().

◆ GetLastErrorText()

LPWSTR GetLastErrorText ( LPWSTR  lpszBuf,
DWORD  dwSize 
)

Definition at line 1149 of file taskmgr.c.

1150 {
1151  DWORD dwRet;
1152  LPWSTR lpszTemp = NULL;
1153 
1155  NULL,
1156  GetLastError(),
1157  LANG_NEUTRAL,
1158  (LPWSTR)&lpszTemp,
1159  0,
1160  NULL );
1161 
1162  /* supplied buffer is not long enough */
1163  if (!dwRet || ( (long)dwSize < (long)dwRet+14)) {
1164  lpszBuf[0] = L'\0';
1165  } else {
1166  lpszTemp[lstrlenW(lpszTemp)-2] = L'\0'; /*remove cr and newline character */
1167  wsprintfW(lpszBuf, L"%s (0x%x)", lpszTemp, (int)GetLastError());
1168  }
1169  if (lpszTemp) {
1170  LocalFree((HLOCAL)lpszTemp);
1171  }
1172  return lpszBuf;
1173 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define LANG_NEUTRAL
Definition: nls.h:22
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define lstrlenW
Definition: compat.h:416
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

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

◆ LoadSettings()

void LoadSettings ( void  )

Definition at line 848 of file taskmgr.c.

849 {
850  HKEY hKey;
851  WCHAR szSubKey[] = L"Software\\ReactOS\\TaskManager";
852  int i;
853  DWORD dwSize;
854 
855  /* Window size & position settings */
861 
862  /* Tab settings */
864 
865  /* Options menu settings */
870 
871  /* Update speed settings */
873 
874  /* Applications page settings */
876 
877  /* Processes page settings */
879 
880  for (i = 0; i < COLUMN_NMAX; i++) {
884  }
885 
888 
889  /* Performance page settings */
892 
893  /* Open the key */
894  if (RegOpenKeyExW(HKEY_CURRENT_USER, szSubKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
895  return;
896  /* Read the settings */
897  dwSize = sizeof(TASKMANAGER_SETTINGS);
898  RegQueryValueExW(hKey, L"Preferences", NULL, NULL, (LPBYTE)&TaskManagerSettings, &dwSize);
899 
900  /*
901  * ATM, the 'ImageName' column is always visible
902  * (and grayed in configuration dialog)
903  * This will avoid troubles if the registry gets corrupted.
904  */
905  TaskManagerSettings.Column_ImageName = TRUE;
906 
907  /* Close the key */
908  RegCloseKey(hKey);
909 }
#define ID_VIEW_DETAILS
Definition: resource.h:36
#define TRUE
Definition: types.h:120
#define COLUMN_NMAX
Definition: column.h:51
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL HideWhenMinimized
Definition: taskmgr.h:68
int ColumnSizeArray[COLUMN_NMAX]
Definition: taskmgr.h:82
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
const PresetColumnEntry ColumnPresets[COLUMN_NMAX]
Definition: column.c:31
smooth NULL
Definition: ftsmooth.c:416
#define COLUMN_IMAGENAME
Definition: column.h:25
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL bDefaults
Definition: column.h:76
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Columns[COLUMN_NMAX]
Definition: taskmgr.h:80
BOOL ShowProcessesFromAllUsers
Definition: taskmgr.h:79
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
int ColumnOrderArray[COLUMN_NMAX]
Definition: taskmgr.h:81
#define ID_VIEW_UPDATESPEED_NORMAL
Definition: resource.h:146
BOOL CPUHistory_OneGraphPerCPU
Definition: taskmgr.h:87
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by wWinMain().

◆ OnCreate()

BOOL OnCreate ( HWND  hWnd)

Definition at line 576 of file taskmgr.c.

577 {
578  HMENU hMenu;
579  HMENU hEditMenu;
580  HMENU hViewMenu;
581  HMENU hShutMenu;
582  HMENU hUpdateSpeedMenu;
583  HMENU hCPUHistoryMenu;
584  int nActivePage;
585  int nParts[3];
586  RECT rc;
587  WCHAR szTemp[256];
588  WCHAR szLogOffItem[MAX_PATH];
589  LPWSTR lpUserName;
590  TCITEM item;
591  DWORD len = 0;
592 
594 
595  /* Initialize the Windows Common Controls DLL */
597 
598  /* Get the minimum window sizes */
599  GetWindowRect(hWnd, &rc);
600  nMinimumWidth = (rc.right - rc.left);
601  nMinimumHeight = (rc.bottom - rc.top);
602 
603  /* Create the status bar */
605  if(!hStatusWnd)
606  return FALSE;
607 
608  /* Create the status bar panes */
609  nParts[0] = STATUS_SIZE1;
610  nParts[1] = STATUS_SIZE2;
611  nParts[2] = STATUS_SIZE3;
613 
614  /* Create tab pages */
616 #if 1
620 #else
624 #endif
625 
626  /* Insert tabs */
627  LoadStringW(hInst, IDS_TAB_APPS, szTemp, 256);
628  memset(&item, 0, sizeof(TCITEM));
629  item.mask = TCIF_TEXT;
630  item.pszText = szTemp;
632  LoadStringW(hInst, IDS_TAB_PROCESSES, szTemp, 256);
633  memset(&item, 0, sizeof(TCITEM));
634  item.mask = TCIF_TEXT;
635  item.pszText = szTemp;
637  LoadStringW(hInst, IDS_TAB_PERFORMANCE, szTemp, 256);
638  memset(&item, 0, sizeof(TCITEM));
639  item.mask = TCIF_TEXT;
640  item.pszText = szTemp;
642 
643  /* Size everything correctly */
644  GetClientRect(hWnd, &rc);
645  nOldWidth = rc.right;
646  nOldHeight = rc.bottom;
647  /* nOldStartX = rc.left; */
648  /*nOldStartY = rc.top; */
649 
650 #define PAGE_OFFSET_LEFT 17
651 #define PAGE_OFFSET_TOP 72
652 #define PAGE_OFFSET_WIDTH (PAGE_OFFSET_LEFT*2)
653 #define PAGE_OFFSET_HEIGHT (PAGE_OFFSET_TOP+32)
654 
655  if ((TaskManagerSettings.Left != 0) ||
656  (TaskManagerSettings.Top != 0) ||
657  (TaskManagerSettings.Right != 0) ||
659  {
661 #ifdef __GNUC__TEST__
665 #endif
666  }
669 
670  /* Set the always on top style */
671  hMenu = GetMenu(hWnd);
672  hEditMenu = GetSubMenu(hMenu, 1);
673  hViewMenu = GetSubMenu(hMenu, 2);
674  hShutMenu = GetSubMenu(hMenu, 4);
675  hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
676  hCPUHistoryMenu = GetSubMenu(hViewMenu, 7);
677 
678  /* Check or uncheck the always on top menu item */
682  } else {
685  }
686 
687  /* Check or uncheck the minimize on use menu item */
690  else
692 
693  /* Check or uncheck the hide when minimized menu item */
696  else
698 
699  /* Check or uncheck the show 16-bit tasks menu item */
702  else
704 
705  /* Set the view mode */
707 
710  else
712 
714 
717  else
719 
720  nActivePage = TaskManagerSettings.ActiveTabPage;
721  TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 0);
722  TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 1);
723  TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 2);
724  TabCtrl_SetCurFocus/*Sel*/(hTabWnd, nActivePage);
725 
726  /* Set the username in the "Log Off %s" item of the Shutdown menu */
727 
728  /* 1- Get the menu item text and store it temporarily */
729  GetMenuStringW(hShutMenu, ID_SHUTDOWN_LOGOFF, szTemp, 256, MF_BYCOMMAND);
730 
731  /* 2- Retrieve the username length first, then allocate a buffer for it and call it again */
733  {
734  lpUserName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
735  if (lpUserName && GetUserNameW(lpUserName, &len))
736  {
737  _snwprintf(szLogOffItem, sizeof(szLogOffItem)/sizeof(szLogOffItem[0]), szTemp, lpUserName);
738  szLogOffItem[sizeof(szLogOffItem)/sizeof(szLogOffItem[0]) - 1] = UNICODE_NULL;
739  }
740  else
741  {
742  _snwprintf(szLogOffItem, sizeof(szLogOffItem)/sizeof(szLogOffItem[0]), szTemp, L"n/a");
743  }
744 
745  if (lpUserName) HeapFree(GetProcessHeap(), 0, lpUserName);
746  }
747  else
748  {
749  _snwprintf(szLogOffItem, sizeof(szLogOffItem)/sizeof(szLogOffItem[0]), szTemp, L"n/a");
750  }
751 
752  /* 3- Set the menu item text to its formatted counterpart */
754 
755  /* Setup update speed */
757 
758  /*
759  * Refresh the performance data
760  * Sample it twice so we can establish
761  * the delta values & cpu usage
762  */
763  PerfDataRefresh();
764  PerfDataRefresh();
765 
769 
771 
772  return TRUE;
773 }
INT_PTR CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: applpage.c:110
HINSTANCE hInst
Definition: taskmgr.c:35
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define STATUS_SIZE3
Definition: taskmgr.h:51
#define ID_VIEW_DETAILS
Definition: resource.h:36
#define TRUE
Definition: types.h:120
HWND hApplicationPage
Definition: applpage.c:34
#define ID_OPTIONS_HIDEWHENMINIMIZED
Definition: resource.h:140
#define PAGE_OFFSET_LEFT
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
BOOL WINAPI ModifyMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDC_TAB
Definition: resource.h:12
#define STATUS_SIZE2
Definition: taskmgr.h:50
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
HWND hTabWnd
Definition: taskmgr.c:39
#define ID_OPTIONS_ALWAYSONTOP
Definition: resource.h:138
#define MF_STRING
Definition: winuser.h:138
HWND hWnd
Definition: settings.c:17
BOOL HideWhenMinimized
Definition: taskmgr.h:68
LONG top
Definition: windef.h:307
#define ID_VIEW_UPDATESPEED_HIGH
Definition: resource.h:145
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HWND_TOPMOST
Definition: winuser.h:1194
int nMinimumHeight
Definition: taskmgr.c:44
#define ID_OPTIONS_SHOW16BITTASKS
Definition: resource.h:158
#define WS_CHILD
Definition: pedump.c:617
#define TCIF_TEXT
Definition: commctrl.h:3967
void RefreshProcessPage(void)
Definition: procpage.c:408
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:308
HWND hPerformancePage
Definition: perfpage.c:31
#define PAGE_OFFSET_HEIGHT
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static void SetUpdateSpeed(HWND hWnd)
Definition: taskmgr.c:560
HWND hStatusWnd
Definition: taskmgr.c:38
int WINAPI GetMenuStringW(_In_ HMENU hMenu, _In_ UINT uIDItem, _Out_writes_opt_(cchMax) LPWSTR lpString, _In_ int cchMax, _In_ UINT flags)
#define UNICODE_NULL
#define ID_OPTIONS_MINIMIZEONUSE
Definition: resource.h:139
#define ID_VIEW_CPUHISTORY_ONEGRAPHALL
Definition: resource.h:162
#define CreateStatusWindow
Definition: commctrl.h:1929
int nOldWidth
Definition: taskmgr.c:46
#define ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
Definition: resource.h:163
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define IDD_APPLICATION_PAGE
Definition: resource.h:8
#define IDD_PROCESS_PAGE
Definition: resource.h:14
#define MF_CHECKED
Definition: winuser.h:132
#define STATUS_SIZE1
Definition: taskmgr.h:49
int nOldHeight
Definition: taskmgr.c:47
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
void RefreshApplicationPage(void)
Definition: applpage.c:247
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
void RefreshPerformancePage(void)
Definition: perfpage.c:306
#define MAX_PATH
Definition: compat.h:26
#define ID_VIEW_SHOWKERNELTIMES
Definition: resource.h:161
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define IDI_TASKMANAGER
Definition: resource.h:17
static const WCHAR L[]
Definition: oid.c:1250
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4256
GLenum GLsizei len
Definition: glext.h:6722
#define ID_VIEW_UPDATESPEED_PAUSED
Definition: resource.h:148
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
INT_PTR CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: perfpage.c:113
#define MF_UNCHECKED
Definition: winuser.h:204
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define SWP_NOSIZE
Definition: winuser.h:1230
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define IDS_TAB_PERFORMANCE
Definition: resource.h:197
#define IDD_PERFORMANCE_PAGE
Definition: resource.h:15
static ATOM item
Definition: dde.c:856
#define IDS_TAB_PROCESSES
Definition: resource.h:196
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL TrayIcon_ShellAddTrayIcon(void)
Definition: trayicon.c:129
HWND hProcessPage
Definition: procpage.c:36
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define SB_SETPARTS
Definition: commctrl.h:1950
#define PAGE_OFFSET_WIDTH
int nMinimumWidth
Definition: taskmgr.c:43
#define TabCtrl_InsertItem(hwnd, iItem, pitem)
Definition: commctrl.h:4047
BOOL EnableDialogTheme(HWND hwnd)
Definition: taskmgr.c:76
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
LONG bottom
Definition: windef.h:309
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define HWND_NOTOPMOST
Definition: winuser.h:1192
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define TCITEM
Definition: commctrl.h:4025
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDS_TAB_APPS
Definition: resource.h:195
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
HMENU WINAPI GetMenu(_In_ HWND)
#define SW_MAXIMIZE
Definition: winuser.h:766
INT_PTR CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: procpage.c:132
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HWND hMainWnd
Definition: taskmgr.c:37
BOOL CPUHistory_OneGraphPerCPU
Definition: taskmgr.h:87
#define SBT_NOBORDERS
Definition: commctrl.h:1967
#define HeapFree(x, y, z)
Definition: compat.h:403
#define STATUS_WINDOW
Definition: taskmgr.c:32
#define ICON_BIG
Definition: tnclass.cpp:51
#define ID_VIEW_LARGE
Definition: resource.h:33
#define PAGE_OFFSET_TOP
void PerfDataRefresh(void)
Definition: perfdata.c:175
#define ID_SHUTDOWN_LOGOFF
Definition: resource.h:187
#define TabCtrl_SetCurFocus(hwnd, i)
Definition: commctrl.h:4098
int * LPINT
Definition: windef.h:178
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by TaskManagerWndProc().

◆ OnMove()

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

Definition at line 779 of file taskmgr.c.

780 {
781 #ifdef __GNUC__TEST__
785 #endif
786 }
HWND hApplicationPage
Definition: applpage.c:34
#define PAGE_OFFSET_LEFT
HWND hPerformancePage
Definition: perfpage.c:31
#define PAGE_OFFSET_HEIGHT
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
HWND hProcessPage
Definition: procpage.c:36
#define PAGE_OFFSET_WIDTH
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
#define PAGE_OFFSET_TOP

Referenced by TaskManagerWndProc().

◆ OnSize()

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

Definition at line 792 of file taskmgr.c.

793 {
794  int nParts[3];
795  int nXDifference;
796  int nYDifference;
797  RECT rc;
798 
799  if (nType == SIZE_MINIMIZED)
800  {
802  {
804  }
805  return;
806  }
807 
808  nXDifference = cx - nOldWidth;
809  nYDifference = cy - nOldHeight;
810  nOldWidth = cx;
811  nOldHeight = cy;
812 
813  /* Update the status bar size */
816 
817  /* Update the status bar pane sizes */
818  nParts[0] = bInMenuLoop ? -1 : STATUS_SIZE1;
819  nParts[1] = STATUS_SIZE2;
820  nParts[2] = cx;
822 
823  /* Resize the tab control */
824  GetWindowRect(hTabWnd, &rc);
825  cx = (rc.right - rc.left) + nXDifference;
826  cy = (rc.bottom - rc.top) + nYDifference;
828 
829  /* Resize the application page */
831  cx = (rc.right - rc.left) + nXDifference;
832  cy = (rc.bottom - rc.top) + nYDifference;
834 
835  /* Resize the process page */
837  cx = (rc.right - rc.left) + nXDifference;
838  cy = (rc.bottom - rc.top) + nYDifference;
840 
841  /* Resize the performance page */
843  cx = (rc.right - rc.left) + nXDifference;
844  cy = (rc.bottom - rc.top) + nYDifference;
846 }
HWND hApplicationPage
Definition: applpage.c:34
#define STATUS_SIZE2
Definition: taskmgr.h:50
#define SW_HIDE
Definition: winuser.h:762
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
HWND hTabWnd
Definition: taskmgr.c:39
BOOL HideWhenMinimized
Definition: taskmgr.h:68
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:308
HWND hPerformancePage
Definition: perfpage.c:31
HWND hStatusWnd
Definition: taskmgr.c:38
int nOldWidth
Definition: taskmgr.c:46
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define STATUS_SIZE1
Definition: taskmgr.h:49
int nOldHeight
Definition: taskmgr.c:47
#define WM_SIZE
Definition: winuser.h:1593
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define SIZE_MINIMIZED
Definition: winuser.h:2481
BOOL bInMenuLoop
Definition: taskmgr.c:49
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND hProcessPage
Definition: procpage.c:36
#define SB_SETPARTS
Definition: commctrl.h:1950
_Out_opt_ int * cx
Definition: commctrl.h:581
LONG bottom
Definition: windef.h:309
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HWND hMainWnd
Definition: taskmgr.c:37
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234
int * LPINT
Definition: windef.h:178

Referenced by TaskManagerWndProc().

◆ SaveSettings()

void SaveSettings ( void  )

Definition at line 911 of file taskmgr.c.

912 {
913  HKEY hKey;
914  WCHAR szSubKey[] = L"Software\\ReactOS\\TaskManager";
915 
916  /* Open (or create) the key */
918  return;
919  /* Save the settings */
920  RegSetValueExW(hKey, L"Preferences", 0, REG_BINARY, (LPBYTE)&TaskManagerSettings, sizeof(TASKMANAGER_SETTINGS));
921  /* Close the key */
922  RegCloseKey(hKey);
923 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
#define HKEY_CURRENT_USER
Definition: winreg.h:11
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:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
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:4895
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52

Referenced by wWinMain().

◆ SetUpdateSpeed()

static void SetUpdateSpeed ( HWND  hWnd)
static

Definition at line 560 of file taskmgr.c.

561 {
562  /* Setup update speed (pause=fall down) */
565  SetTimer(hWnd, 1, 1000, NULL);
566  break;
568  SetTimer(hWnd, 1, 2000, NULL);
569  break;
571  SetTimer(hWnd, 1, 4000, NULL);
572  break;
573  }
574 }
HWND hWnd
Definition: settings.c:17
#define ID_VIEW_UPDATESPEED_HIGH
Definition: resource.h:145
smooth NULL
Definition: ftsmooth.c:416
#define ID_VIEW_UPDATESPEED_LOW
Definition: resource.h:147
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
#define ID_VIEW_UPDATESPEED_NORMAL
Definition: resource.h:146

Referenced by OnCreate(), and TaskManager_OnViewUpdateSpeed().

◆ ShowWin32Error()

VOID ShowWin32Error ( DWORD  dwError)

Definition at line 1133 of file taskmgr.c.

1134 {
1135  LPWSTR lpMessageBuffer;
1136 
1138  NULL,
1139  dwError,
1141  (LPWSTR)&lpMessageBuffer,
1142  0, NULL) != 0)
1143  {
1144  MessageBoxW(hMainWnd, lpMessageBuffer, NULL, MB_OK | MB_ICONERROR);
1145  if (lpMessageBuffer) LocalFree(lpMessageBuffer);
1146  }
1147 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define MB_ICONERROR
Definition: winuser.h:781
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define MB_OK
Definition: winuser.h:784
#define MAKELANGID(p, s)
Definition: nls.h:15
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HWND hMainWnd
Definition: taskmgr.c:37

◆ TaskManager_OnEnterMenuLoop()

void TaskManager_OnEnterMenuLoop ( HWND  hWnd)

Definition at line 939 of file taskmgr.c.

940 {
941  int nParts;
942 
943  /* Update the status bar pane sizes */
944  nParts = -1;
946  bInMenuLoop = TRUE;
948 }
#define TRUE
Definition: types.h:120
UINT_PTR WPARAM
Definition: windef.h:207
HWND hStatusWnd
Definition: taskmgr.c:38
LONG_PTR LPARAM
Definition: windef.h:208
static const WCHAR L[]
Definition: oid.c:1250
#define SB_SETTEXT
Definition: commctrl.h:1945
BOOL bInMenuLoop
Definition: taskmgr.c:49
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1950
int * LPINT
Definition: windef.h:178

Referenced by TaskManagerWndProc().

◆ TaskManager_OnExitMenuLoop()

void TaskManager_OnExitMenuLoop ( HWND  hWnd)

Definition at line 950 of file taskmgr.c.

951 {
952  RECT rc;
953  int nParts[3];
954 
955  bInMenuLoop = FALSE;
956 
957  /* Update the status bar pane sizes */
958  GetClientRect(hWnd, &rc);
959  nParts[0] = STATUS_SIZE1;
960  nParts[1] = STATUS_SIZE2;
961  nParts[2] = rc.right;
963 
964  /* trigger update of status bar columns and performance page asynchronously */
966 }
#define STATUS_SIZE2
Definition: taskmgr.h:50
HWND hWnd
Definition: settings.c:17
LONG right
Definition: windef.h:308
HWND hStatusWnd
Definition: taskmgr.c:38
LONG_PTR LPARAM
Definition: windef.h:208
#define STATUS_SIZE1
Definition: taskmgr.h:49
void RefreshPerformancePage(void)
Definition: perfpage.c:306
BOOL bInMenuLoop
Definition: taskmgr.c:49
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1950
int * LPINT
Definition: windef.h:178

Referenced by TaskManagerWndProc().

◆ TaskManager_OnMenuSelect()

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

Definition at line 968 of file taskmgr.c.

969 {
970  WCHAR str[100];
971 
972  wcscpy(str, L"");
973  if (LoadStringW(hInst, nItemID, str, 100)) {
974  /* load appropriate string */
975  LPWSTR lpsz = str;
976  /* first newline terminates actual string */
977  lpsz = wcschr(lpsz, '\n');
978  if (lpsz != NULL)
979  *lpsz = '\0';
980  }
982 }
HINSTANCE hInst
Definition: taskmgr.c:35
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HWND hStatusWnd
Definition: taskmgr.c:38
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define SB_SETTEXT
Definition: commctrl.h:1945
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by TaskManagerWndProc().

◆ TaskManager_OnRestoreMainWindow()

void TaskManager_OnRestoreMainWindow ( void  )

Definition at line 925 of file taskmgr.c.

926 {
927  //HMENU hMenu, hOptionsMenu;
928  BOOL OnTop;
929 
930  //hMenu = GetMenu(hMainWnd);
931  //hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
933 
937 }
#define GWL_EXSTYLE
Definition: winuser.h:845
#define HWND_TOPMOST
Definition: winuser.h:1194
#define HWND_TOP
Definition: winuser.h:1193
#define GetWindowLongPtrW
Definition: winuser.h:4804
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI OpenIcon(_In_ HWND)
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define SWP_NOSIZE
Definition: winuser.h:1230
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HWND hMainWnd
Definition: taskmgr.c:37

Referenced by TaskManagerWndProc().

◆ TaskManager_OnTabWndSelChange()

void TaskManager_OnTabWndSelChange ( void  )

Definition at line 1002 of file taskmgr.c.

1003 {
1004  int i;
1005  HMENU hMenu;
1006  HMENU hOptionsMenu;
1007  HMENU hViewMenu;
1008  HMENU hSubMenu;
1009  WCHAR szTemp[256];
1010  SYSTEM_INFO sysInfo;
1011 
1012  hMenu = GetMenu(hMainWnd);
1013  hViewMenu = GetSubMenu(hMenu, 2);
1014  hOptionsMenu = GetSubMenu(hMenu, 1);
1016  for (i = GetMenuItemCount(hViewMenu) - 1; i > 2; i--) {
1017  hSubMenu = GetSubMenu(hViewMenu, i);
1018  if (hSubMenu)
1019  DestroyMenu(hSubMenu);
1020  RemoveMenu(hViewMenu, i, MF_BYPOSITION);
1021  }
1022  RemoveMenu(hOptionsMenu, 3, MF_BYPOSITION);
1023  if (hWindowMenu)
1026  case 0:
1031 
1032  LoadStringW(hInst, IDS_MENU_LARGEICONS, szTemp, 256);
1033  AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_LARGE, szTemp);
1034 
1035  LoadStringW(hInst, IDS_MENU_SMALLICONS, szTemp, 256);
1036  AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SMALL, szTemp);
1037 
1038  LoadStringW(hInst, IDS_MENU_DETAILS, szTemp, 256);
1039  AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_DETAILS, szTemp);
1040 
1041  if (GetMenuItemCount(hMenu) <= 5) {
1043 
1044  LoadStringW(hInst, IDS_MENU_WINDOWS, szTemp, 256);
1045  InsertMenuW(hMenu, 3, MF_BYPOSITION|MF_POPUP, (UINT_PTR) hWindowMenu, szTemp);
1046 
1048  }
1050 
1051  /*
1052  * Give the application list control focus
1053  */
1054  if (!bWasKeyboardInput)
1056  break;
1057 
1058  case 1:
1063 
1064  LoadStringW(hInst, IDS_MENU_SELECTCOLUMNS, szTemp, 256);
1065  AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SELECTCOLUMNS, szTemp);
1066 
1067  LoadStringW(hInst, IDS_MENU_16BITTASK, szTemp, 256);
1068  AppendMenuW(hOptionsMenu, MF_STRING, ID_OPTIONS_SHOW16BITTASKS, szTemp);
1069 
1072  if (GetMenuItemCount(hMenu) > 5)
1073  {
1074  DeleteMenu(hMenu, 3, MF_BYPOSITION);
1076  }
1077  /*
1078  * Give the process list control focus
1079  */
1080  if (!bWasKeyboardInput)
1082  break;
1083 
1084  case 2:
1089  if (GetMenuItemCount(hMenu) > 5) {
1090  DeleteMenu(hMenu, 3, MF_BYPOSITION);
1092  }
1093 
1094  GetSystemInfo(&sysInfo);
1095 
1096  /* Hide CPU graph options on single CPU systems */
1097  if (sysInfo.dwNumberOfProcessors > 1)
1098  {
1099  hSubMenu = CreatePopupMenu();
1100 
1103 
1104  LoadStringW(hInst, IDS_MENU_ONEGRAPHPERCPU, szTemp, 256);
1106 
1107  LoadStringW(hInst, IDS_MENU_CPUHISTORY, szTemp, 256);
1108  AppendMenuW(hViewMenu, MF_STRING|MF_POPUP, (UINT_PTR) hSubMenu, szTemp);
1109 
1112  else
1114  }
1115 
1117  AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, szTemp);
1118 
1121  else
1123 
1124  /*
1125  * Give the tab control focus
1126  */
1127  if (!bWasKeyboardInput)
1128  SetFocus(hTabWnd);
1129  break;
1130  }
1131 }
#define IDS_MENU_DETAILS
Definition: resource.h:232
HINSTANCE hInst
Definition: taskmgr.c:35
#define IDR_WINDOWSMENU
Definition: resource.h:16
#define ID_VIEW_DETAILS
Definition: resource.h:36
HWND hApplicationPage
Definition: applpage.c:34
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define IDS_MENU_SHOWKERNELTIMES
Definition: resource.h:236
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDS_MENU_ONEGRAPHALLCPUS
Definition: resource.h:233
BOOL WINAPI InsertMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
HWND hTabWnd
Definition: taskmgr.c:39
#define MF_STRING
Definition: winuser.h:138
HWND WINAPI SetFocus(_In_opt_ HWND)
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4059
#define ID_OPTIONS_SHOW16BITTASKS
Definition: resource.h:158
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND hApplicationPageListCtrl
Definition: applpage.c:35
HWND hPerformancePage
Definition: perfpage.c:31
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
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 ID_VIEW_CPUHISTORY_ONEGRAPHALL
Definition: resource.h:162
#define MF_BYPOSITION
Definition: winuser.h:203
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI BringWindowToTop(_In_ HWND)
#define ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
Definition: resource.h:163
#define SW_SHOW
Definition: winuser.h:769
#define MF_CHECKED
Definition: winuser.h:132
BOOL bWasKeyboardInput
Definition: taskmgr.c:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_VIEW_SHOWKERNELTIMES
Definition: resource.h:161
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define IDS_MENU_SMALLICONS
Definition: resource.h:231
#define IDS_MENU_ONEGRAPHPERCPU
Definition: resource.h:234
#define MF_POPUP
Definition: winuser.h:136
#define IDS_MENU_LARGEICONS
Definition: resource.h:230
#define ID_VIEW_SELECTCOLUMNS
Definition: resource.h:160
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define IDS_MENU_CPUHISTORY
Definition: resource.h:235
#define MF_UNCHECKED
Definition: winuser.h:204
#define ID_VIEW_SMALL
Definition: resource.h:34
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define IDS_MENU_WINDOWS
Definition: resource.h:229
HMENU hWindowMenu
Definition: taskmgr.c:41
#define IDS_MENU_16BITTASK
Definition: resource.h:228
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:142
HWND hProcessPage
Definition: procpage.c:36
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
DWORD dwNumberOfProcessors
Definition: winbase.h:1143
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
#define IDS_MENU_SELECTCOLUMNS
Definition: resource.h:227
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HWND hProcessPageListCtrl
Definition: procpage.c:38
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HWND hMainWnd
Definition: taskmgr.c:37
BOOL CPUHistory_OneGraphPerCPU
Definition: taskmgr.h:87
#define ID_VIEW_LARGE
Definition: resource.h:33

Referenced by TaskManagerWndProc().

◆ TaskManager_OnViewUpdateSpeed()

void TaskManager_OnViewUpdateSpeed ( DWORD  dwSpeed)

Definition at line 984 of file taskmgr.c.

985 {
986  HMENU hMenu;
987  HMENU hViewMenu;
988  HMENU hUpdateSpeedMenu;
989 
990  hMenu = GetMenu(hMainWnd);
991  hViewMenu = GetSubMenu(hMenu, 2);
992  hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
993 
996 
997  KillTimer(hMainWnd, 1);
998 
1000 }
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI CheckMenuRadioItem(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT, _In_ UINT)
#define ID_VIEW_UPDATESPEED_HIGH
Definition: resource.h:145
static void SetUpdateSpeed(HWND hWnd)
Definition: taskmgr.c:560
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define ID_VIEW_UPDATESPEED_PAUSED
Definition: resource.h:148
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HWND hMainWnd
Definition: taskmgr.c:37

Referenced by TaskManagerWndProc().

◆ TaskManagerWndProc()

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

Definition at line 200 of file taskmgr.c.

201 {
202 #if 0
203  HDC hdc;
204  PAINTSTRUCT ps;
205  RECT rc;
206 #endif
207  LPRECT pRC;
208  LPNMHDR pnmh;
209  WINDOWPLACEMENT wp;
210 
211  switch (message) {
212  case WM_INITDIALOG:
213  // For now, the Help dialog menu item is disabled because of lacking of HTML Help support
215  hMainWnd = hDlg;
216  return OnCreate(hDlg);
217 
218  case WM_COMMAND:
219  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
220  EndDialog(hDlg, LOWORD(wParam));
221  return TRUE;
222  }
223  /* Process menu commands */
224  switch (LOWORD(wParam))
225  {
226  case ID_FILE_NEW:
228  break;
231  break;
234  break;
237  break;
240  break;
241  case ID_RESTORE:
243  break;
244  case ID_VIEW_LARGE:
245  case ID_VIEW_SMALL:
246  case ID_VIEW_DETAILS:
248  break;
251  break;
254  break;
257  break;
263  break;
266  break;
267  case ID_VIEW_REFRESH:
268  PostMessageW(hDlg, WM_TIMER, 0, 0);
269  break;
272  break;
275  break;
276  case ID_WINDOWS_MINIMIZE:
278  break;
279  case ID_WINDOWS_MAXIMIZE:
281  break;
282  case ID_WINDOWS_CASCADE:
284  break;
287  break;
290  break;
293  break;
296  break;
299  break;
302  break;
305  break;
308  break;
311  break;
314  break;
317  break;
320  break;
323  break;
326  break;
327 
328 /* ShutDown items */
329  case ID_SHUTDOWN_STANDBY:
331  break;
334  break;
337  break;
338  case ID_SHUTDOWN_REBOOT:
339  ShutDown_Reboot();
340  break;
341  case ID_SHUTDOWN_LOGOFF:
343  break;
346  break;
349  break;
352  break;
355  break;
356 
357  case ID_HELP_ABOUT:
358  OnAbout();
359  break;
360  case ID_FILE_EXIT:
361  EndDialog(hDlg, IDOK);
362  break;
363  }
364  break;
365 
366  case WM_ONTRAYICON:
367  switch(lParam)
368  {
369  case WM_RBUTTONDOWN:
370  {
371  POINT pt;
372  BOOL OnTop;
373  HMENU hMenu, hPopupMenu;
374 
375  GetCursorPos(&pt);
376 
378 
380  hPopupMenu = GetSubMenu(hMenu, 0);
381 
383  {
384  DeleteMenu(hPopupMenu, ID_RESTORE, MF_BYCOMMAND);
385  }
386  else
387  {
388  SetMenuDefaultItem(hPopupMenu, ID_RESTORE, FALSE);
389  }
390 
391  if(OnTop)
392  {
394  } else
395  {
397  }
398 
400  TrackPopupMenuEx(hPopupMenu, 0, pt.x, pt.y, hMainWnd, NULL);
401 
402  DestroyMenu(hMenu);
403  break;
404  }
405  case WM_LBUTTONDBLCLK:
407  break;
408  }
409  break;
410 
411  case WM_NOTIFY:
412  pnmh = (LPNMHDR)lParam;
413  if ((pnmh->hwndFrom == hTabWnd) &&
414  (pnmh->idFrom == IDC_TAB))
415  {
416  switch (pnmh->code)
417  {
418  case TCN_SELCHANGE:
420  break;
421  case TCN_KEYDOWN:
423  break;
424  case NM_CLICK:
426  break;
427  }
428  }
429  break;
430 #if 0
431  case WM_NCPAINT:
432  hdc = GetDC(hDlg);
433  GetClientRect(hDlg, &rc);
435  ReleaseDC(hDlg, hdc);
436  break;
437 
438  case WM_PAINT:
439  hdc = BeginPaint(hDlg, &ps);
440  GetClientRect(hDlg, &rc);
442  EndPaint(hDlg, &ps);
443  break;
444 #endif
445  case WM_SIZING:
446  /* Make sure the user is sizing the dialog */
447  /* in an acceptable range */
448  pRC = (LPRECT)lParam;
449  if ((wParam == WMSZ_LEFT) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_BOTTOMLEFT)) {
450  /* If the width is too small enlarge it to the minimum */
451  if (nMinimumWidth > (pRC->right - pRC->left))
452  pRC->left = pRC->right - nMinimumWidth;
453  } else {
454  /* If the width is too small enlarge it to the minimum */
455  if (nMinimumWidth > (pRC->right - pRC->left))
456  pRC->right = pRC->left + nMinimumWidth;
457  }
458  if ((wParam == WMSZ_TOP) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_TOPRIGHT)) {
459  /* If the height is too small enlarge it to the minimum */
460  if (nMinimumHeight > (pRC->bottom - pRC->top))
461  pRC->top = pRC->bottom - nMinimumHeight;
462  } else {
463  /* If the height is too small enlarge it to the minimum */
464  if (nMinimumHeight > (pRC->bottom - pRC->top))
465  pRC->bottom = pRC->top + nMinimumHeight;
466  }
467  return TRUE;
468  break;
469 
470  case WM_SIZE:
471  /* Handle the window sizing in it's own function */
473  break;
474 
475  case WM_MOVE:
476  /* Handle the window moving in it's own function */
478  break;
479 
480  case WM_DESTROY:
481  ShowWindow(hDlg, SW_HIDE);
483  wp.length = sizeof(WINDOWPLACEMENT);
484  GetWindowPlacement(hDlg, &wp);
489  if (IsZoomed(hDlg) || (wp.flags & WPF_RESTORETOMAXIMIZED))
491  else
493  /* Get rid of the allocated command line cache, if any */
495  if (hWindowMenu)
497  return DefWindowProcW(hDlg, message, wParam, lParam);
498 
499  case WM_TIMER:
500  /* Refresh the performance data */
501  PerfDataRefresh();
506  break;
507 
508  case WM_ENTERMENULOOP:
510  break;
511  case WM_EXITMENULOOP:
513  break;
514  case WM_MENUSELECT:
516  break;
517  case WM_SYSCOLORCHANGE:
518  /* Forward WM_SYSCOLORCHANGE to common controls */
522  break;
523  }
524 
525  return 0;
526 }
void ApplicationPage_OnWindowsCascade(void)
Definition: applpage.c:815
HINSTANCE hInst
Definition: taskmgr.c:35
#define ID_SHUTDOWN_SWITCHUSER
Definition: resource.h:188
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
#define COLOR_3DHILIGHT
Definition: winuser.h:927
Definition: tftpd.h:59
#define REALTIME_PRIORITY_CLASS
Definition: winbase.h:184
#define ID_VIEW_DETAILS
Definition: resource.h:36
#define TRUE
Definition: types.h:120
#define IDR_TRAY_POPUP
Definition: resource.h:22
#define IDOK
Definition: winuser.h:824
#define ID_OPTIONS_HIDEWHENMINIMIZED
Definition: resource.h:140
#define ID_RESTORE
Definition: resource.h:168
#define MF_BYCOMMAND
Definition: winuser.h:202
struct _WINDOWPLACEMENT WINDOWPLACEMENT
void OnAbout(void)
Definition: about.c:25
#define IDC_TAB
Definition: resource.h:12
void OnMove(WPARAM nType, int cx, int cy)
Definition: taskmgr.c:779
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
Definition: taskmgr.c:546
#define ID_PROCESS_PAGE_SETPRIORITY_NORMAL
Definition: resource.h:179
HDC WINAPI GetDC(_In_opt_ HWND)
#define pt(x, y)
Definition: drawing.c:79
#define SW_HIDE
Definition: winuser.h:762
void TaskManager_OnViewUpdateSpeed(DWORD dwSpeed)
Definition: taskmgr.c:984
void ProcessPage_OnEndProcessTree(void)
Definition: endproc.c:161
HWND hTabWnd
Definition: taskmgr.c:39
#define ID_OPTIONS_ALWAYSONTOP
Definition: resource.h:138
#define ID_SHUTDOWN_POWEROFF
Definition: resource.h:185
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
#define ID_SHUTDOWN_DISCONNECT
Definition: resource.h:190
void DoSetPriority(DWORD priority)
Definition: priority.c:26
static HDC
Definition: imagelist.c:92
#define ID_APPLICATION_PAGE_GOTOPROCESS
Definition: resource.h:170
VOID ShutDown_LogOffUser(VOID)
Definition: shutdown.c:170
LONG top
Definition: windef.h:307
#define ID_HELP_TOPICS
Definition: resource.h:155
#define ID_VIEW_UPDATESPEED_HIGH
Definition: resource.h:145
#define WM_MOVE
Definition: winuser.h:1592
VOID ShutDown_PowerOff(VOID)
Definition: shutdown.c:115
#define GWL_EXSTYLE
Definition: winuser.h:845
BOOL OnCreate(HWND hWnd)
Definition: taskmgr.c:576
void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void)
Definition: perfpage.c:518
int nMinimumHeight
Definition: taskmgr.c:44
#define ID_WINDOWS_MAXIMIZE
Definition: resource.h:152
#define WMSZ_TOP
Definition: winuser.h:2441
VOID ShutDown_EjectComputer(VOID)
Definition: shutdown.c:194
#define WPF_RESTORETOMAXIMIZED
Definition: winuser.h:2507
#define ID_OPTIONS_SHOW16BITTASKS
Definition: resource.h:158
#define ID_PROCESS_PAGE_SETPRIORITY_HIGH
Definition: resource.h:177
void RefreshProcessPage(void)
Definition: procpage.c:408
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG left
Definition: windef.h:306
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:181
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
LONG right
Definition: windef.h:308
HWND hApplicationPageListCtrl
Definition: applpage.c:35
DWORD WINAPI GetSysColor(_In_ int)
void ApplicationPage_OnWindowsMinimize(void)
Definition: applpage.c:773
BOOL TrayIcon_ShellUpdateTrayIcon(void)
Definition: trayicon.c:177
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define ID_WINDOWS_TILEVERTICALLY
Definition: resource.h:150
struct tagNMHDR * LPNMHDR
#define COLOR_3DSHADOW
Definition: winuser.h:921
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ID_PROCESS_PAGE_ENDPROCESS
Definition: resource.h:172
#define WMSZ_TOPLEFT
Definition: winuser.h:2442
#define ABOVE_NORMAL_PRIORITY_CLASS
Definition: winbase.h:191
#define ID_SHUTDOWN_HIBERNATE
Definition: resource.h:184
UINT code
Definition: winuser.h:3134
#define WM_NCPAINT
Definition: winuser.h:1669
void ProcessPage_OnDebug(void)
Definition: debug.c:26
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_PROCESS_PAGE_SETPRIORITY_REALTIME
Definition: resource.h:176
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ID_OPTIONS_MINIMIZEONUSE
Definition: resource.h:139
#define ID_VIEW_CPUHISTORY_ONEGRAPHALL
Definition: resource.h:162
#define WM_ENTERMENULOOP
Definition: winuser.h:1786
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define ID_FILE_EXIT
Definition: resource.h:46
BOOL TrayIcon_ShellRemoveTrayIcon(void)
Definition: trayicon.c:159
UINT_PTR idFrom
Definition: winuser.h:3133
#define MDITILE_HORIZONTAL
Definition: winuser.h:2163
HWND hProcessPageHeaderCtrl
Definition: procpage.c:39
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_MENUSELECT
Definition: winuser.h:1729
#define WM_SIZING
Definition: winuser.h:1789
#define ID_HELP_ABOUT
Definition: resource.h:78
#define HIGH_PRIORITY_CLASS
Definition: winbase.h:183
#define ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU
Definition: resource.h:163
VOID ShutDown_Disconnect(VOID)
Definition: shutdown.c:189
#define WM_EXITMENULOOP
Definition: winuser.h:1787
VOID ShutDown_Hibernate(VOID)
Definition: shutdown.c:88
void ProcessPage_OnEndProcess(void)
Definition: endproc.c:30
smooth NULL
Definition: ftsmooth.c:416
#define ID_VIEW_UPDATESPEED_LOW
Definition: resource.h:147
#define ID_PROCESS_PAGE_SETAFFINITY
Definition: resource.h:175
#define LPRECT
Definition: precomp.h:28
void ProcessPage_OnSetAffinity(void)
Definition: affinity.c:41
#define ID_SHUTDOWN_STANDBY
Definition: resource.h:183
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define WM_DESTROY
Definition: winuser.h:1591
#define ID_FILE_NEW
Definition: resource.h:40
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
void ApplicationPage_OnWindowsTile(DWORD dwMode)
Definition: applpage.c:742
#define MF_CHECKED
Definition: winuser.h:132
void OnSize(WPARAM nType, int cx, int cy)
Definition: taskmgr.c:792
#define TCN_SELCHANGE
Definition: commctrl.h:4128
#define ID_VIEW_REFRESH
Definition: resource.h:59
BOOL bWasKeyboardInput
Definition: taskmgr.c:50
void ApplicationPage_OnView(DWORD dwMode)
Definition: applpage.c:728
void TaskManager_OnRestoreMainWindow(void)
Definition: taskmgr.c:925
#define ID_PROCESS_PAGE_DEBUG
Definition: resource.h:174
void RefreshApplicationPage(void)
Definition: applpage.c:247
#define IDLE_PRIORITY_CLASS
Definition: winbase.h:182
#define ID_SHUTDOWN_EJECT_COMPUTER
Definition: resource.h:191
#define ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL
Definition: resource.h:180
void ApplicationPage_OnEndTask(void)
Definition: applpage.c:905
#define WM_SIZE
Definition: winuser.h:1593
#define MDITILE_VERTICAL
Definition: winuser.h:2164
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_TIMER
Definition: winuser.h:1724
void RefreshPerformancePage(void)
Definition: perfpage.c:306
#define ID_VIEW_SHOWKERNELTIMES
Definition: resource.h:161
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define WM_PAINT
Definition: winuser.h:1602
#define ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL
Definition: resource.h:178
void ApplicationPage_OnGotoProcess(void)
Definition: applpage.c:929
VOID ShutDown_StandBy(VOID)
Definition: shutdown.c:61
void PerfDataDeallocCommandLineCache()
Definition: perfdata.c:659
#define WM_ONTRAYICON
Definition: trayicon.h:25
HDC hdc
Definition: main.c:9
#define ID_VIEW_SELECTCOLUMNS
Definition: resource.h:160
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define ID_VIEW_UPDATESPEED_PAUSED
Definition: resource.h:148
VOID ShutDown_LockComputer(VOID)
Definition: shutdown.c:182
void ApplicationPage_OnWindowsBringToFront(void)
Definition: applpage.c:844
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
void PerformancePage_OnViewShowKernelTimes(void)
Definition: perfpage.c:481
#define WM_COMMAND
Definition: winuser.h:1722
HWND hwndFrom
Definition: winuser.h:3132
#define MF_UNCHECKED
Definition: winuser.h:204
#define NM_CLICK
Definition: commctrl.h:130
void PerformancePage_OnViewCPUHistoryOneGraphAll(void)
Definition: perfpage.c:504
#define ID_VIEW_SMALL
Definition: resource.h:34
void TaskManager_OnEnterMenuLoop(HWND hWnd)
Definition: taskmgr.c:939
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define ID_WINDOWS_CASCADE
Definition: resource.h:153
HMENU hWindowMenu
Definition: taskmgr.c:41
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
VOID ShutDown_SwitchUser(VOID)
Definition: shutdown.c:177
void TaskManager_OnTabWndSelChange(void)
Definition: taskmgr.c:1002
void ApplicationPage_OnWindowsMaximize(void)
Definition: applpage.c:794
void TaskManager_OnOptionsAlwaysOnTop(void)
Definition: optnmenu.c:31
void TaskManager_OnFileNew(void)
Definition: run.c:26
#define ID_PROCESS_PAGE_ENDPROCESSTREE
Definition: resource.h:173
BOOL WINAPI IsZoomed(_In_ HWND)
#define ID_WINDOWS_MINIMIZE
Definition: resource.h:151
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_APPLICATION_PAGE_ENDTASK
Definition: resource.h:169
RECT rcNormalPosition
Definition: winuser.h:3270
int nMinimumWidth
Definition: taskmgr.c:43
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SendMessage
Definition: winuser.h:5818
void TaskManager_OnOptionsShow16BitTasks(void)
Definition: optnmenu.c:103
#define ID_SHUTDOWN_LOCKCOMPUTER
Definition: resource.h:189
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define BELOW_NORMAL_PRIORITY_CLASS
Definition: winbase.h:190
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
LONG bottom
Definition: windef.h:309
TASKMANAGER_SETTINGS TaskManagerSettings
Definition: taskmgr.c:52
VOID ShutDown_Reboot(VOID)
Definition: shutdown.c:143
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define ID_WINDOWS_BRINGTOFRONT
Definition: resource.h:154
#define MF_GRAYED
Definition: winuser.h:129
void ProcessPage_OnViewSelectColumns(void)
Definition: column.c:145
#define IDCANCEL
Definition: winuser.h:825
#define ID_WINDOWS_TILEHORIZONTALLY
Definition: resource.h:149
HWND hProcessPageListCtrl
Definition: procpage.c:38
#define ID_VIEW_UPDATESPEED_NORMAL
Definition: resource.h:146
HMENU WINAPI GetMenu(_In_ HWND)
#define ID_APPLICATION_PAGE_SWITCHTO
Definition: resource.h:165
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define ID_SHUTDOWN_REBOOT
Definition: resource.h:186
HWND hMainWnd
Definition: taskmgr.c:37
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define TCN_KEYDOWN
Definition: commctrl.h:4114
void TaskManager_OnOptionsMinimizeOnUse(void)
Definition: optnmenu.c:57
#define ID_PROCESS_PAGE_SETPRIORITY_LOW
Definition: resource.h:181
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: taskmgr.c:968
#define WMSZ_LEFT
Definition: winuser.h:2439
#define WM_NOTIFY
Definition: richedit.h:61
#define WMSZ_TOPRIGHT
Definition: winuser.h:2443
#define WMSZ_BOTTOMLEFT
Definition: winuser.h:2445
#define ID_VIEW_LARGE
Definition: resource.h:33
void PerfDataRefresh(void)
Definition: perfdata.c:175
#define ID_SHUTDOWN_LOGOFF
Definition: resource.h:187
void TaskManager_OnExitMenuLoop(HWND hWnd)
Definition: taskmgr.c:950
void TaskManager_OnOptionsHideWhenMinimized(void)
Definition: optnmenu.c:80
void ApplicationPage_OnSwitchTo(void)
Definition: applpage.c:868

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 109 of file taskmgr.c.

113 {
115  HANDLE hToken;
116  TOKEN_PRIVILEGES tkp;
117  HANDLE hMutex;
118 
119  /* check wether we're already running or not */
120  hMutex = CreateMutexW(NULL, TRUE, L"taskmgrros");
122  {
123  /* Restore existing taskmanager and bring window to front */
124  /* Relies on the fact that the application title string and window title are the same */
125  HWND hTaskMgr;
126  TCHAR szTaskmgr[128];
127 
128  LoadString(hInst, IDS_APP_TITLE, szTaskmgr, sizeof(szTaskmgr)/sizeof(TCHAR));
129  hTaskMgr = FindWindow(NULL, szTaskmgr);
130 
131  if (hTaskMgr != NULL)
132  {
133  SendMessage(hTaskMgr, WM_SYSCOMMAND, SC_RESTORE, 0);
134  SetForegroundWindow(hTaskMgr);
135  }
136 
138  return 0;
139  }
140  else if (!hMutex)
141  {
142  return 1;
143  }
144 
145  /* Initialize global variables */
146  hInst = hInstance;
147 
148  /* Change our priority class to HIGH */
152 
153  /* Now lets get the SE_DEBUG_NAME privilege
154  * so that we can debug processes
155  */
156 
157  /* Get a token for this process. */
159  {
160  /* Get the LUID for the debug privilege. */
162  {
163  tkp.PrivilegeCount = 1; /* one privilege to set */
165 
166  /* Get the debug privilege for this process. */
167  AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
168  }
169  CloseHandle(hToken);
170  }
171 
172  /* Load our settings from the registry */
173  LoadSettings();
174 
175  /* Initialize perf data */
176  if (!PerfDataInitialize())
177  {
178  return -1;
179  }
180 
181  /*
182  * Set our shutdown parameters: we want to shutdown the very last,
183  * without displaying any end task dialog if needed.
184  */
186 
188 
189  /* Save our settings to the registry */
190  SaveSettings();
193  if (hWindowMenu)
195  return 0;
196 }
HINSTANCE hInst
Definition: taskmgr.c:35
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:407
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
#define IDD_TASKMGR_DIALOG
Definition: resource.h:4
#define FindWindow
Definition: winuser.h:5752
#define SC_RESTORE
Definition: winuser.h:2573
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL PerfDataInitialize(void)
Definition: perfdata.c:64
BOOL WINAPI SetPriorityClass(IN HANDLE hProcess, IN DWORD dwPriorityClass)
Definition: proc.c:1694
$ULONG PrivilegeCount
Definition: setypes.h:969
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
void PerfDataUninitialize(void)
Definition: perfdata.c:85
BOOL WINAPI SetProcessShutdownParameters(IN DWORD dwLevel, IN DWORD dwFlags)
Definition: proc.c:949
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
HINSTANCE hInstance
Definition: charmap.c:20
#define HIGH_PRIORITY_CLASS
Definition: winbase.h:183
smooth NULL
Definition: ftsmooth.c:416
HANDLE hMutex
Definition: mutex.c:11
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
void SaveSettings(void)
Definition: taskmgr.c:911
char TCHAR
Definition: xmlstorage.h:189
#define TOKEN_QUERY
Definition: setypes.h:874
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
static const WCHAR L[]
Definition: oid.c:1250
INT_PTR CALLBACK TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: taskmgr.c:200
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
void LoadSettings(void)
Definition: taskmgr.c:848
HMENU hWindowMenu
Definition: taskmgr.c:41
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
#define SHUTDOWN_NORETRY
Definition: winbase.h:429
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define IDS_APP_TITLE
Definition: resource.h:10
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:970
#define SendMessage
Definition: winuser.h:5818
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define SE_DEBUG_NAME
Definition: winnt_old.h:384
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
#define WM_SYSCOMMAND
Definition: winuser.h:1723
#define LoadString
Definition: winuser.h:5794
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158

Variable Documentation

◆ bInMenuLoop

BOOL bInMenuLoop = FALSE

Definition at line 49 of file taskmgr.c.

Referenced by OnSize(), TaskManager_OnEnterMenuLoop(), and TaskManager_OnExitMenuLoop().

◆ bWasKeyboardInput

BOOL bWasKeyboardInput = FALSE

Definition at line 50 of file taskmgr.c.

Referenced by TaskManager_OnTabWndSelChange(), and TaskManagerWndProc().

◆ hInst

◆ hMainWnd

◆ hStatusWnd

◆ hTabWnd

HWND hTabWnd

Definition at line 39 of file taskmgr.c.

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

◆ hWindowMenu

◆ nMinimumHeight

int nMinimumHeight

Definition at line 44 of file taskmgr.c.

Referenced by OnCreate(), and TaskManagerWndProc().

◆ nMinimumWidth

int nMinimumWidth

Definition at line 43 of file taskmgr.c.

Referenced by OnCreate(), and TaskManagerWndProc().

◆ nOldHeight

int nOldHeight

Definition at line 47 of file taskmgr.c.

Referenced by OnCreate(), and OnSize().

◆ nOldWidth

int nOldWidth

Definition at line 46 of file taskmgr.c.

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

◆ TaskManagerSettings