2004-03-23 02:19:54 +01:00
|
|
|
/*
|
|
|
|
* ReactOS Task Manager
|
|
|
|
*
|
|
|
|
* taskmgr.c : Defines the entry point for the application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
|
2008-08-20 10:32:24 +02:00
|
|
|
* Copyright (C) 2008 Vladimir Pankratov
|
2004-03-23 02:19:54 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-23 02:19:54 +01:00
|
|
|
*/
|
|
|
|
|
2012-01-23 12:04:05 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-03-23 02:19:54 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <winnt.h>
|
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
#include "wine/unicode.h"
|
2004-03-23 02:19:54 +01:00
|
|
|
#include "resource.h"
|
|
|
|
#include "taskmgr.h"
|
|
|
|
#include "perfdata.h"
|
|
|
|
#include "column.h"
|
|
|
|
|
|
|
|
#define STATUS_WINDOW 2001
|
|
|
|
|
|
|
|
/* Global Variables: */
|
|
|
|
HINSTANCE hInst; /* current instance */
|
|
|
|
|
|
|
|
HWND hMainWnd; /* Main Window */
|
|
|
|
HWND hStatusWnd; /* Status Bar Window */
|
|
|
|
HWND hTabWnd; /* Tab Control Window */
|
|
|
|
|
|
|
|
int nMinimumWidth; /* Minimum width of the dialog (OnSize()'s cx) */
|
|
|
|
int nMinimumHeight; /* Minimum height of the dialog (OnSize()'s cy) */
|
|
|
|
|
|
|
|
int nOldWidth; /* Holds the previous client area width */
|
|
|
|
int nOldHeight; /* Holds the previous client area height */
|
|
|
|
|
|
|
|
BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
|
|
|
|
|
|
|
|
TASKMANAGER_SETTINGS TaskManagerSettings;
|
|
|
|
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
void FillSolidRect(HDC hDC, LPCRECT lpRect, COLORREF clr)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
2006-03-21 18:35:41 +01:00
|
|
|
SetBkColor(hDC, clr);
|
2011-05-17 12:15:34 +02:00
|
|
|
ExtTextOutW(hDC, 0, 0, ETO_OPAQUE, lpRect, NULL, 0, NULL);
|
2006-03-21 18:35:41 +01:00
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2009-05-06 03:33:55 +02:00
|
|
|
static void FillSolidRect2(HDC hDC, int x, int y, int cx, int cy, COLORREF clr)
|
2006-03-21 18:35:41 +01:00
|
|
|
{
|
|
|
|
RECT rect;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
SetBkColor(hDC, clr);
|
|
|
|
rect.left = x;
|
|
|
|
rect.top = y;
|
|
|
|
rect.right = x + cx;
|
|
|
|
rect.bottom = y + cy;
|
2011-05-17 12:15:34 +02:00
|
|
|
ExtTextOutW(hDC, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
|
2006-03-21 18:35:41 +01:00
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2009-05-06 03:33:55 +02:00
|
|
|
static void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight)
|
2006-03-21 18:35:41 +01:00
|
|
|
{
|
|
|
|
FillSolidRect2(hDC, x, y, cx - 1, 1, clrTopLeft);
|
|
|
|
FillSolidRect2(hDC, x, y, 1, cy - 1, clrTopLeft);
|
|
|
|
FillSolidRect2(hDC, x + cx, y, -1, cy, clrBottomRight);
|
|
|
|
FillSolidRect2(hDC, x, y + cy, cx, -1, clrBottomRight);
|
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
void Font_DrawText(HDC hDC, LPWSTR lpwszText, int x, int y)
|
2006-03-21 18:35:41 +01:00
|
|
|
{
|
|
|
|
HDC hFontDC;
|
|
|
|
HBITMAP hFontBitmap;
|
|
|
|
HBITMAP hOldBitmap;
|
|
|
|
int i;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
hFontDC = CreateCompatibleDC(hDC);
|
2011-05-17 12:15:34 +02:00
|
|
|
hFontBitmap = LoadBitmapW(hInst, MAKEINTRESOURCEW(IDB_FONT));
|
2008-10-25 23:39:55 +02:00
|
|
|
hOldBitmap = SelectObject(hFontDC, hFontBitmap);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
for (i = 0; lpwszText[i]; i++) {
|
|
|
|
if ((lpwszText[i] >= '0') && (lpwszText[i] <= '9')) {
|
|
|
|
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, (lpwszText[i] - '0') * 8, 0, SRCCOPY);
|
2006-03-21 18:35:41 +01:00
|
|
|
}
|
2008-08-20 10:32:24 +02:00
|
|
|
else if (lpwszText[i] == 'K')
|
2006-03-21 18:35:41 +01:00
|
|
|
{
|
|
|
|
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 80, 0, SRCCOPY);
|
|
|
|
}
|
2008-08-20 10:32:24 +02:00
|
|
|
else if (lpwszText[i] == '%')
|
2006-03-21 18:35:41 +01:00
|
|
|
{
|
|
|
|
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 88, 0, SRCCOPY);
|
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
2006-03-21 18:35:41 +01:00
|
|
|
SelectObject(hFontDC, hOldBitmap);
|
|
|
|
DeleteObject(hFontBitmap);
|
|
|
|
DeleteDC(hFontDC);
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static BOOL OnCreate(HWND hWnd)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
2006-03-21 18:35:41 +01:00
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hEditMenu;
|
|
|
|
HMENU hViewMenu;
|
|
|
|
HMENU hUpdateSpeedMenu;
|
|
|
|
HMENU hCPUHistoryMenu;
|
|
|
|
int nActivePage;
|
|
|
|
int nParts[3];
|
|
|
|
RECT rc;
|
2008-08-20 10:32:24 +02:00
|
|
|
TCITEMW item;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2009-06-21 14:28:09 +02:00
|
|
|
static WCHAR wszApplications[255];
|
|
|
|
static WCHAR wszProcesses[255];
|
|
|
|
static WCHAR wszPerformance[255];
|
|
|
|
|
|
|
|
LoadStringW(hInst, IDS_APPLICATIONS, wszApplications, sizeof(wszApplications)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_PERFORMANCE, wszPerformance, sizeof(wszPerformance)/sizeof(WCHAR));
|
2008-08-20 10:32:24 +02:00
|
|
|
|
2011-05-17 12:15:34 +02:00
|
|
|
SendMessageW(hMainWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER)));
|
2010-04-19 20:12:39 +02:00
|
|
|
SendMessageW(hMainWnd, WM_SETICON, ICON_SMALL,
|
2011-05-17 12:15:34 +02:00
|
|
|
(LPARAM)LoadImageW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
|
|
|
|
LR_SHARED));
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Initialize the Windows Common Controls DLL */
|
|
|
|
InitCommonControls();
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Get the minimum window sizes */
|
|
|
|
GetWindowRect(hWnd, &rc);
|
|
|
|
nMinimumWidth = (rc.right - rc.left);
|
|
|
|
nMinimumHeight = (rc.bottom - rc.top);
|
|
|
|
|
|
|
|
/* Create the status bar */
|
2008-08-20 10:32:24 +02:00
|
|
|
hStatusWnd = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, NULL, hWnd, STATUS_WINDOW);
|
2004-03-23 02:19:54 +01:00
|
|
|
if(!hStatusWnd)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Create the status bar panes */
|
|
|
|
nParts[0] = 100;
|
|
|
|
nParts[1] = 210;
|
|
|
|
nParts[2] = 400;
|
2009-03-02 23:26:51 +01:00
|
|
|
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM)nParts);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Create tab pages */
|
|
|
|
hTabWnd = GetDlgItem(hWnd, IDC_TAB);
|
|
|
|
#if 1
|
2008-08-20 10:32:24 +02:00
|
|
|
hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hWnd, ApplicationPageWndProc);
|
|
|
|
hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hWnd, ProcessPageWndProc);
|
|
|
|
hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hWnd, PerformancePageWndProc);
|
2004-03-23 02:19:54 +01:00
|
|
|
#else
|
2008-08-20 10:32:24 +02:00
|
|
|
hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hTabWnd, ApplicationPageWndProc);
|
|
|
|
hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hTabWnd, ProcessPageWndProc);
|
|
|
|
hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hTabWnd, PerformancePageWndProc);
|
2004-03-23 02:19:54 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Insert tabs */
|
2008-08-20 10:32:24 +02:00
|
|
|
memset(&item, 0, sizeof(TCITEMW));
|
2004-03-23 02:19:54 +01:00
|
|
|
item.mask = TCIF_TEXT;
|
2008-08-20 10:32:24 +02:00
|
|
|
item.pszText = wszApplications;
|
|
|
|
SendMessageW(hTabWnd, TCM_INSERTITEMW, 0, (LPARAM)&item);
|
|
|
|
memset(&item, 0, sizeof(TCITEMW));
|
2004-03-23 02:19:54 +01:00
|
|
|
item.mask = TCIF_TEXT;
|
2008-08-20 10:32:24 +02:00
|
|
|
item.pszText = wszProcesses;
|
|
|
|
SendMessageW(hTabWnd, TCM_INSERTITEMW, 1, (LPARAM)&item);
|
|
|
|
memset(&item, 0, sizeof(TCITEMW));
|
2004-03-23 02:19:54 +01:00
|
|
|
item.mask = TCIF_TEXT;
|
2008-08-20 10:32:24 +02:00
|
|
|
item.pszText = wszPerformance;
|
|
|
|
SendMessageW(hTabWnd, TCM_INSERTITEMW, 2, (LPARAM)&item);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Size everything correctly */
|
|
|
|
GetClientRect(hWnd, &rc);
|
|
|
|
nOldWidth = rc.right;
|
|
|
|
nOldHeight = rc.bottom;
|
|
|
|
/* nOldStartX = rc.left; */
|
|
|
|
/*nOldStartY = rc.top; */
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
if ((TaskManagerSettings.Left != 0) ||
|
|
|
|
(TaskManagerSettings.Top != 0) ||
|
|
|
|
(TaskManagerSettings.Right != 0) ||
|
|
|
|
(TaskManagerSettings.Bottom != 0))
|
|
|
|
{
|
|
|
|
MoveWindow(hWnd, TaskManagerSettings.Left, TaskManagerSettings.Top, TaskManagerSettings.Right - TaskManagerSettings.Left, TaskManagerSettings.Bottom - TaskManagerSettings.Top, TRUE);
|
|
|
|
#ifdef __GNUC__TEST__
|
|
|
|
MoveWindow(hApplicationPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
|
|
|
MoveWindow(hProcessPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
|
|
|
MoveWindow(hPerformancePage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (TaskManagerSettings.Maximized)
|
|
|
|
ShowWindow(hWnd, SW_MAXIMIZE);
|
|
|
|
|
|
|
|
/* Set the always on top style */
|
|
|
|
hMenu = GetMenu(hWnd);
|
|
|
|
hEditMenu = GetSubMenu(hMenu, 1);
|
|
|
|
hViewMenu = GetSubMenu(hMenu, 2);
|
|
|
|
hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
|
|
|
|
hCPUHistoryMenu = GetSubMenu(hViewMenu, 7);
|
|
|
|
|
|
|
|
/* Check or uncheck the always on top menu item */
|
|
|
|
if (TaskManagerSettings.AlwaysOnTop) {
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
|
|
|
} else {
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
|
|
|
|
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check or uncheck the minimize on use menu item */
|
|
|
|
if (TaskManagerSettings.MinimizeOnUse)
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
else
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
|
|
|
|
|
|
|
|
/* Check or uncheck the hide when minimized menu item */
|
|
|
|
if (TaskManagerSettings.HideWhenMinimized)
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
else
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
|
|
|
|
|
|
|
|
/* Check or uncheck the show 16-bit tasks menu item */
|
|
|
|
if (TaskManagerSettings.Show16BitTasks)
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
else
|
|
|
|
CheckMenuItem(hEditMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
|
|
|
|
|
|
|
|
if (TaskManagerSettings.View_LargeIcons)
|
|
|
|
CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_LARGE, MF_BYCOMMAND);
|
|
|
|
else if (TaskManagerSettings.View_SmallIcons)
|
|
|
|
CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_SMALL, MF_BYCOMMAND);
|
|
|
|
else
|
|
|
|
CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_DETAILS, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
if (TaskManagerSettings.ShowKernelTimes)
|
|
|
|
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
else
|
|
|
|
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
|
|
|
|
|
|
|
|
if (TaskManagerSettings.UpdateSpeed == 1)
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_HIGH, MF_BYCOMMAND);
|
|
|
|
else if (TaskManagerSettings.UpdateSpeed == 2)
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_NORMAL, MF_BYCOMMAND);
|
|
|
|
else if (TaskManagerSettings.UpdateSpeed == 4)
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_LOW, MF_BYCOMMAND);
|
|
|
|
else
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_PAUSED, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
if (TaskManagerSettings.CPUHistory_OneGraphPerCPU)
|
|
|
|
CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
|
|
|
|
else
|
|
|
|
CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
nActivePage = TaskManagerSettings.ActiveTabPage;
|
2011-05-17 12:15:34 +02:00
|
|
|
SendMessageW(hTabWnd, TCM_SETCURFOCUS, 0, 0);
|
|
|
|
SendMessageW(hTabWnd, TCM_SETCURFOCUS, 1, 0);
|
|
|
|
SendMessageW(hTabWnd, TCM_SETCURFOCUS, 2, 0);
|
|
|
|
SendMessageW(hTabWnd, TCM_SETCURFOCUS, nActivePage, 0);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2005-09-14 17:37:25 +02:00
|
|
|
if (TaskManagerSettings.UpdateSpeed == 1)
|
2004-03-23 02:19:54 +01:00
|
|
|
SetTimer(hWnd, 1, 1000, NULL);
|
|
|
|
else if (TaskManagerSettings.UpdateSpeed == 2)
|
|
|
|
SetTimer(hWnd, 1, 2000, NULL);
|
|
|
|
else if (TaskManagerSettings.UpdateSpeed == 4)
|
|
|
|
SetTimer(hWnd, 1, 4000, NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Refresh the performance data
|
|
|
|
* Sample it twice so we can establish
|
|
|
|
* the delta values & cpu usage
|
|
|
|
*/
|
|
|
|
PerfDataRefresh();
|
|
|
|
PerfDataRefresh();
|
|
|
|
|
|
|
|
RefreshApplicationPage();
|
|
|
|
RefreshProcessPage();
|
|
|
|
RefreshPerformancePage();
|
|
|
|
|
|
|
|
TrayIcon_ShellAddTrayIcon();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OnMove()
|
|
|
|
* This function handles all the moving events for the application
|
|
|
|
* It moves every child window that needs moving
|
|
|
|
*/
|
2006-03-21 18:35:41 +01:00
|
|
|
static void OnMove( UINT nType, int cx, int cy )
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
#ifdef __GNUC__TEST__
|
|
|
|
MoveWindow(hApplicationPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
|
|
|
MoveWindow(hProcessPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
|
|
|
MoveWindow(hPerformancePage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OnSize()
|
|
|
|
* This function handles all the sizing events for the application
|
|
|
|
* It re-sizes every window, and child window that needs re-sizing
|
|
|
|
*/
|
2006-03-21 18:35:41 +01:00
|
|
|
static void OnSize( UINT nType, int cx, int cy )
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
int nParts[3];
|
|
|
|
int nXDifference;
|
|
|
|
int nYDifference;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
if (nType == SIZE_MINIMIZED)
|
2005-09-14 21:17:12 +02:00
|
|
|
{
|
|
|
|
if(TaskManagerSettings.HideWhenMinimized)
|
|
|
|
{
|
|
|
|
ShowWindow(hMainWnd, SW_HIDE);
|
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
return;
|
2005-09-14 21:17:12 +02:00
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
nXDifference = cx - nOldWidth;
|
|
|
|
nYDifference = cy - nOldHeight;
|
|
|
|
nOldWidth = cx;
|
|
|
|
nOldHeight = cy;
|
|
|
|
|
|
|
|
/* Update the status bar size */
|
|
|
|
GetWindowRect(hStatusWnd, &rc);
|
2008-08-20 10:32:24 +02:00
|
|
|
SendMessageW(hStatusWnd, WM_SIZE, nType, MAKELPARAM(cx, cy + (rc.bottom - rc.top)));
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Update the status bar pane sizes */
|
|
|
|
nParts[0] = bInMenuLoop ? -1 : 100;
|
|
|
|
nParts[1] = 210;
|
|
|
|
nParts[2] = cx;
|
2008-08-20 10:32:24 +02:00
|
|
|
SendMessageW(hStatusWnd, SB_SETPARTS, bInMenuLoop ? 1 : 3, (LPARAM)nParts);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Resize the tab control */
|
|
|
|
GetWindowRect(hTabWnd, &rc);
|
|
|
|
cx = (rc.right - rc.left) + nXDifference;
|
|
|
|
cy = (rc.bottom - rc.top) + nYDifference;
|
|
|
|
SetWindowPos(hTabWnd, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
|
|
|
/* Resize the application page */
|
|
|
|
GetWindowRect(hApplicationPage, &rc);
|
|
|
|
cx = (rc.right - rc.left) + nXDifference;
|
|
|
|
cy = (rc.bottom - rc.top) + nYDifference;
|
|
|
|
SetWindowPos(hApplicationPage, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
|
|
|
/* Resize the process page */
|
|
|
|
GetWindowRect(hProcessPage, &rc);
|
|
|
|
cx = (rc.right - rc.left) + nXDifference;
|
|
|
|
cy = (rc.bottom - rc.top) + nYDifference;
|
|
|
|
SetWindowPos(hProcessPage, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
|
|
|
/* Resize the performance page */
|
|
|
|
GetWindowRect(hPerformancePage, &rc);
|
|
|
|
cx = (rc.right - rc.left) + nXDifference;
|
|
|
|
cy = (rc.bottom - rc.top) + nYDifference;
|
|
|
|
SetWindowPos(hPerformancePage, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void LoadSettings(void)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
int i;
|
|
|
|
DWORD dwSize;
|
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
static const WCHAR wszSubKey[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'W','i','n','e','\\','T','a','s','k','M','a','n','a','g','e','r',0};
|
|
|
|
static const WCHAR wszPreferences[] = {'P','r','e','f','e','r','e','n','c','e','s',0};
|
|
|
|
|
2004-03-23 02:19:54 +01:00
|
|
|
/* Window size & position settings */
|
|
|
|
TaskManagerSettings.Maximized = FALSE;
|
|
|
|
TaskManagerSettings.Left = 0;
|
|
|
|
TaskManagerSettings.Top = 0;
|
|
|
|
TaskManagerSettings.Right = 0;
|
|
|
|
TaskManagerSettings.Bottom = 0;
|
|
|
|
|
|
|
|
/* Tab settings */
|
|
|
|
TaskManagerSettings.ActiveTabPage = 0;
|
|
|
|
|
|
|
|
/* Options menu settings */
|
|
|
|
TaskManagerSettings.AlwaysOnTop = FALSE;
|
|
|
|
TaskManagerSettings.MinimizeOnUse = TRUE;
|
|
|
|
TaskManagerSettings.HideWhenMinimized = TRUE;
|
|
|
|
TaskManagerSettings.Show16BitTasks = TRUE;
|
|
|
|
|
|
|
|
/* Update speed settings */
|
|
|
|
TaskManagerSettings.UpdateSpeed = 2;
|
|
|
|
|
|
|
|
/* Applications page settings */
|
|
|
|
TaskManagerSettings.View_LargeIcons = FALSE;
|
|
|
|
TaskManagerSettings.View_SmallIcons = FALSE;
|
|
|
|
TaskManagerSettings.View_Details = TRUE;
|
|
|
|
|
|
|
|
/* Processes page settings */
|
|
|
|
TaskManagerSettings.ShowProcessesFromAllUsers = FALSE; /* Server-only? */
|
|
|
|
TaskManagerSettings.Column_ImageName = TRUE;
|
|
|
|
TaskManagerSettings.Column_PID = TRUE;
|
|
|
|
TaskManagerSettings.Column_CPUUsage = TRUE;
|
|
|
|
TaskManagerSettings.Column_CPUTime = TRUE;
|
|
|
|
TaskManagerSettings.Column_MemoryUsage = TRUE;
|
|
|
|
TaskManagerSettings.Column_MemoryUsageDelta = FALSE;
|
|
|
|
TaskManagerSettings.Column_PeakMemoryUsage = FALSE;
|
|
|
|
TaskManagerSettings.Column_PageFaults = FALSE;
|
|
|
|
TaskManagerSettings.Column_USERObjects = FALSE;
|
|
|
|
TaskManagerSettings.Column_IOReads = FALSE;
|
|
|
|
TaskManagerSettings.Column_IOReadBytes = FALSE;
|
|
|
|
TaskManagerSettings.Column_SessionID = FALSE; /* Server-only? */
|
|
|
|
TaskManagerSettings.Column_UserName = FALSE; /* Server-only? */
|
|
|
|
TaskManagerSettings.Column_PageFaultsDelta = FALSE;
|
|
|
|
TaskManagerSettings.Column_VirtualMemorySize = FALSE;
|
|
|
|
TaskManagerSettings.Column_PagedPool = FALSE;
|
|
|
|
TaskManagerSettings.Column_NonPagedPool = FALSE;
|
|
|
|
TaskManagerSettings.Column_BasePriority = FALSE;
|
|
|
|
TaskManagerSettings.Column_HandleCount = FALSE;
|
|
|
|
TaskManagerSettings.Column_ThreadCount = FALSE;
|
|
|
|
TaskManagerSettings.Column_GDIObjects = FALSE;
|
|
|
|
TaskManagerSettings.Column_IOWrites = FALSE;
|
|
|
|
TaskManagerSettings.Column_IOWriteBytes = FALSE;
|
|
|
|
TaskManagerSettings.Column_IOOther = FALSE;
|
|
|
|
TaskManagerSettings.Column_IOOtherBytes = FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < 25; i++) {
|
|
|
|
TaskManagerSettings.ColumnOrderArray[i] = i;
|
|
|
|
}
|
|
|
|
TaskManagerSettings.ColumnSizeArray[0] = 105;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[1] = 50;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[2] = 107;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[3] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[4] = 35;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[5] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[6] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[7] = 100;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[8] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[9] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[10] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[11] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[12] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[13] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[14] = 60;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[15] = 60;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[16] = 60;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[17] = 60;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[18] = 60;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[19] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[20] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[21] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[22] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[23] = 70;
|
|
|
|
TaskManagerSettings.ColumnSizeArray[24] = 70;
|
|
|
|
|
|
|
|
TaskManagerSettings.SortColumn = 1;
|
|
|
|
TaskManagerSettings.SortAscending = TRUE;
|
|
|
|
|
|
|
|
/* Performance page settings */
|
|
|
|
TaskManagerSettings.CPUHistory_OneGraphPerCPU = TRUE;
|
|
|
|
TaskManagerSettings.ShowKernelTimes = FALSE;
|
|
|
|
|
|
|
|
/* Open the key */
|
2005-06-13 20:56:00 +02:00
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\TaskManager */
|
2008-08-20 10:32:24 +02:00
|
|
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, wszSubKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
2004-03-23 02:19:54 +01:00
|
|
|
return;
|
|
|
|
/* Read the settings */
|
|
|
|
dwSize = sizeof(TASKMANAGER_SETTINGS);
|
2008-08-20 10:32:24 +02:00
|
|
|
RegQueryValueExW(hKey, wszPreferences, NULL, NULL, (LPBYTE)&TaskManagerSettings, &dwSize);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Close the key */
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void SaveSettings(void)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
2008-08-20 10:32:24 +02:00
|
|
|
|
|
|
|
static const WCHAR wszSubKey3[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'W','i','n','e','\\','T','a','s','k','M','a','n','a','g','e','r',0};
|
|
|
|
static const WCHAR wszPreferences[] = {'P','r','e','f','e','r','e','n','c','e','s',0};
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
/* Open (or create) the key */
|
2005-06-13 20:56:00 +02:00
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\TaskManager */
|
2008-08-20 10:32:24 +02:00
|
|
|
if (RegCreateKeyExW(HKEY_CURRENT_USER, wszSubKey3, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
2004-03-23 02:19:54 +01:00
|
|
|
return;
|
|
|
|
/* Save the settings */
|
2008-08-20 10:32:24 +02:00
|
|
|
RegSetValueExW(hKey, wszPreferences, 0, REG_BINARY, (LPBYTE)&TaskManagerSettings, sizeof(TASKMANAGER_SETTINGS));
|
2004-03-23 02:19:54 +01:00
|
|
|
/* Close the key */
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void TaskManager_OnRestoreMainWindow(void)
|
2005-09-14 21:17:12 +02:00
|
|
|
{
|
|
|
|
BOOL OnTop;
|
|
|
|
|
2011-05-17 12:15:34 +02:00
|
|
|
OnTop = (GetWindowLongW(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
|
|
|
|
|
2005-09-14 21:17:12 +02:00
|
|
|
OpenIcon(hMainWnd);
|
|
|
|
SetForegroundWindow(hMainWnd);
|
|
|
|
SetWindowPos(hMainWnd, (OnTop ? HWND_TOPMOST : HWND_TOP), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
|
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void TaskManager_OnEnterMenuLoop(HWND hWnd)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
int nParts;
|
|
|
|
|
|
|
|
/* Update the status bar pane sizes */
|
|
|
|
nParts = -1;
|
2009-03-02 23:26:51 +01:00
|
|
|
SendMessageW(hStatusWnd, SB_SETPARTS, 1, (LPARAM)&nParts);
|
2004-03-23 02:19:54 +01:00
|
|
|
bInMenuLoop = TRUE;
|
2008-08-20 10:32:24 +02:00
|
|
|
SendMessageW(hStatusWnd, SB_SETTEXTW, 0, 0);
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void TaskManager_OnExitMenuLoop(HWND hWnd)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
int nParts[3];
|
2008-08-20 10:32:24 +02:00
|
|
|
WCHAR text[256];
|
|
|
|
|
2009-06-21 15:04:14 +02:00
|
|
|
WCHAR wszCPU_Usage[255];
|
|
|
|
WCHAR wszProcesses[255];
|
|
|
|
|
|
|
|
LoadStringW(hInst, IDS_STATUS_BAR_CPU_USAGE, wszCPU_Usage, sizeof(wszCPU_Usage)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_STATUS_BAR_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR));
|
2004-03-23 02:19:54 +01:00
|
|
|
|
|
|
|
bInMenuLoop = FALSE;
|
|
|
|
/* Update the status bar pane sizes */
|
|
|
|
GetClientRect(hWnd, &rc);
|
|
|
|
nParts[0] = 100;
|
|
|
|
nParts[1] = 210;
|
|
|
|
nParts[2] = rc.right;
|
2009-03-02 23:26:51 +01:00
|
|
|
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM)nParts);
|
2011-05-17 12:15:34 +02:00
|
|
|
SendMessageW(hStatusWnd, SB_SETTEXTW, 0, 0);
|
2008-08-20 10:32:24 +02:00
|
|
|
wsprintfW(text, wszCPU_Usage, PerfDataGetProcessorUsage());
|
|
|
|
SendMessageW(hStatusWnd, SB_SETTEXTW, 1, (LPARAM)text);
|
|
|
|
wsprintfW(text, wszProcesses, PerfDataGetProcessCount());
|
|
|
|
SendMessageW(hStatusWnd, SB_SETTEXTW, 0, (LPARAM)text);
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
2008-08-20 10:32:24 +02:00
|
|
|
WCHAR wstr[256] = {0};
|
|
|
|
|
|
|
|
LoadStringW(hInst, nItemID, wstr, sizeof(wstr)/sizeof(WCHAR));
|
|
|
|
SendMessageW(hStatusWnd, SB_SETTEXTW, 0, (LPARAM)wstr);
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void TaskManager_OnViewUpdateSpeedHigh(void)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hViewMenu;
|
|
|
|
HMENU hUpdateSpeedMenu;
|
|
|
|
|
|
|
|
hMenu = GetMenu(hMainWnd);
|
|
|
|
hViewMenu = GetSubMenu(hMenu, 2);
|
|
|
|
hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
|
|
|
|
|
|
|
|
TaskManagerSettings.UpdateSpeed = 1;
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_HIGH, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
KillTimer(hMainWnd, 1);
|
|
|
|
SetTimer(hMainWnd, 1, 1000, NULL);
|
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
static void TaskManager_OnViewUpdateSpeedNormal(void)
|
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hViewMenu;
|
|
|
|
HMENU hUpdateSpeedMenu;
|
|
|
|
|
|
|
|
hMenu = GetMenu(hMainWnd);
|
|
|
|
hViewMenu = GetSubMenu(hMenu, 2);
|
|
|
|
hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
|
|
|
|
|
|
|
|
TaskManagerSettings.UpdateSpeed = 2;
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_NORMAL, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
KillTimer(hMainWnd, 1);
|
|
|
|
SetTimer(hMainWnd, 1, 2000, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TaskManager_OnViewUpdateSpeedLow(void)
|
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hViewMenu;
|
|
|
|
HMENU hUpdateSpeedMenu;
|
|
|
|
|
|
|
|
hMenu = GetMenu(hMainWnd);
|
|
|
|
hViewMenu = GetSubMenu(hMenu, 2);
|
|
|
|
hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
|
|
|
|
|
|
|
|
TaskManagerSettings.UpdateSpeed = 4;
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_LOW, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
KillTimer(hMainWnd, 1);
|
|
|
|
SetTimer(hMainWnd, 1, 4000, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TaskManager_OnViewUpdateSpeedPaused(void)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hViewMenu;
|
|
|
|
HMENU hUpdateSpeedMenu;
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
hMenu = GetMenu(hMainWnd);
|
|
|
|
hViewMenu = GetSubMenu(hMenu, 2);
|
|
|
|
hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1);
|
|
|
|
TaskManagerSettings.UpdateSpeed = 0;
|
|
|
|
CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_PAUSED, MF_BYCOMMAND);
|
|
|
|
KillTimer(hMainWnd, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TaskManager_OnTabWndSelChange(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
HMENU hMenu;
|
|
|
|
HMENU hOptionsMenu;
|
|
|
|
HMENU hViewMenu;
|
|
|
|
HMENU hSubMenu;
|
|
|
|
|
2009-06-21 14:28:09 +02:00
|
|
|
WCHAR wszLargeIcons[255];
|
|
|
|
WCHAR wszSmallIcons[255];
|
|
|
|
WCHAR wszDetails[255];
|
|
|
|
WCHAR wszWindows[255];
|
|
|
|
WCHAR wszSelectColumns[255];
|
|
|
|
WCHAR wszShow16bTasks[255];
|
|
|
|
WCHAR wszOneGraphAllCPU[255];
|
|
|
|
WCHAR wszOneGraphPerCPU[255];
|
|
|
|
WCHAR wszCPUHistory[255];
|
|
|
|
WCHAR wszShowKernelTimes[255];
|
|
|
|
|
|
|
|
LoadStringW(hInst, IDS_VIEW_LARGE, wszLargeIcons, sizeof(wszLargeIcons)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_SMALL, wszSmallIcons, sizeof(wszSmallIcons)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_DETAILS, wszDetails, sizeof(wszDetails)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_WINDOWS, wszWindows, sizeof(wszWindows)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_SELECTCOLUMNS, wszSelectColumns, sizeof(wszSelectColumns)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_OPTIONS_SHOW16BITTASKS, wszShow16bTasks, sizeof(wszShow16bTasks)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_CPUHISTORY_ONEGRAPHALL, wszOneGraphAllCPU, sizeof(wszOneGraphAllCPU)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_CPUHISTORY_ONEGRAPHPERCPU, wszOneGraphPerCPU, sizeof(wszOneGraphPerCPU)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_CPUHISTORY, wszCPUHistory, sizeof(wszCPUHistory)/sizeof(WCHAR));
|
|
|
|
LoadStringW(hInst, IDS_VIEW_SHOWKERNELTIMES, wszShowKernelTimes, sizeof(wszShowKernelTimes)/sizeof(WCHAR));
|
2008-08-20 10:32:24 +02:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
hMenu = GetMenu(hMainWnd);
|
|
|
|
hViewMenu = GetSubMenu(hMenu, 2);
|
|
|
|
hOptionsMenu = GetSubMenu(hMenu, 1);
|
2011-05-17 12:15:34 +02:00
|
|
|
TaskManagerSettings.ActiveTabPage = SendMessageW(hTabWnd, TCM_GETCURSEL, 0, 0);
|
2006-03-21 18:35:41 +01:00
|
|
|
for (i = GetMenuItemCount(hViewMenu) - 1; i > 2; i--) {
|
|
|
|
hSubMenu = GetSubMenu(hViewMenu, i);
|
|
|
|
if (hSubMenu)
|
|
|
|
DestroyMenu(hSubMenu);
|
|
|
|
RemoveMenu(hViewMenu, i, MF_BYPOSITION);
|
|
|
|
}
|
|
|
|
RemoveMenu(hOptionsMenu, 3, MF_BYPOSITION);
|
|
|
|
switch (TaskManagerSettings.ActiveTabPage) {
|
|
|
|
case 0:
|
|
|
|
ShowWindow(hApplicationPage, SW_SHOW);
|
|
|
|
ShowWindow(hProcessPage, SW_HIDE);
|
|
|
|
ShowWindow(hPerformancePage, SW_HIDE);
|
|
|
|
BringWindowToTop(hApplicationPage);
|
2008-08-20 10:32:24 +02:00
|
|
|
AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_LARGE, wszLargeIcons);
|
|
|
|
AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SMALL, wszSmallIcons);
|
|
|
|
AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_DETAILS, wszDetails);
|
2006-03-21 18:35:41 +01:00
|
|
|
|
|
|
|
if (GetMenuItemCount(hMenu) <= 4) {
|
2008-08-20 10:32:24 +02:00
|
|
|
hSubMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_WINDOWSMENU));
|
|
|
|
InsertMenuW(hMenu, 3, MF_BYPOSITION|MF_POPUP, (UINT_PTR)hSubMenu, wszWindows);
|
2006-03-21 18:35:41 +01:00
|
|
|
DrawMenuBar(hMainWnd);
|
|
|
|
}
|
|
|
|
if (TaskManagerSettings.View_LargeIcons)
|
|
|
|
CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_LARGE, MF_BYCOMMAND);
|
|
|
|
else if (TaskManagerSettings.View_SmallIcons)
|
|
|
|
CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_SMALL, MF_BYCOMMAND);
|
|
|
|
else
|
|
|
|
CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_DETAILS, MF_BYCOMMAND);
|
|
|
|
/*
|
|
|
|
* Give the application list control focus
|
|
|
|
*/
|
|
|
|
SetFocus(hApplicationPageListCtrl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
ShowWindow(hApplicationPage, SW_HIDE);
|
|
|
|
ShowWindow(hProcessPage, SW_SHOW);
|
|
|
|
ShowWindow(hPerformancePage, SW_HIDE);
|
|
|
|
BringWindowToTop(hProcessPage);
|
2008-08-20 10:32:24 +02:00
|
|
|
AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SELECTCOLUMNS, wszSelectColumns);
|
|
|
|
AppendMenuW(hOptionsMenu, MF_STRING, ID_OPTIONS_SHOW16BITTASKS, wszShow16bTasks);
|
2006-03-21 18:35:41 +01:00
|
|
|
if (TaskManagerSettings.Show16BitTasks)
|
|
|
|
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
if (GetMenuItemCount(hMenu) > 4)
|
|
|
|
{
|
|
|
|
RemoveMenu(hMenu, 3, MF_BYPOSITION);
|
|
|
|
DrawMenuBar(hMainWnd);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Give the process list control focus
|
|
|
|
*/
|
|
|
|
SetFocus(hProcessPageListCtrl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
ShowWindow(hApplicationPage, SW_HIDE);
|
|
|
|
ShowWindow(hProcessPage, SW_HIDE);
|
|
|
|
ShowWindow(hPerformancePage, SW_SHOW);
|
|
|
|
BringWindowToTop(hPerformancePage);
|
|
|
|
if (GetMenuItemCount(hMenu) > 4) {
|
|
|
|
RemoveMenu(hMenu, 3, MF_BYPOSITION);
|
|
|
|
DrawMenuBar(hMainWnd);
|
|
|
|
}
|
|
|
|
hSubMenu = CreatePopupMenu();
|
2008-08-20 10:32:24 +02:00
|
|
|
AppendMenuW(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHALL, wszOneGraphAllCPU);
|
|
|
|
AppendMenuW(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, wszOneGraphPerCPU);
|
|
|
|
AppendMenuW(hViewMenu, MF_STRING|MF_POPUP, (UINT_PTR)hSubMenu, wszCPUHistory);
|
|
|
|
AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, wszShowKernelTimes);
|
2006-03-21 18:35:41 +01:00
|
|
|
if (TaskManagerSettings.ShowKernelTimes)
|
|
|
|
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
else
|
|
|
|
CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED);
|
|
|
|
if (TaskManagerSettings.CPUHistory_OneGraphPerCPU)
|
|
|
|
CheckMenuRadioItem(hSubMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND);
|
|
|
|
else
|
|
|
|
CheckMenuRadioItem(hSubMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND);
|
|
|
|
/*
|
|
|
|
* Give the tab control focus
|
|
|
|
*/
|
|
|
|
SetFocus(hTabWnd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
LPWSTR GetLastErrorText(LPWSTR lpwszBuf, DWORD dwSize)
|
2006-03-21 18:35:41 +01:00
|
|
|
{
|
|
|
|
DWORD dwRet;
|
2008-08-20 10:32:24 +02:00
|
|
|
LPWSTR lpwszTemp = NULL;
|
|
|
|
static const WCHAR wszFormat[] = {'%','s',' ','(','%','u',')',0};
|
2006-03-21 18:35:41 +01:00
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
dwRet = FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_ARGUMENT_ARRAY,
|
2006-03-21 18:35:41 +01:00
|
|
|
NULL,
|
|
|
|
GetLastError(),
|
|
|
|
LANG_NEUTRAL,
|
2008-08-20 10:32:24 +02:00
|
|
|
(LPWSTR)&lpwszTemp,
|
2006-03-21 18:35:41 +01:00
|
|
|
0,
|
|
|
|
NULL );
|
|
|
|
|
|
|
|
/* supplied buffer is not long enough */
|
2010-05-18 01:30:51 +02:00
|
|
|
if (!dwRet || ( dwSize < dwRet+14)) {
|
2008-08-20 10:32:24 +02:00
|
|
|
lpwszBuf[0] = '\0';
|
2006-03-21 18:35:41 +01:00
|
|
|
} else {
|
2008-08-20 10:32:24 +02:00
|
|
|
lpwszTemp[strlenW(lpwszTemp)-2] = '\0'; /* remove cr and newline character */
|
|
|
|
sprintfW(lpwszBuf, wszFormat, lpwszTemp, GetLastError());
|
2006-03-21 18:35:41 +01:00
|
|
|
}
|
2008-08-20 10:32:24 +02:00
|
|
|
if (lpwszTemp) {
|
2008-12-08 04:07:58 +01:00
|
|
|
LocalFree(lpwszTemp);
|
2006-03-21 18:35:41 +01:00
|
|
|
}
|
2008-08-20 10:32:24 +02:00
|
|
|
return lpwszBuf;
|
2006-03-21 18:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Message handler for dialog box. */
|
|
|
|
static INT_PTR CALLBACK
|
|
|
|
TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-04-08 12:01:43 +02:00
|
|
|
static const WCHAR wszTaskmgr[] = {'t','a','s','k','m','g','r',0};
|
2006-03-21 18:35:41 +01:00
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
LPRECT pRC;
|
|
|
|
RECT rc;
|
|
|
|
LPNMHDR pnmh;
|
|
|
|
WINDOWPLACEMENT wp;
|
|
|
|
|
|
|
|
switch (message) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
hMainWnd = hDlg;
|
|
|
|
return OnCreate(hDlg);
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
|
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
/* Process menu commands */
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case ID_FILE_NEW:
|
|
|
|
TaskManager_OnFileNew();
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_ALWAYSONTOP:
|
|
|
|
TaskManager_OnOptionsAlwaysOnTop();
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_MINIMIZEONUSE:
|
|
|
|
TaskManager_OnOptionsMinimizeOnUse();
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_HIDEWHENMINIMIZED:
|
|
|
|
TaskManager_OnOptionsHideWhenMinimized();
|
|
|
|
break;
|
|
|
|
case ID_OPTIONS_SHOW16BITTASKS:
|
|
|
|
TaskManager_OnOptionsShow16BitTasks();
|
|
|
|
break;
|
|
|
|
case ID_RESTORE:
|
|
|
|
TaskManager_OnRestoreMainWindow();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_LARGE:
|
|
|
|
ApplicationPage_OnViewLargeIcons();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_SMALL:
|
|
|
|
ApplicationPage_OnViewSmallIcons();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_DETAILS:
|
|
|
|
ApplicationPage_OnViewDetails();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_SHOWKERNELTIMES:
|
|
|
|
PerformancePage_OnViewShowKernelTimes();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_CPUHISTORY_ONEGRAPHALL:
|
|
|
|
PerformancePage_OnViewCPUHistoryOneGraphAll();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU:
|
|
|
|
PerformancePage_OnViewCPUHistoryOneGraphPerCPU();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_UPDATESPEED_HIGH:
|
|
|
|
TaskManager_OnViewUpdateSpeedHigh();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_UPDATESPEED_NORMAL:
|
|
|
|
TaskManager_OnViewUpdateSpeedNormal();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_UPDATESPEED_LOW:
|
|
|
|
TaskManager_OnViewUpdateSpeedLow();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_UPDATESPEED_PAUSED:
|
|
|
|
TaskManager_OnViewUpdateSpeedPaused();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_SELECTCOLUMNS:
|
|
|
|
ProcessPage_OnViewSelectColumns();
|
|
|
|
break;
|
|
|
|
case ID_VIEW_REFRESH:
|
2011-05-17 12:15:34 +02:00
|
|
|
PostMessageW(hDlg, WM_TIMER, 0, 0);
|
2006-03-21 18:35:41 +01:00
|
|
|
break;
|
|
|
|
case ID_WINDOWS_TILEHORIZONTALLY:
|
|
|
|
ApplicationPage_OnWindowsTileHorizontally();
|
|
|
|
break;
|
|
|
|
case ID_WINDOWS_TILEVERTICALLY:
|
|
|
|
ApplicationPage_OnWindowsTileVertically();
|
|
|
|
break;
|
|
|
|
case ID_WINDOWS_MINIMIZE:
|
|
|
|
ApplicationPage_OnWindowsMinimize();
|
|
|
|
break;
|
|
|
|
case ID_WINDOWS_MAXIMIZE:
|
|
|
|
ApplicationPage_OnWindowsMaximize();
|
|
|
|
break;
|
|
|
|
case ID_WINDOWS_CASCADE:
|
|
|
|
ApplicationPage_OnWindowsCascade();
|
|
|
|
break;
|
|
|
|
case ID_WINDOWS_BRINGTOFRONT:
|
|
|
|
ApplicationPage_OnWindowsBringToFront();
|
|
|
|
break;
|
|
|
|
case ID_APPLICATION_PAGE_SWITCHTO:
|
|
|
|
ApplicationPage_OnSwitchTo();
|
|
|
|
break;
|
|
|
|
case ID_APPLICATION_PAGE_ENDTASK:
|
|
|
|
ApplicationPage_OnEndTask();
|
|
|
|
break;
|
|
|
|
case ID_APPLICATION_PAGE_GOTOPROCESS:
|
|
|
|
ApplicationPage_OnGotoProcess();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_ENDPROCESS:
|
|
|
|
ProcessPage_OnEndProcess();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_ENDPROCESSTREE:
|
|
|
|
ProcessPage_OnEndProcessTree();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_DEBUG:
|
|
|
|
ProcessPage_OnDebug();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETAFFINITY:
|
|
|
|
ProcessPage_OnSetAffinity();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETPRIORITY_REALTIME:
|
|
|
|
ProcessPage_OnSetPriorityRealTime();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETPRIORITY_HIGH:
|
|
|
|
ProcessPage_OnSetPriorityHigh();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL:
|
|
|
|
ProcessPage_OnSetPriorityAboveNormal();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETPRIORITY_NORMAL:
|
|
|
|
ProcessPage_OnSetPriorityNormal();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL:
|
|
|
|
ProcessPage_OnSetPriorityBelowNormal();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_SETPRIORITY_LOW:
|
|
|
|
ProcessPage_OnSetPriorityLow();
|
|
|
|
break;
|
|
|
|
case ID_PROCESS_PAGE_DEBUGCHANNELS:
|
|
|
|
ProcessPage_OnDebugChannels();
|
|
|
|
break;
|
2011-04-08 12:01:43 +02:00
|
|
|
case ID_HELP_TOPICS:
|
|
|
|
WinHelpW(hDlg, wszTaskmgr, HELP_FINDER, 0);
|
|
|
|
break;
|
2006-03-21 18:35:41 +01:00
|
|
|
case ID_HELP_ABOUT:
|
|
|
|
OnAbout();
|
|
|
|
break;
|
|
|
|
case ID_FILE_EXIT:
|
|
|
|
EndDialog(hDlg, IDOK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_ONTRAYICON:
|
|
|
|
switch(lParam)
|
|
|
|
{
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
BOOL OnTop;
|
|
|
|
HMENU hMenu, hPopupMenu;
|
|
|
|
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
|
2011-05-17 12:15:34 +02:00
|
|
|
OnTop = (GetWindowLongW(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
|
2006-03-21 18:35:41 +01:00
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_TRAY_POPUP));
|
2006-03-21 18:35:41 +01:00
|
|
|
hPopupMenu = GetSubMenu(hMenu, 0);
|
|
|
|
|
|
|
|
if(IsWindowVisible(hMainWnd))
|
|
|
|
{
|
|
|
|
DeleteMenu(hPopupMenu, ID_RESTORE, MF_BYCOMMAND);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetMenuDefaultItem(hPopupMenu, ID_RESTORE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(OnTop)
|
|
|
|
{
|
|
|
|
CheckMenuItem(hPopupMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND | MF_CHECKED);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetForegroundWindow(hMainWnd);
|
|
|
|
TrackPopupMenuEx(hPopupMenu, 0, pt.x, pt.y, hMainWnd, NULL);
|
|
|
|
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
TaskManager_OnRestoreMainWindow();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
pnmh = (LPNMHDR)lParam;
|
|
|
|
if ((pnmh->hwndFrom == hTabWnd) &&
|
|
|
|
(pnmh->idFrom == IDC_TAB) &&
|
|
|
|
(pnmh->code == TCN_SELCHANGE))
|
|
|
|
{
|
|
|
|
TaskManager_OnTabWndSelChange();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NCPAINT:
|
|
|
|
hdc = GetDC(hDlg);
|
|
|
|
GetClientRect(hDlg, &rc);
|
|
|
|
Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
|
|
|
|
ReleaseDC(hDlg, hdc);
|
|
|
|
break;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_PAINT:
|
|
|
|
hdc = BeginPaint(hDlg, &ps);
|
|
|
|
GetClientRect(hDlg, &rc);
|
|
|
|
Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
|
|
|
|
EndPaint(hDlg, &ps);
|
|
|
|
break;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_SIZING:
|
|
|
|
/* Make sure the user is sizing the dialog */
|
|
|
|
/* in an acceptable range */
|
|
|
|
pRC = (LPRECT)lParam;
|
|
|
|
if ((wParam == WMSZ_LEFT) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_BOTTOMLEFT)) {
|
|
|
|
/* If the width is too small enlarge it to the minimum */
|
|
|
|
if (nMinimumWidth > (pRC->right - pRC->left))
|
|
|
|
pRC->left = pRC->right - nMinimumWidth;
|
|
|
|
} else {
|
|
|
|
/* If the width is too small enlarge it to the minimum */
|
|
|
|
if (nMinimumWidth > (pRC->right - pRC->left))
|
|
|
|
pRC->right = pRC->left + nMinimumWidth;
|
|
|
|
}
|
|
|
|
if ((wParam == WMSZ_TOP) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_TOPRIGHT)) {
|
|
|
|
/* If the height is too small enlarge it to the minimum */
|
|
|
|
if (nMinimumHeight > (pRC->bottom - pRC->top))
|
|
|
|
pRC->top = pRC->bottom - nMinimumHeight;
|
|
|
|
} else {
|
|
|
|
/* If the height is too small enlarge it to the minimum */
|
|
|
|
if (nMinimumHeight > (pRC->bottom - pRC->top))
|
|
|
|
pRC->bottom = pRC->top + nMinimumHeight;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_SIZE:
|
|
|
|
/* Handle the window sizing in it's own function */
|
|
|
|
OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
|
|
|
|
break;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_MOVE:
|
|
|
|
/* Handle the window moving in it's own function */
|
|
|
|
OnMove(wParam, LOWORD(lParam), HIWORD(lParam));
|
|
|
|
break;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_DESTROY:
|
|
|
|
ShowWindow(hDlg, SW_HIDE);
|
|
|
|
TrayIcon_ShellRemoveTrayIcon();
|
|
|
|
wp.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
GetWindowPlacement(hDlg, &wp);
|
|
|
|
TaskManagerSettings.Left = wp.rcNormalPosition.left;
|
|
|
|
TaskManagerSettings.Top = wp.rcNormalPosition.top;
|
|
|
|
TaskManagerSettings.Right = wp.rcNormalPosition.right;
|
|
|
|
TaskManagerSettings.Bottom = wp.rcNormalPosition.bottom;
|
|
|
|
if (IsZoomed(hDlg) || (wp.flags & WPF_RESTORETOMAXIMIZED))
|
|
|
|
TaskManagerSettings.Maximized = TRUE;
|
|
|
|
else
|
|
|
|
TaskManagerSettings.Maximized = FALSE;
|
2011-05-17 12:15:34 +02:00
|
|
|
return DefWindowProcW(hDlg, message, wParam, lParam);
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_TIMER:
|
|
|
|
/* Refresh the performance data */
|
|
|
|
PerfDataRefresh();
|
|
|
|
RefreshApplicationPage();
|
|
|
|
RefreshProcessPage();
|
|
|
|
RefreshPerformancePage();
|
|
|
|
TrayIcon_ShellUpdateTrayIcon();
|
|
|
|
break;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
case WM_ENTERMENULOOP:
|
|
|
|
TaskManager_OnEnterMenuLoop(hDlg);
|
|
|
|
break;
|
|
|
|
case WM_EXITMENULOOP:
|
|
|
|
TaskManager_OnExitMenuLoop(hDlg);
|
|
|
|
break;
|
|
|
|
case WM_MENUSELECT:
|
|
|
|
TaskManager_OnMenuSelect(hDlg, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
|
|
|
|
break;
|
|
|
|
}
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
return 0;
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
int APIENTRY WinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
2004-03-23 02:19:54 +01:00
|
|
|
{
|
2006-03-21 18:35:41 +01:00
|
|
|
HANDLE hProcess;
|
|
|
|
HANDLE hToken;
|
|
|
|
TOKEN_PRIVILEGES tkp;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Initialize global variables */
|
|
|
|
hInst = hInstance;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Change our priority class to HIGH */
|
|
|
|
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
|
|
|
|
SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS);
|
|
|
|
CloseHandle(hProcess);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Now let's get the SE_DEBUG_NAME privilege
|
|
|
|
* so that we can debug processes
|
|
|
|
*/
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Get a token for this process. */
|
|
|
|
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
|
2011-05-17 12:15:34 +02:00
|
|
|
static const WCHAR SeDebugPrivilegeW[] = {'S','e','D','e','b','u','g','P','r','i','v','i','l','e','g','e',0};
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Get the LUID for the debug privilege. */
|
2011-05-17 12:15:34 +02:00
|
|
|
LookupPrivilegeValueW(NULL, SeDebugPrivilegeW, &tkp.Privileges[0].Luid);
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
tkp.PrivilegeCount = 1; /* one privilege to set */
|
|
|
|
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Get the debug privilege for this process. */
|
2008-11-02 00:27:00 +01:00
|
|
|
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0);
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Load our settings from the registry */
|
|
|
|
LoadSettings();
|
2004-03-23 02:19:54 +01:00
|
|
|
|
2006-03-21 18:35:41 +01:00
|
|
|
/* Initialize perf data */
|
|
|
|
if (!PerfDataInitialize()) {
|
|
|
|
return -1;
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|
2006-03-21 18:35:41 +01:00
|
|
|
|
2008-08-20 10:32:24 +02:00
|
|
|
DialogBoxW(hInst, (LPWSTR)IDD_TASKMGR_DIALOG, NULL, TaskManagerWndProc);
|
2006-03-21 18:35:41 +01:00
|
|
|
|
|
|
|
/* Save our settings to the registry */
|
|
|
|
SaveSettings();
|
|
|
|
PerfDataUninitialize();
|
|
|
|
return 0;
|
2004-03-23 02:19:54 +01:00
|
|
|
}
|