Commit d6b348f0 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Ported the ReactOS taskmgr written by Brian Palmer.

parent b613ee7a
...@@ -1679,6 +1679,7 @@ programs/regsvr32/Makefile ...@@ -1679,6 +1679,7 @@ programs/regsvr32/Makefile
programs/rpcss/Makefile programs/rpcss/Makefile
programs/rundll32/Makefile programs/rundll32/Makefile
programs/start/Makefile programs/start/Makefile
programs/taskmgr/Makefile
programs/uninstaller/Makefile programs/uninstaller/Makefile
programs/view/Makefile programs/view/Makefile
programs/wcmd/Makefile programs/wcmd/Makefile
......
...@@ -18,6 +18,7 @@ SUBDIRS = \ ...@@ -18,6 +18,7 @@ SUBDIRS = \
rpcss \ rpcss \
rundll32 \ rundll32 \
start \ start \
taskmgr \
uninstaller \ uninstaller \
view \ view \
wcmd \ wcmd \
...@@ -48,6 +49,7 @@ INSTALLSUBDIRS = \ ...@@ -48,6 +49,7 @@ INSTALLSUBDIRS = \
rpcss \ rpcss \
rundll32 \ rundll32 \
start \ start \
taskmgr \
uninstaller \ uninstaller \
wcmd \ wcmd \
wineboot \ wineboot \
...@@ -98,6 +100,7 @@ SYMLINKS = \ ...@@ -98,6 +100,7 @@ SYMLINKS = \
rpcss.exe \ rpcss.exe \
rundll32.exe \ rundll32.exe \
start.exe \ start.exe \
taskmgr.exe \
uninstaller.exe \ uninstaller.exe \
view.exe \ view.exe \
wcmd.exe \ wcmd.exe \
...@@ -200,6 +203,9 @@ rundll32.exe$(DLLEXT): rundll32/rundll32.exe$(DLLEXT) ...@@ -200,6 +203,9 @@ rundll32.exe$(DLLEXT): rundll32/rundll32.exe$(DLLEXT)
start.exe$(DLLEXT): start/start.exe$(DLLEXT) start.exe$(DLLEXT): start/start.exe$(DLLEXT)
$(RM) $@ && $(LN_S) start/start.exe$(DLLEXT) $@ $(RM) $@ && $(LN_S) start/start.exe$(DLLEXT) $@
taskmgr.exe$(DLLEXT): taskmgr/taskmgr.exe$(DLLEXT)
$(RM) $@ && $(LN_S) taskmgr/taskmgr.exe$(DLLEXT) $@
uninstaller.exe$(DLLEXT): uninstaller/uninstaller.exe$(DLLEXT) uninstaller.exe$(DLLEXT): uninstaller/uninstaller.exe$(DLLEXT)
$(RM) $@ && $(LN_S) uninstaller/uninstaller.exe$(DLLEXT) $@ $(RM) $@ && $(LN_S) uninstaller/uninstaller.exe$(DLLEXT) $@
...@@ -262,6 +268,7 @@ regsvr32/regsvr32.exe$(DLLEXT): regsvr32 ...@@ -262,6 +268,7 @@ regsvr32/regsvr32.exe$(DLLEXT): regsvr32
rpcss/rpcss.exe$(DLLEXT): rpcss rpcss/rpcss.exe$(DLLEXT): rpcss
rundll32/rundll32.exe$(DLLEXT): rundll32 rundll32/rundll32.exe$(DLLEXT): rundll32
start/start.exe$(DLLEXT): start start/start.exe$(DLLEXT): start
taskmgr/taskmgr.exe$(DLLEXT): taskmgr
uninstaller/uninstaller.exe$(DLLEXT): uninstaller uninstaller/uninstaller.exe$(DLLEXT): uninstaller
view/view.exe$(DLLEXT): view view/view.exe$(DLLEXT): view
wcmd/wcmd.exe$(DLLEXT): wcmd wcmd/wcmd.exe$(DLLEXT): wcmd
......
Makefile
font.bmp
taskmgr.exe.dbg.c
taskmgr.ico
taskmgr.res
trayicon.bmp
traymask.bmp
window.ico
windowsm.ico
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = taskmgr.exe
APPMODE = -mwindows
IMPORTS = psapi shell32 comctl32 msvcrt user32 gdi32 advapi32 kernel32
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
EXTRADEFS = -DNO_LIBWINE_PORT
C_SRCS = \
about.c \
affinity.c \
applpage.c \
column.c \
dbgchnl.c \
debug.c \
endproc.c \
graph.c \
graphctl.c \
optnmenu.c \
perfdata.c \
perfpage.c \
priority.c \
proclist.c \
procpage.c \
run.c \
taskmgr.c \
trayicon.c
RC_SRCS = taskmgr.rc
RC_BINSRC = taskmgr.rc
RC_BINARIES = \
font.bmp \
taskmgr.ico \
trayicon.bmp \
traymask.bmp \
window.ico \
windowsm.ico
@MAKE_PROG_RULES@
### Dependencies:
/*
* ReactOS Task Manager
*
* about.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include "taskmgr.h"
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void OnAbout(void)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hMainWnd, (DLGPROC)AboutDialogWndProc);
}
LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hLicenseEditWnd;
TCHAR strLicense[0x1000];
switch (message)
{
case WM_INITDIALOG:
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
LoadString(hInst, IDS_LICENSE, strLicense, 0x1000);
SetWindowText(hLicenseEditWnd, strLicense);
return TRUE;
case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return 0;
}
/*
* ReactOS Task Manager
*
* column.h
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __COLUMN_H
#define __COLUMN_H
#define COLUMN_IMAGENAME 0
#define COLUMN_PID 1
#define COLUMN_USERNAME 2
#define COLUMN_SESSIONID 3
#define COLUMN_CPUUSAGE 4
#define COLUMN_CPUTIME 5
#define COLUMN_MEMORYUSAGE 6
#define COLUMN_PEAKMEMORYUSAGE 7
#define COLUMN_MEMORYUSAGEDELTA 8
#define COLUMN_PAGEFAULTS 9
#define COLUMN_PAGEFAULTSDELTA 10
#define COLUMN_VIRTUALMEMORYSIZE 11
#define COLUMN_PAGEDPOOL 12
#define COLUMN_NONPAGEDPOOL 13
#define COLUMN_BASEPRIORITY 14
#define COLUMN_HANDLECOUNT 15
#define COLUMN_THREADCOUNT 16
#define COLUMN_USEROBJECTS 17
#define COLUMN_GDIOBJECTS 18
#define COLUMN_IOREADS 19
#define COLUMN_IOWRITES 20
#define COLUMN_IOOTHER 21
#define COLUMN_IOREADBYTES 22
#define COLUMN_IOWRITEBYTES 23
#define COLUMN_IOOTHERBYTES 24
extern UINT ColumnDataHints[25];
void ProcessPage_OnViewSelectColumns(void);
void AddColumns(void);
void SaveColumnSettings(void);
void UpdateColumnDataHints(void);
#endif /* __COLUMN_H */
/*
* ReactOS Task Manager
*
* debug.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
void ProcessPage_OnDebug(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
TCHAR strErrorText[260];
HKEY hKey;
TCHAR strDebugPath[260];
TCHAR strDebugger[260];
DWORD dwDebuggerSize;
PROCESS_INFORMATION pi;
STARTUPINFO si;
HANDLE hDebugEvent;
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Debugging this process may result in loss of data.\nAre you sure you wish to attach the debugger?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return;
}
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return;
}
dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
RegCloseKey(hKey);
return;
}
RegCloseKey(hKey);
hDebugEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!hDebugEvent)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
return;
}
wsprintf(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
if (!CreateProcess(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
}
CloseHandle(hDebugEvent);
}
/*
* ReactOS Task Manager
*
* endproc.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
void ProcessPage_OnEndProcess(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
return;
}
if (!TerminateProcess(hProcess, 0))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
}
void ProcessPage_OnEndProcessTree(void)
{
LVITEM lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
memset(&lvitem, 0, sizeof(LVITEM));
lvitem.mask = LVIF_STATE;
lvitem.stateMask = LVIS_SELECTED;
lvitem.iItem = Index;
ListView_GetItem(hProcessPageListCtrl, &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
}
dwProcessId = PerfDataGetProcessId(Index);
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
return;
}
if (!TerminateProcess(hProcess, 0))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
}
/*
* ReactOS Task Manager
*
* graphctl.h
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __GRAPH_CTRL_H__
#define __GRAPH_CTRL_H__
#define MAX_PLOTS 4
#define MAX_CTRLS 4
#ifdef __cplusplus
extern "C" {
#endif
#if 0
/* Attributes */
public:
void SetXUnits(const char* string);
void SetYUnits(const char* string);
/* Operations */
public:
BOOL Create(DWORD dwStyle, const RECT& rect, HWND hParentWnd, UINT nID=NULL);
#endif
typedef struct
{
int m_nShiftPixels; /* amount to shift with each new point */
int m_nYDecimals;
char m_strXUnitsString[50];
char m_strYUnitsString[50];
COLORREF m_crBackColor; /* background color */
COLORREF m_crGridColor; /* grid color */
COLORREF m_crPlotColor[MAX_PLOTS]; /* data color */
double m_dCurrentPosition[MAX_PLOTS]; /* current position */
double m_dPreviousPosition[MAX_PLOTS]; /* previous position */
/* those were protected fields */
int m_nHalfShiftPixels;
int m_nPlotShiftPixels;
int m_nClientHeight;
int m_nClientWidth;
int m_nPlotHeight;
int m_nPlotWidth;
double m_dLowerLimit; /* lower bounds */
double m_dUpperLimit; /* upper bounds */
double m_dRange;
double m_dVerticalFactor;
HWND m_hWnd;
HWND m_hParentWnd;
HDC m_dcGrid;
HDC m_dcPlot;
HBITMAP m_bitmapOldGrid;
HBITMAP m_bitmapOldPlot;
HBITMAP m_bitmapGrid;
HBITMAP m_bitmapPlot;
HBRUSH m_brushBack;
HPEN m_penPlot[MAX_PLOTS];
RECT m_rectClient;
RECT m_rectPlot;
} TGraphCtrl;
extern LONG OldGraphCtrlWndProc;
double GraphCtrl_AppendPoint(TGraphCtrl* this,
double dNewPoint0, double dNewPoint1,
double dNewPoint2, double dNewPoint3);
BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd,
UINT nID);
void GraphCtrl_DrawPoint(TGraphCtrl* this);
void GraphCtrl_InvalidateCtrl(TGraphCtrl* this);
void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc);
void GraphCtrl_Reset(TGraphCtrl* this);
void GraphCtrl_Resize(TGraphCtrl* this);
void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF
color);
void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color);
void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF
color);
void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double
dUpper, int nDecimalPlaces);
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef __cplusplus
}
#endif
#endif /* __GRAPH_CTRL_H__ */
/*
* ReactOS Task Manager
*
* optnmenu.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* options.c
*
* Menu item handlers for the options menu.
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include "taskmgr.h"
#define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* Check or uncheck the always on top menu item
* and update main window.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.AlwaysOnTop = FALSE;
SetWindowPos(hMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.AlwaysOnTop = TRUE;
SetWindowPos(hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
}
void TaskManager_OnOptionsMinimizeOnUse(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* Check or uncheck the minimize on use menu item.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.MinimizeOnUse = FALSE;
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.MinimizeOnUse = TRUE;
}
}
void TaskManager_OnOptionsHideWhenMinimized(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* Check or uncheck the hide when minimized menu item.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.HideWhenMinimized = FALSE;
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.HideWhenMinimized = TRUE;
}
}
void TaskManager_OnOptionsShow16BitTasks(void)
{
HMENU hMenu;
HMENU hOptionsMenu;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
/*
* FIXME: Currently this is useless because the
* current implemetation doesn't list the 16-bit
* processes. I believe that would require querying
* each ntvdm.exe process for it's children.
*/
/*
* Check or uncheck the show 16-bit tasks menu item
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND) & MF_CHECKED)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.Show16BitTasks = FALSE;
}
else
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED);
TaskManagerSettings.Show16BitTasks = TRUE;
}
/*
* Refresh the list of processes.
*/
RefreshProcessPage();
}
/*
* ReactOS Task Manager
*
* proclist.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LONG OldProcessListWndProc;
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HBRUSH hbrBackground;
RECT rcItem;
RECT rcClip;
HDC hDC;
int DcSave;
switch (message)
{
case WM_ERASEBKGND:
/*
* The list control produces a nasty flicker
* when the user is resizing the window because
* it erases the background to white, then
* paints the list items over it.
*
* We will clip the drawing so that it only
* erases the parts of the list control that
* show only the background.
*/
/*
* Get the device context and save it's state
* to be restored after we're done
*/
hDC = (HDC) wParam;
DcSave = SaveDC(hDC);
/*
* Get the background brush
*/
hbrBackground = (HBRUSH) GetClassLong(hWnd, GCL_HBRBACKGROUND);
/*
* Calculate the clip rect by getting the RECT
* of the first and last items and adding them up.
*
* We also have to get the item's icon RECT and
* subtract it from our clip rect because we don't
* use icons in this list control.
*/
ListView_GetItemRect(hWnd, 0, &rcClip, LVIR_BOUNDS);
ListView_GetItemRect(hWnd, ListView_GetItemCount(hWnd) - 1, &rcItem, LVIR_BOUNDS);
rcClip.bottom = rcItem.bottom;
ListView_GetItemRect(hWnd, 0, &rcItem, LVIR_ICON);
rcClip.left = rcItem.right;
/*
* Now exclude the clip rect
*/
ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);
/*
* Now erase the background
*
*
* FIXME: Should I erase it myself or
* pass down the updated HDC and let
* the default handler do it?
*/
GetClientRect(hWnd, &rcItem);
FillRect(hDC, &rcItem, hbrBackground);
/*
* Now restore the DC state that we
* saved earlier
*/
RestoreDC(hDC, DcSave);
return TRUE;
}
/*
* We pass on all messages except WM_ERASEBKGND
*/
return CallWindowProc((WNDPROC)OldProcessListWndProc, hWnd, message, wParam, lParam);
}
/*
*{{NO_DEPENDENCIES}}
* Microsoft Developer Studio generated include file.
* Used by taskmgr.rc
*
*/
#define IDD_TASKMGR_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDD_APPLICATION_PAGE 106
#define IDI_TASKMGR 107
#define IDI_SMALL 108
#define IDC_TASKMGR 109
#define IDR_MAINFRAME 128
#define IDR_TASKMANAGER 130
#define IDD_PROCESS_PAGE 133
#define IDD_PERFORMANCE_PAGE 134
#define IDR_WINDOWSMENU 135
#define IDI_TASKMANAGER 136
#define IDI_WINDOW 137
#define IDI_WINDOWSM 138
#define IDR_APPLICATION_PAGE_CONTEXT1 139
#define IDR_APPLICATION_PAGE_CONTEXT2 140
#define IDR_TRAY_POPUP 141
#define IDD_AFFINITY_DIALOG 142
#define IDD_COLUMNS_DIALOG 143
#define IDR_PROCESS_PAGE_CONTEXT 144
#define IDB_TRAYMASK 150
#define IDB_TRAYICON 153
#define IDB_FONT 154
#define IDD_DEBUG_CHANNELS_DIALOG 155
#define IDC_DEBUG_CHANNELS_LIST 156
#define IDC_ENDTASK 1012
#define IDC_SWITCHTO 1013
#define IDC_NEWTASK 1014
#define IDC_TAB 1015
#define IDC_APPLIST 1016
#define IDC_ENDPROCESS 1017
#define IDC_PROCESSLIST 1018
#define IDC_CPU0 1019
#define IDC_CPU1 1020
#define IDC_CPU2 1021
#define IDC_SHOWALLPROCESSES 1021
#define IDC_CPU3 1022
#define IDC_IMAGENAME 1022
#define IDC_CPU4 1023
#define IDC_PID 1023
#define IDC_CPU5 1024
#define IDC_CPUUSAGE 1024
#define IDC_TOTALS_HANDLE_COUNT 1024
#define IDC_CPU6 1025
#define IDC_CPUTIME 1025
#define IDC_CPU7 1026
#define IDC_MEMORYUSAGE 1026
#define IDC_TOTALS_THREAD_COUNT 1026
#define IDC_CPU8 1027
#define IDC_MEMORYUSAGEDELTA 1027
#define IDC_TOTALS_PROCESS_COUNT 1027
#define IDC_CPU9 1028
#define IDC_PEAKMEMORYUSAGE 1028
#define IDC_COMMIT_CHARGE_TOTAL 1028
#define IDC_CPU10 1029
#define IDC_PAGEFAULTS 1029
#define IDC_COMMIT_CHARGE_LIMIT 1029
#define IDC_LICENSE_EDIT 1029
#define IDC_CPU11 1030
#define IDC_USEROBJECTS 1030
#define IDC_COMMIT_CHARGE_PEAK 1030
#define IDC_CPU12 1031
#define IDC_IOREADS 1031
#define IDC_PHYSICAL_MEMORY_TOTAL 1031
#define IDC_CPU13 1032
#define IDC_IOREADBYTES 1032
#define IDC_PHYSICAL_MEMORY_AVAILABLE 1032
#define IDC_CPU14 1033
#define IDC_SESSIONID 1033
#define IDC_PHYSICAL_MEMORY_SYSTEM_CACHE 1033
#define IDC_CPU15 1034
#define IDC_USERNAME 1034
#define IDC_KERNEL_MEMORY_TOTAL 1034
#define IDC_CPU16 1035
#define IDC_PAGEFAULTSDELTA 1035
#define IDC_KERNEL_MEMORY_PAGED 1035
#define IDC_CPU17 1036
#define IDC_VIRTUALMEMORYSIZE 1036
#define IDC_KERNEL_MEMORY_NONPAGED 1036
#define IDC_CPU18 1037
#define IDC_PAGEDPOOL 1037
#define IDC_TOTALS_FRAME 1037
#define IDC_CPU19 1038
#define IDC_NONPAGEDPOOL 1038
#define IDC_COMMIT_CHARGE_FRAME 1038
#define IDC_CPU20 1039
#define IDC_BASEPRIORITY 1039
#define IDC_KERNEL_MEMORY_FRAME 1039
#define IDC_CPU21 1040
#define IDC_HANDLECOUNT 1040
#define IDC_PHYSICAL_MEMORY_FRAME 1040
#define IDC_CPU22 1041
#define IDC_THREADCOUNT 1041
#define IDC_CPU23 1042
#define IDC_CPU24 1043
#define IDC_GDIOBJECTS 1043
#define IDC_CPU_USAGE_FRAME 1043
#define IDC_CPU25 1044
#define IDC_IOWRITES 1044
#define IDC_MEM_USAGE_FRAME 1044
#define IDC_CPU26 1045
#define IDC_IOWRITEBYTES 1045
#define IDC_CPU_USAGE_HISTORY_FRAME 1045
#define IDC_CPU27 1046
#define IDC_IOOTHER 1046
#define IDC_MEMORY_USAGE_HISTORY_FRAME 1046
#define IDC_CPU28 1047
#define IDC_IOOTHERBYTES 1047
#define IDC_CPU_USAGE_GRAPH 1047
#define IDC_CPU29 1048
#define IDC_MEM_USAGE_GRAPH2 1048
#define IDC_MEM_USAGE_GRAPH 1048
#define IDC_CPU30 1049
#define IDC_MEM_USAGE_HISTORY_GRAPH 1049
#define IDC_CPU_USAGE_HISTORY_GRAPH 1050
#define IDC_CPU31 1051
#define IDS_TOTALS_HANDLE_COUNT 1060
#define IDS_TOTALS_THREAD_COUNT 1061
#define IDS_TOTALS_PROCESS_COUNT 1062
#define IDS_COMMIT_CHARGE_TOTAL 1063
#define IDS_COMMIT_CHARGE_LIMIT 1064
#define IDS_COMMIT_CHARGE_PEAK 1065
#define IDS_PHYSICAL_MEMORY_TOTAL 1066
#define IDS_PHYSICAL_MEMORY_AVAILABLE 1067
#define IDS_PHYSICAL_MEMORY_SYSTEM_CACHE 1068
#define IDS_KERNEL_MEMORY_TOTAL 1069
#define IDS_KERNEL_MEMORY_PAGED 1070
#define IDS_KERNEL_MEMORY_NONPAGED 1071
#define ID_FILE_NEW 32771
#define ID_OPTIONS_ALWAYSONTOP 32773
#define ID_OPTIONS_MINIMIZEONUSE 32774
#define ID_OPTIONS_HIDEWHENMINIMIZED 32775
#define ID_VIEW_REFRESH 32776
#define ID_VIEW_LARGE 32778
#define ID_VIEW_SMALL 32779
#define ID_VIEW_DETAILS 32780
#define ID_VIEW_UPDATESPEED_HIGH 32781
#define ID_VIEW_UPDATESPEED_NORMAL 32782
#define ID_VIEW_UPDATESPEED_LOW 32783
#define ID_VIEW_UPDATESPEED_PAUSED 32784
#define ID_WINDOWS_TILEHORIZONTALLY 32785
#define ID_WINDOWS_TILEVERTICALLY 32786
#define ID_WINDOWS_MINIMIZE 32787
#define ID_WINDOWS_MAXIMIZE 32788
#define ID_WINDOWS_CASCADE 32789
#define ID_WINDOWS_BRINGTOFRONT 32790
#define ID_HELP_TOPICS 32791
#define ID_HELP_ABOUT 32792
#define ID_FILE_EXIT 32793
#define ID_OPTIONS_SHOW16BITTASKS 32794
#define ID_VIEW_SELECTCOLUMNS 32795
#define ID_VIEW_SHOWKERNELTIMES 32796
#define ID_VIEW_CPUHISTORY_ONEGRAPHALL 32797
#define ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU 32798
#define ID_APPLICATION_PAGE_SWITCHTO 32799
#define ID_ENDTASK 32800
#define ID_GOTOPROCESS 32801
#define ID_RESTORE 32802
#define ID_APPLICATION_PAGE_ENDTASK 32803
#define ID_APPLICATION_PAGE_GOTOPROCESS 32804
#define ID_PROCESS_PAGE_ENDPROCESS 32805
#define ID_PROCESS_PAGE_ENDPROCESSTREE 32806
#define ID_PROCESS_PAGE_DEBUG 32807
#define ID_PROCESS_PAGE_SETAFFINITY 32808
#define ID_PROCESS_PAGE_SETPRIORITY_REALTIME 32809
#define ID_PROCESS_PAGE_SETPRIORITY_HIGH 32810
#define ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL 32811
#define ID_PROCESS_PAGE_SETPRIORITY_NORMAL 32812
#define ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL 32813
#define ID_PROCESS_PAGE_SETPRIORITY_LOW 32814
#define ID_PROCESS_PAGE_DEBUGCHANNELS 32815
#define IDS_LICENSE 32816
#define IDC_STATIC -1
/*
* Next default values for new objects
*
*/
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 157
#define _APS_NEXT_COMMAND_VALUE 32817
#define _APS_NEXT_CONTROL_VALUE 1048
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
/*
* ReactOS Task Manager
*
* run.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include "taskmgr.h"
typedef void (WINAPI *RUNFILEDLG)(
HWND hwndOwner,
HICON hIcon,
LPCSTR lpstrDirectory,
LPCSTR lpstrTitle,
LPCSTR lpstrDescription,
UINT uFlags);
/*
* Flags for RunFileDlg
*/
#define RFF_NOBROWSE 0x01 /* Removes the browse button. */
#define RFF_NODEFAULT 0x02 /* No default item selected. */
#define RFF_CALCDIRECTORY 0x04 /* Calculates the working directory from the file name. */
#define RFF_NOLABEL 0x08 /* Removes the edit box label. */
#define RFF_NOSEPARATEMEM 0x20 /* Removes the Separate Memory Space check box (Windows NT only). */
void TaskManager_OnFileNew(void)
{
HMODULE hShell32;
RUNFILEDLG RunFileDlg;
OSVERSIONINFO versionInfo;
WCHAR wTitle[40];
WCHAR wText[256];
char szTitle[40] = "Create New Task";
char szText[256] = "Type the name of a program, folder, document, or Internet resource, and Task Manager will open it for you.";
hShell32 = LoadLibrary(_T("SHELL32.DLL"));
RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D));
/* Show "Run..." dialog */
if (RunFileDlg)
{
versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&versionInfo);
if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256);
RunFileDlg(hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY);
}
else
RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY);
}
FreeLibrary(hShell32);
}
/*
* ReactOS Task Manager
*
* taskmgr.h
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __TASKMGR_H__
#define __TASKMGR_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
/*MF
typedef struct _IO_COUNTERS {
ULONGLONG ReadOperationCount;
ULONGLONG WriteOperationCount;
ULONGLONG OtherOperationCount;
ULONGLONG ReadTransferCount;
ULONGLONG WriteTransferCount;
ULONGLONG OtherTransferCount;
} IO_COUNTERS, *PIO_COUNTERS;
*/
#endif /* _MSC_VER */
#include "resource.h"
#define RUN_APPS_PAGE
#define RUN_PROC_PAGE
#define RUN_PERF_PAGE
#define STATUS_WINDOW 2001
typedef struct
{
/* Window size & position settings */
BOOL Maximized;
int Left;
int Top;
int Right;
int Bottom;
/* Tab settings */
int ActiveTabPage;
/* Options menu settings */
BOOL AlwaysOnTop;
BOOL MinimizeOnUse;
BOOL HideWhenMinimized;
BOOL Show16BitTasks;
/* Update speed settings */
/* How many half-seconds in between updates (i.e. 0 - Paused, 1 - High, 2 - Normal, 4 - Low) */
int UpdateSpeed;
/* Applications page settings */
BOOL View_LargeIcons;
BOOL View_SmallIcons;
BOOL View_Details;
/* Processes page settings */
BOOL ShowProcessesFromAllUsers; /* Server-only? */
BOOL Column_ImageName;
BOOL Column_PID;
BOOL Column_CPUUsage;
BOOL Column_CPUTime;
BOOL Column_MemoryUsage;
BOOL Column_MemoryUsageDelta;
BOOL Column_PeakMemoryUsage;
BOOL Column_PageFaults;
BOOL Column_USERObjects;
BOOL Column_IOReads;
BOOL Column_IOReadBytes;
BOOL Column_SessionID; /* Server-only? */
BOOL Column_UserName; /* Server-only? */
BOOL Column_PageFaultsDelta;
BOOL Column_VirtualMemorySize;
BOOL Column_PagedPool;
BOOL Column_NonPagedPool;
BOOL Column_BasePriority;
BOOL Column_HandleCount;
BOOL Column_ThreadCount;
BOOL Column_GDIObjects;
BOOL Column_IOWrites;
BOOL Column_IOWriteBytes;
BOOL Column_IOOther;
BOOL Column_IOOtherBytes;
int ColumnOrderArray[25];
int ColumnSizeArray[25];
int SortColumn;
BOOL SortAscending;
/* Performance page settings */
BOOL CPUHistory_OneGraphPerCPU;
BOOL ShowKernelTimes;
} TASKMANAGER_SETTINGS, *LPTASKMANAGER_SETTINGS;
/* Global Variables: */
extern HINSTANCE hInst; /* current instance */
extern HWND hMainWnd; /* Main Window */
extern HWND hStatusWnd; /* Status Bar Window */
extern HWND hTabWnd; /* Tab Control Window */
extern int nMinimumWidth; /* Minimum width of the dialog (OnSize()'s cx) */
extern int nMinimumHeight; /* Minimum height of the dialog (OnSize()'s cy) */
extern int nOldWidth; /* Holds the previous client area width */
extern int nOldHeight; /* Holds the previous client area height */
extern TASKMANAGER_SETTINGS TaskManagerSettings;
extern LONG OldProcessListWndProc;
extern LONG OldGraphWndProc;
extern HWND hProcessPage; /* Process List Property Page */
extern HWND hProcessPageListCtrl; /* Process ListCtrl Window */
extern HWND hProcessPageHeaderCtrl; /* Process Header Control */
extern HWND hProcessPageEndProcessButton; /* Process End Process button */
extern HWND hProcessPageShowAllProcessesButton; /* Process Show All Processes checkbox */
extern HWND hPerformancePage; /* Performance Property Page */
extern HWND hApplicationPage; /* Application List Property Page */
extern HWND hApplicationPageListCtrl; /* Application ListCtrl Window */
extern HWND hApplicationPageEndTaskButton; /* Application End Task button */
extern HWND hApplicationPageSwitchToButton; /* Application Switch To button */
extern HWND hApplicationPageNewTaskButton; /* Application New Task button */
/* Foward declarations of functions included in this code module: */
LRESULT CALLBACK TaskManagerWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL OnCreate(HWND hWnd);
void OnSize(UINT nType, int cx, int cy);
void OnMove(UINT nType, int cx, int cy);
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);
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y);
void LoadSettings(void);
void SaveSettings(void);
void TaskManager_OnEnterMenuLoop(HWND hWnd);
void TaskManager_OnExitMenuLoop(HWND hWnd);
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu);
void TaskManager_OnViewUpdateSpeedHigh(void);
void TaskManager_OnViewUpdateSpeedNormal(void);
void TaskManager_OnViewUpdateSpeedLow(void);
void TaskManager_OnViewUpdateSpeedPaused(void);
void TaskManager_OnViewRefresh(void);
void TaskManager_OnTabWndSelChange(void);
void TaskManager_OnOptionsAlwaysOnTop(void);
void TaskManager_OnOptionsMinimizeOnUse(void);
void TaskManager_OnOptionsHideWhenMinimized(void);
void TaskManager_OnOptionsShow16BitTasks(void);
void TaskManager_OnFileNew(void);
LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
void OnAbout(void);
BOOL AreDebugChannelsSupported(void);
void ProcessPage_OnSetAffinity(void);
void ProcessPage_OnDebug(void);
void ProcessPage_OnEndProcess(void);
void ProcessPage_OnEndProcessTree(void);
void ProcessPage_OnSetPriorityRealTime(void);
void ProcessPage_OnSetPriorityHigh(void);
void ProcessPage_OnSetPriorityAboveNormal(void);
void ProcessPage_OnSetPriorityNormal(void);
void ProcessPage_OnSetPriorityBelowNormal(void);
void ProcessPage_OnSetPriorityLow(void);
void ProcessPage_OnDebugChannels(void);
HICON TrayIcon_GetProcessorUsageIcon(void);
BOOL TrayIcon_ShellAddTrayIcon(void);
BOOL TrayIcon_ShellRemoveTrayIcon(void);
BOOL TrayIcon_ShellUpdateTrayIcon(void);
void PerformancePage_OnViewShowKernelTimes(void);
void PerformancePage_OnViewCPUHistoryOneGraphAll(void);
void PerformancePage_OnViewCPUHistoryOneGraphPerCPU(void);
void ApplicationPage_OnViewLargeIcons(void);
void ApplicationPage_OnViewSmallIcons(void);
void ApplicationPage_OnViewDetails(void);
void ApplicationPage_OnWindowsTileHorizontally(void);
void ApplicationPage_OnWindowsTileVertically(void);
void ApplicationPage_OnWindowsMinimize(void);
void ApplicationPage_OnWindowsMaximize(void);
void ApplicationPage_OnWindowsCascade(void);
void ApplicationPage_OnWindowsBringToFront(void);
void ApplicationPage_OnSwitchTo(void);
void ApplicationPage_OnEndTask(void);
void ApplicationPage_OnGotoProcess(void);
void RefreshApplicationPage(void);
void UpdateApplicationListControlViewSetting(void);
void RefreshPerformancePage(void);
void RefreshProcessPage(void);
LRESULT CALLBACK ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK Graph_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef __cplusplus
}
#endif
#endif /* __TASKMGR_H__ */
/*
* ReactOS Task Manager
*
* trayicon.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "taskmgr.h"
#include "perfdata.h"
#include "shellapi.h"
HICON TrayIcon_GetProcessorUsageIcon(void)
{
HICON hTrayIcon = NULL;
HDC hScreenDC = NULL;
HDC hDC = NULL;
HBITMAP hBitmap = NULL;
HBITMAP hOldBitmap = NULL;
HBITMAP hBitmapMask = NULL;
ICONINFO iconInfo;
ULONG ProcessorUsage;
int nLinesToDraw;
HBRUSH hBitmapBrush = NULL;
RECT rc;
/*
* Get a handle to the screen DC
*/
hScreenDC = GetDC(NULL);
if (!hScreenDC)
goto done;
/*
* Create our own DC from it
*/
hDC = CreateCompatibleDC(hScreenDC);
if (!hDC)
goto done;
/*
* Load the bitmaps
*/
hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYICON));
hBitmapMask = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_TRAYMASK));
if (!hBitmap || !hBitmapMask)
goto done;
hBitmapBrush = CreateSolidBrush(RGB(0, 255, 0));
if (!hBitmapBrush)
goto done;
/*
* Select the bitmap into our device context
* so we can draw on it.
*/
hOldBitmap = (HBITMAP) SelectObject(hDC, hBitmap);
/*
* Get the cpu usage
*/
ProcessorUsage = PerfDataGetProcessorUsage();
/*
* Calculate how many lines to draw
* since we have 11 rows of space
* to draw the cpu usage instead of
* just having 10.
*/
nLinesToDraw = (ProcessorUsage + (ProcessorUsage / 10)) / 11;
rc.left = 3;
rc.top = 12 - nLinesToDraw;
rc.right = 13;
rc.bottom = 13;
/*
* Now draw the cpu usage
*/
if (nLinesToDraw)
FillRect(hDC, &rc, hBitmapBrush);
/*
* Now that we are done drawing put the
* old bitmap back.
*/
SelectObject(hDC, hOldBitmap);
hOldBitmap = NULL;
iconInfo.fIcon = TRUE;
iconInfo.xHotspot = 0;
iconInfo.yHotspot = 0;
iconInfo.hbmMask = hBitmapMask;
iconInfo.hbmColor = hBitmap;
hTrayIcon = CreateIconIndirect(&iconInfo);
done:
/*
* Cleanup
*/
if (hScreenDC)
ReleaseDC(NULL, hScreenDC);
if (hOldBitmap)
SelectObject(hDC, hOldBitmap);
if (hDC)
DeleteDC(hDC);
if (hBitmapBrush)
DeleteObject(hBitmapBrush);
if (hBitmap)
DeleteObject(hBitmap);
if (hBitmapMask)
DeleteObject(hBitmapMask);
/*
* Return the newly created tray icon (if successful)
*/
return hTrayIcon;
}
BOOL TrayIcon_ShellAddTrayIcon(void)
{
NOTIFYICONDATA nid;
HICON hIcon = NULL;
BOOL bRetVal;
memset(&nid, 0, sizeof(NOTIFYICONDATA));
hIcon = TrayIcon_GetProcessorUsageIcon();
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hMainWnd;
nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */
nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
bRetVal = Shell_NotifyIcon(NIM_ADD, &nid);
if (hIcon)
DestroyIcon(hIcon);
return bRetVal;
}
BOOL TrayIcon_ShellRemoveTrayIcon(void)
{
NOTIFYICONDATA nid;
BOOL bRetVal;
memset(&nid, 0, sizeof(NOTIFYICONDATA));
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hMainWnd;
nid.uID = 0;
nid.uFlags = 0;
/* nid.uCallbackMessage = ??; */
bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid);
return bRetVal;
}
BOOL TrayIcon_ShellUpdateTrayIcon(void)
{
NOTIFYICONDATA nid;
HICON hIcon = NULL;
BOOL bRetVal;
memset(&nid, 0, sizeof(NOTIFYICONDATA));
hIcon = TrayIcon_GetProcessorUsageIcon();
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hMainWnd;
nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */
nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
bRetVal = Shell_NotifyIcon(NIM_MODIFY, &nid);
if (hIcon)
DestroyIcon(hIcon);
return bRetVal;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment