mirror of
https://github.com/reactos/reactos.git
synced 2024-12-25 16:50:57 +00:00
Updated for building with GCC.
Added graphcntrl for performance page. Various fixes and additions. svn path=/trunk/; revision=3159
This commit is contained in:
parent
7fc762dac1
commit
51036c7f74
20 changed files with 2897 additions and 1596 deletions
File diff suppressed because it is too large
Load diff
722
rosapps/taskmgr/GraphCtrl.cpp
Normal file
722
rosapps/taskmgr/GraphCtrl.cpp
Normal file
|
@ -0,0 +1,722 @@
|
|||
/*
|
||||
* ReactOS Task Manager
|
||||
*
|
||||
* GraphCtrl.cpp
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "math.h"
|
||||
#include "GraphCtrl.h"
|
||||
#include "TaskMgr.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
|
||||
LONG OldGraphCtrlWndProc;
|
||||
|
||||
|
||||
TGraphCtrl::TGraphCtrl() :
|
||||
m_hWnd(0),
|
||||
m_hParentWnd(0),
|
||||
m_dcGrid(0),
|
||||
m_dcPlot(0),
|
||||
m_bitmapOldGrid(0),
|
||||
m_bitmapOldPlot(0),
|
||||
m_bitmapGrid(0),
|
||||
m_bitmapPlot(0),
|
||||
m_brushBack(0)
|
||||
{
|
||||
//RECT m_rectClient;
|
||||
//RECT m_rectPlot;
|
||||
m_penPlot[0] = 0;
|
||||
m_penPlot[1] = 0;
|
||||
m_penPlot[2] = 0;
|
||||
m_penPlot[3] = 0;
|
||||
|
||||
// since plotting is based on a LineTo for each new point
|
||||
// we need a starting point (i.e. a "previous" point)
|
||||
// use 0.0 as the default first point.
|
||||
// these are public member variables, and can be changed outside
|
||||
// (after construction). Therefore m_perviousPosition could be set to
|
||||
// a more appropriate value prior to the first call to SetPosition.
|
||||
m_dPreviousPosition[0] = 0.0;
|
||||
m_dPreviousPosition[1] = 0.0;
|
||||
m_dPreviousPosition[2] = 0.0;
|
||||
m_dPreviousPosition[3] = 0.0;
|
||||
|
||||
// public variable for the number of decimal places on the y axis
|
||||
m_nYDecimals = 3;
|
||||
|
||||
// set some initial values for the scaling until "SetRange" is called.
|
||||
// these are protected varaibles and must be set with SetRange
|
||||
// in order to ensure that m_dRange is updated accordingly
|
||||
// m_dLowerLimit = -10.0;
|
||||
// m_dUpperLimit = 10.0;
|
||||
m_dLowerLimit = 0.0;
|
||||
m_dUpperLimit = 100.0;
|
||||
m_dRange = m_dUpperLimit - m_dLowerLimit; // protected member variable
|
||||
|
||||
// m_nShiftPixels determines how much the plot shifts (in terms of pixels)
|
||||
// with the addition of a new data point
|
||||
m_nShiftPixels = 4;
|
||||
m_nHalfShiftPixels = m_nShiftPixels/2; // protected
|
||||
m_nPlotShiftPixels = m_nShiftPixels + m_nHalfShiftPixels; // protected
|
||||
|
||||
// background, grid and data colors
|
||||
// these are public variables and can be set directly
|
||||
m_crBackColor = RGB( 0, 0, 0); // see also SetBackgroundColor
|
||||
m_crGridColor = RGB( 0, 255, 255); // see also SetGridColor
|
||||
m_crPlotColor[0] = RGB(255, 255, 255); // see also SetPlotColor
|
||||
m_crPlotColor[1] = RGB(100, 255, 255); // see also SetPlotColor
|
||||
m_crPlotColor[2] = RGB(255, 100, 255); // see also SetPlotColor
|
||||
m_crPlotColor[3] = RGB(255, 255, 100); // see also SetPlotColor
|
||||
|
||||
// protected variables
|
||||
int i;
|
||||
for (i = 0; i < MAX_PLOTS; i++) {
|
||||
m_penPlot[i] = CreatePen(PS_SOLID, 0, m_crPlotColor[i]);
|
||||
}
|
||||
m_brushBack = CreateSolidBrush(m_crBackColor);
|
||||
|
||||
// public member variables, can be set directly
|
||||
strcpy(m_strXUnitsString, "Samples"); // can also be set with SetXUnits
|
||||
strcpy(m_strYUnitsString, "Y units"); // can also be set with SetYUnits
|
||||
|
||||
// protected bitmaps to restore the memory DC's
|
||||
m_bitmapOldGrid = NULL;
|
||||
m_bitmapOldPlot = NULL;
|
||||
#if 0
|
||||
for (i = 0; i < MAX_CTRLS; i++) {
|
||||
if (pCtrlArray[i] == 0) {
|
||||
pCtrlArray[i] = this;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
TGraphCtrl::~TGraphCtrl()
|
||||
{
|
||||
// just to be picky restore the bitmaps for the two memory dc's
|
||||
// (these dc's are being destroyed so there shouldn't be any leaks)
|
||||
if (m_bitmapOldGrid != NULL) SelectObject(m_dcGrid, m_bitmapOldGrid);
|
||||
if (m_bitmapOldPlot != NULL) SelectObject(m_dcPlot, m_bitmapOldPlot);
|
||||
if (m_bitmapGrid != NULL) DeleteObject(m_bitmapGrid);
|
||||
if (m_bitmapPlot != NULL) DeleteObject(m_bitmapPlot);
|
||||
if (m_dcGrid != NULL) DeleteDC(m_dcGrid);
|
||||
if (m_dcPlot != NULL) DeleteDC(m_dcPlot);
|
||||
if (m_brushBack != NULL) DeleteObject(m_brushBack);
|
||||
#if 0
|
||||
for (int i = 0; i < MAX_CTRLS; i++) {
|
||||
if (pCtrlArray[i] == this) {
|
||||
pCtrlArray[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
BOOL TGraphCtrl::Create(HWND hWnd, HWND hParentWnd, UINT nID)
|
||||
{
|
||||
BOOL result = 0;
|
||||
|
||||
m_hParentWnd = hParentWnd;
|
||||
m_hWnd = hWnd;
|
||||
Resize();
|
||||
if (result != 0)
|
||||
InvalidateCtrl();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
BOOL TGraphCtrl::Create(DWORD dwStyle, const RECT& rect,
|
||||
HWND hParentWnd, UINT nID)
|
||||
{
|
||||
BOOL result = 0;
|
||||
|
||||
m_hParentWnd = hParentWnd;
|
||||
// GetClientRect(m_hParentWnd, &m_rectClient);
|
||||
|
||||
// set some member variables to avoid multiple function calls
|
||||
m_nClientHeight = rect.bottom - rect.top;//rect.Height();
|
||||
m_nClientWidth = rect.right - rect.left;//rect.Width();
|
||||
// m_nClientHeight = cx;
|
||||
// m_nClientWidth = cy;
|
||||
|
||||
// the "left" coordinate and "width" will be modified in
|
||||
// InvalidateCtrl to be based on the width of the y axis scaling
|
||||
#if 0
|
||||
m_rectPlot.left = 20;
|
||||
m_rectPlot.top = 10;
|
||||
m_rectPlot.right = rect.right-10;
|
||||
m_rectPlot.bottom = rect.bottom-25;
|
||||
#else
|
||||
m_rectPlot.left = -1;
|
||||
m_rectPlot.top = -1;
|
||||
m_rectPlot.right = rect.right-0;
|
||||
m_rectPlot.bottom = rect.bottom-0;
|
||||
#endif
|
||||
// set some member variables to avoid multiple function calls
|
||||
m_nPlotHeight = m_rectPlot.bottom - m_rectPlot.top;//m_rectPlot.Height();
|
||||
m_nPlotWidth = m_rectPlot.right - m_rectPlot.left;//m_rectPlot.Width();
|
||||
|
||||
// set the scaling factor for now, this can be adjusted
|
||||
// in the SetRange functions
|
||||
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
|
||||
|
||||
if (result != 0)
|
||||
InvalidateCtrl();
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::SetRange(double dLower, double dUpper, int nDecimalPlaces)
|
||||
{
|
||||
//ASSERT(dUpper > dLower);
|
||||
m_dLowerLimit = dLower;
|
||||
m_dUpperLimit = dUpper;
|
||||
m_nYDecimals = nDecimalPlaces;
|
||||
m_dRange = m_dUpperLimit - m_dLowerLimit;
|
||||
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
|
||||
// clear out the existing garbage, re-start with a clean plot
|
||||
InvalidateCtrl();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::SetXUnits(const char* string)
|
||||
{
|
||||
strncpy(m_strXUnitsString, string, sizeof(m_strXUnitsString) - 1);
|
||||
// clear out the existing garbage, re-start with a clean plot
|
||||
InvalidateCtrl();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::SetYUnits(const char* string)
|
||||
{
|
||||
strncpy(m_strYUnitsString, string, sizeof(m_strYUnitsString) - 1);
|
||||
// clear out the existing garbage, re-start with a clean plot
|
||||
InvalidateCtrl();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::SetGridColor(COLORREF color)
|
||||
{
|
||||
m_crGridColor = color;
|
||||
// clear out the existing garbage, re-start with a clean plot
|
||||
InvalidateCtrl();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::SetPlotColor(int plot, COLORREF color)
|
||||
{
|
||||
m_crPlotColor[plot] = color;
|
||||
DeleteObject(m_penPlot[plot]);
|
||||
m_penPlot[plot] = CreatePen(PS_SOLID, 0, m_crPlotColor[plot]);
|
||||
// clear out the existing garbage, re-start with a clean plot
|
||||
InvalidateCtrl();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::SetBackgroundColor(COLORREF color)
|
||||
{
|
||||
m_crBackColor = color;
|
||||
DeleteObject(m_brushBack);
|
||||
m_brushBack = CreateSolidBrush(m_crBackColor);
|
||||
// clear out the existing garbage, re-start with a clean plot
|
||||
InvalidateCtrl();
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::InvalidateCtrl()
|
||||
{
|
||||
// There is a lot of drawing going on here - particularly in terms of
|
||||
// drawing the grid. Don't panic, this is all being drawn (only once)
|
||||
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
|
||||
int i, j;
|
||||
int nCharacters;
|
||||
int nTopGridPix, nMidGridPix, nBottomGridPix;
|
||||
|
||||
HPEN oldPen;
|
||||
HPEN solidPen = CreatePen(PS_SOLID, 0, m_crGridColor);
|
||||
//HFONT axisFont, yUnitFont, oldFont;
|
||||
//char strTemp[50];
|
||||
|
||||
// in case we haven't established the memory dc's
|
||||
//CClientDC dc(this);
|
||||
HDC dc = GetDC(m_hParentWnd);
|
||||
|
||||
// if we don't have one yet, set up a memory dc for the grid
|
||||
if (m_dcGrid == NULL) {
|
||||
m_dcGrid = CreateCompatibleDC(dc);
|
||||
m_bitmapGrid = CreateCompatibleBitmap(dc, m_nClientWidth, m_nClientHeight);
|
||||
m_bitmapOldGrid = (HBITMAP)SelectObject(m_dcGrid, m_bitmapGrid);
|
||||
}
|
||||
|
||||
SetBkColor(m_dcGrid, m_crBackColor);
|
||||
|
||||
// fill the grid background
|
||||
FillRect(m_dcGrid, &m_rectClient, m_brushBack);
|
||||
|
||||
// draw the plot rectangle:
|
||||
// determine how wide the y axis scaling values are
|
||||
nCharacters = abs((int)log10(fabs(m_dUpperLimit)));
|
||||
nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit))));
|
||||
|
||||
// add the units digit, decimal point and a minus sign, and an extra space
|
||||
// as well as the number of decimal places to display
|
||||
nCharacters = nCharacters + 4 + m_nYDecimals;
|
||||
|
||||
// adjust the plot rectangle dimensions
|
||||
// assume 6 pixels per character (this may need to be adjusted)
|
||||
// m_rectPlot.left = m_rectClient.left + 6*(nCharacters);
|
||||
m_rectPlot.left = m_rectClient.left;
|
||||
m_nPlotWidth = m_rectPlot.right - m_rectPlot.left;//m_rectPlot.Width();
|
||||
|
||||
// draw the plot rectangle
|
||||
oldPen = (HPEN)SelectObject(m_dcGrid, solidPen);
|
||||
MoveToEx(m_dcGrid, m_rectPlot.left, m_rectPlot.top, NULL);
|
||||
LineTo(m_dcGrid, m_rectPlot.right+1, m_rectPlot.top);
|
||||
LineTo(m_dcGrid, m_rectPlot.right+1, m_rectPlot.bottom+1);
|
||||
LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+1);
|
||||
// LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top);
|
||||
SelectObject(m_dcGrid, oldPen);
|
||||
DeleteObject(solidPen);
|
||||
|
||||
// draw the dotted lines,
|
||||
// use SetPixel instead of a dotted pen - this allows for a
|
||||
// finer dotted line and a more "technical" look
|
||||
nMidGridPix = (m_rectPlot.top + m_rectPlot.bottom)/2;
|
||||
nTopGridPix = nMidGridPix - m_nPlotHeight/4;
|
||||
nBottomGridPix = nMidGridPix + m_nPlotHeight/4;
|
||||
|
||||
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=2) {
|
||||
SetPixel(m_dcGrid, i, nTopGridPix, m_crGridColor);
|
||||
SetPixel(m_dcGrid, i, nMidGridPix, m_crGridColor);
|
||||
SetPixel(m_dcGrid, i, nBottomGridPix, m_crGridColor);
|
||||
}
|
||||
|
||||
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=10) {
|
||||
for (j=m_rectPlot.top; j<m_rectPlot.bottom; j+=2) {
|
||||
SetPixel(m_dcGrid, i, j, m_crGridColor);
|
||||
// SetPixel(m_dcGrid, i, j, m_crGridColor);
|
||||
// SetPixel(m_dcGrid, i, j, m_crGridColor);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// create some fonts (horizontal and vertical)
|
||||
// use a height of 14 pixels and 300 weight
|
||||
// (these may need to be adjusted depending on the display)
|
||||
axisFont = CreateFont (14, 0, 0, 0, 300,
|
||||
FALSE, FALSE, 0, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH|FF_SWISS, "Arial");
|
||||
yUnitFont = CreateFont (14, 0, 900, 0, 300,
|
||||
FALSE, FALSE, 0, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH|FF_SWISS, "Arial");
|
||||
|
||||
// grab the horizontal font
|
||||
oldFont = (HFONT)SelectObject(m_dcGrid, axisFont);
|
||||
|
||||
// y max
|
||||
SetTextColor(m_dcGrid, m_crGridColor);
|
||||
SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
|
||||
sprintf(strTemp, "%.*lf", m_nYDecimals, m_dUpperLimit);
|
||||
TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.top, strTemp, strlen(strTemp));
|
||||
|
||||
// y min
|
||||
SetTextAlign(m_dcGrid, TA_RIGHT|TA_BASELINE);
|
||||
sprintf(strTemp, "%.*lf", m_nYDecimals, m_dLowerLimit);
|
||||
TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.bottom, strTemp, strlen(strTemp));
|
||||
|
||||
// x min
|
||||
SetTextAlign(m_dcGrid, TA_LEFT|TA_TOP);
|
||||
TextOut(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+4, "0", 1);
|
||||
|
||||
// x max
|
||||
SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
|
||||
sprintf(strTemp, "%d", m_nPlotWidth/m_nShiftPixels);
|
||||
TextOut(m_dcGrid, m_rectPlot.right, m_rectPlot.bottom+4, strTemp, strlen(strTemp));
|
||||
|
||||
// x units
|
||||
SetTextAlign(m_dcGrid, TA_CENTER|TA_TOP);
|
||||
TextOut(m_dcGrid, (m_rectPlot.left+m_rectPlot.right)/2,
|
||||
m_rectPlot.bottom+4, m_strXUnitsString, strlen(m_strXUnitsString));
|
||||
|
||||
// restore the font
|
||||
SelectObject(m_dcGrid, oldFont);
|
||||
|
||||
// y units
|
||||
oldFont = (HFONT)SelectObject(m_dcGrid, yUnitFont);
|
||||
SetTextAlign(m_dcGrid, TA_CENTER|TA_BASELINE);
|
||||
TextOut(m_dcGrid, (m_rectClient.left+m_rectPlot.left)/2,
|
||||
(m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString, strlen(m_strYUnitsString));
|
||||
SelectObject(m_dcGrid, oldFont);
|
||||
#endif
|
||||
// at this point we are done filling the the grid bitmap,
|
||||
// no more drawing to this bitmap is needed until the setting are changed
|
||||
|
||||
// if we don't have one yet, set up a memory dc for the plot
|
||||
if (m_dcPlot == NULL) {
|
||||
m_dcPlot = CreateCompatibleDC(dc);
|
||||
m_bitmapPlot = CreateCompatibleBitmap(dc, m_nClientWidth, m_nClientHeight);
|
||||
m_bitmapOldPlot = (HBITMAP)SelectObject(m_dcPlot, m_bitmapPlot);
|
||||
}
|
||||
|
||||
// make sure the plot bitmap is cleared
|
||||
SetBkColor(m_dcPlot, m_crBackColor);
|
||||
FillRect(m_dcPlot, &m_rectClient, m_brushBack);
|
||||
|
||||
// finally, force the plot area to redraw
|
||||
InvalidateRect(m_hParentWnd, &m_rectClient, TRUE);
|
||||
ReleaseDC(m_hParentWnd, dc);
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
double TGraphCtrl::AppendPoint(double dNewPoint0, double dNewPoint1,
|
||||
double dNewPoint2, double dNewPoint3)
|
||||
{
|
||||
// append a data point to the plot & return the previous point
|
||||
double dPrevious;
|
||||
|
||||
dPrevious = m_dCurrentPosition[0];
|
||||
m_dCurrentPosition[0] = dNewPoint0;
|
||||
m_dCurrentPosition[1] = dNewPoint1;
|
||||
m_dCurrentPosition[2] = dNewPoint2;
|
||||
m_dCurrentPosition[3] = dNewPoint3;
|
||||
DrawPoint();
|
||||
//Invalidate();
|
||||
return dPrevious;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::Paint(HWND hWnd, HDC dc)
|
||||
{
|
||||
HDC memDC;
|
||||
HBITMAP memBitmap;
|
||||
HBITMAP oldBitmap; // bitmap originally found in CMemDC
|
||||
|
||||
// RECT rcClient;
|
||||
// GetClientRect(hWnd, &rcClient);
|
||||
// FillSolidRect(dc, &rcClient, RGB(255, 0, 255));
|
||||
// m_nClientWidth = rcClient.right - rcClient.left;
|
||||
// m_nClientHeight = rcClient.bottom - rcClient.top;
|
||||
|
||||
// no real plotting work is performed here,
|
||||
// just putting the existing bitmaps on the client
|
||||
|
||||
// to avoid flicker, establish a memory dc, draw to it
|
||||
// and then BitBlt it to the client
|
||||
memDC = CreateCompatibleDC(dc);
|
||||
memBitmap = (HBITMAP)CreateCompatibleBitmap(dc, m_nClientWidth, m_nClientHeight);
|
||||
oldBitmap = (HBITMAP)SelectObject(memDC, memBitmap);
|
||||
|
||||
if (memDC != NULL) {
|
||||
// first drop the grid on the memory dc
|
||||
BitBlt(memDC, 0, 0, m_nClientWidth, m_nClientHeight, m_dcGrid, 0, 0, SRCCOPY);
|
||||
// now add the plot on top as a "pattern" via SRCPAINT.
|
||||
// works well with dark background and a light plot
|
||||
BitBlt(memDC, 0, 0, m_nClientWidth, m_nClientHeight, m_dcPlot, 0, 0, SRCPAINT); //SRCPAINT
|
||||
// finally send the result to the display
|
||||
BitBlt(dc, 0, 0, m_nClientWidth, m_nClientHeight, memDC, 0, 0, SRCCOPY);
|
||||
}
|
||||
SelectObject(memDC, oldBitmap);
|
||||
DeleteObject(memBitmap);
|
||||
DeleteDC(memDC);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::DrawPoint()
|
||||
{
|
||||
// this does the work of "scrolling" the plot to the left
|
||||
// and appending a new data point all of the plotting is
|
||||
// directed to the memory based bitmap associated with m_dcPlot
|
||||
// the will subsequently be BitBlt'd to the client in Paint
|
||||
|
||||
int currX, prevX, currY, prevY;
|
||||
HPEN oldPen;
|
||||
RECT rectCleanUp;
|
||||
|
||||
if (m_dcPlot != NULL) {
|
||||
// shift the plot by BitBlt'ing it to itself
|
||||
// note: the m_dcPlot covers the entire client
|
||||
// but we only shift bitmap that is the size
|
||||
// of the plot rectangle
|
||||
// grab the right side of the plot (exluding m_nShiftPixels on the left)
|
||||
// move this grabbed bitmap to the left by m_nShiftPixels
|
||||
|
||||
BitBlt(m_dcPlot, m_rectPlot.left, m_rectPlot.top+1,
|
||||
m_nPlotWidth, m_nPlotHeight, m_dcPlot,
|
||||
m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1,
|
||||
SRCCOPY);
|
||||
|
||||
// establish a rectangle over the right side of plot
|
||||
// which now needs to be cleaned up proir to adding the new point
|
||||
rectCleanUp = m_rectPlot;
|
||||
rectCleanUp.left = rectCleanUp.right - m_nShiftPixels;
|
||||
|
||||
// fill the cleanup area with the background
|
||||
FillRect(m_dcPlot, &rectCleanUp, m_brushBack);
|
||||
|
||||
// draw the next line segement
|
||||
for (int i = 0; i < MAX_PLOTS; i++) {
|
||||
|
||||
// grab the plotting pen
|
||||
oldPen = (HPEN)SelectObject(m_dcPlot, m_penPlot[i]);
|
||||
|
||||
// move to the previous point
|
||||
prevX = m_rectPlot.right-m_nPlotShiftPixels;
|
||||
prevY = m_rectPlot.bottom -
|
||||
(long)((m_dPreviousPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
|
||||
MoveToEx(m_dcPlot, prevX, prevY, NULL);
|
||||
|
||||
// draw to the current point
|
||||
currX = m_rectPlot.right-m_nHalfShiftPixels;
|
||||
currY = m_rectPlot.bottom -
|
||||
(long)((m_dCurrentPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
|
||||
LineTo(m_dcPlot, currX, currY);
|
||||
|
||||
// restore the pen
|
||||
SelectObject(m_dcPlot, oldPen);
|
||||
|
||||
// if the data leaks over the upper or lower plot boundaries
|
||||
// fill the upper and lower leakage with the background
|
||||
// this will facilitate clipping on an as needed basis
|
||||
// as opposed to always calling IntersectClipRect
|
||||
|
||||
if ((prevY <= m_rectPlot.top) || (currY <= m_rectPlot.top)) {
|
||||
RECT rc;
|
||||
rc.bottom = m_rectPlot.top+1;
|
||||
rc.left = prevX;
|
||||
rc.right = currX+1;
|
||||
rc.top = m_rectClient.top;
|
||||
FillRect(m_dcPlot, &rc, m_brushBack);
|
||||
}
|
||||
if ((prevY >= m_rectPlot.bottom) || (currY >= m_rectPlot.bottom)) {
|
||||
RECT rc;
|
||||
rc.bottom = m_rectClient.bottom+1;
|
||||
rc.left = prevX;
|
||||
rc.right = currX+1;
|
||||
rc.top = m_rectPlot.bottom+1;
|
||||
//RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1);
|
||||
FillRect(m_dcPlot, &rc, m_brushBack);
|
||||
}
|
||||
|
||||
// store the current point for connection to the next point
|
||||
m_dPreviousPosition[i] = m_dCurrentPosition[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::Resize(void)
|
||||
{
|
||||
// NOTE: Resize automatically gets called during the setup of the control
|
||||
GetClientRect(m_hWnd, &m_rectClient);
|
||||
|
||||
// set some member variables to avoid multiple function calls
|
||||
m_nClientHeight = m_rectClient.bottom - m_rectClient.top;//m_rectClient.Height();
|
||||
m_nClientWidth = m_rectClient.right - m_rectClient.left;//m_rectClient.Width();
|
||||
|
||||
// the "left" coordinate and "width" will be modified in
|
||||
// InvalidateCtrl to be based on the width of the y axis scaling
|
||||
#if 0
|
||||
m_rectPlot.left = 20;
|
||||
m_rectPlot.top = 10;
|
||||
m_rectPlot.right = m_rectClient.right-10;
|
||||
m_rectPlot.bottom = m_rectClient.bottom-25;
|
||||
#else
|
||||
m_rectPlot.left = 0;
|
||||
m_rectPlot.top = -1;
|
||||
m_rectPlot.right = m_rectClient.right-0;
|
||||
m_rectPlot.bottom = m_rectClient.bottom-0;
|
||||
#endif
|
||||
|
||||
// set some member variables to avoid multiple function calls
|
||||
m_nPlotHeight = m_rectPlot.bottom - m_rectPlot.top;//m_rectPlot.Height();
|
||||
m_nPlotWidth = m_rectPlot.right - m_rectPlot.left;//m_rectPlot.Width();
|
||||
|
||||
// set the scaling factor for now, this can be adjusted
|
||||
// in the SetRange functions
|
||||
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
void TGraphCtrl::Reset()
|
||||
{
|
||||
// to clear the existing data (in the form of a bitmap)
|
||||
// simply invalidate the entire control
|
||||
InvalidateCtrl();
|
||||
}
|
||||
|
||||
|
||||
extern TGraphCtrl PerformancePageCpuUsageHistoryGraph;
|
||||
extern TGraphCtrl PerformancePageMemUsageHistoryGraph;
|
||||
extern HWND hPerformancePageCpuUsageHistoryGraph;
|
||||
extern HWND hPerformancePageMemUsageHistoryGraph;
|
||||
|
||||
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT rcClient;
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
//LONG WindowId;
|
||||
//TGraphCtrl* pGraphCtrl;
|
||||
|
||||
switch (message) {
|
||||
/*
|
||||
case WM_ERASEBKGND:
|
||||
return TRUE;
|
||||
//
|
||||
// Filter out mouse & keyboard messages
|
||||
//
|
||||
//case WM_APPCOMMAND:
|
||||
case WM_CAPTURECHANGED:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_MBUTTONDBLCLK:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_MOUSEACTIVATE:
|
||||
case WM_MOUSEHOVER:
|
||||
case WM_MOUSELEAVE:
|
||||
case WM_MOUSEMOVE:
|
||||
//case WM_MOUSEWHEEL:
|
||||
case WM_NCHITTEST:
|
||||
case WM_NCLBUTTONDBLCLK:
|
||||
case WM_NCLBUTTONDOWN:
|
||||
case WM_NCLBUTTONUP:
|
||||
case WM_NCMBUTTONDBLCLK:
|
||||
case WM_NCMBUTTONDOWN:
|
||||
case WM_NCMBUTTONUP:
|
||||
//case WM_NCMOUSEHOVER:
|
||||
//case WM_NCMOUSELEAVE:
|
||||
case WM_NCMOUSEMOVE:
|
||||
case WM_NCRBUTTONDBLCLK:
|
||||
case WM_NCRBUTTONDOWN:
|
||||
case WM_NCRBUTTONUP:
|
||||
//case WM_NCXBUTTONDBLCLK:
|
||||
//case WM_NCXBUTTONDOWN:
|
||||
//case WM_NCXBUTTONUP:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
//case WM_XBUTTONDBLCLK:
|
||||
//case WM_XBUTTONDOWN:
|
||||
//case WM_XBUTTONUP:
|
||||
case WM_ACTIVATE:
|
||||
case WM_CHAR:
|
||||
case WM_DEADCHAR:
|
||||
case WM_GETHOTKEY:
|
||||
case WM_HOTKEY:
|
||||
case WM_KEYDOWN:
|
||||
case WM_KEYUP:
|
||||
case WM_KILLFOCUS:
|
||||
case WM_SETFOCUS:
|
||||
case WM_SETHOTKEY:
|
||||
case WM_SYSCHAR:
|
||||
case WM_SYSDEADCHAR:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_SYSKEYUP:
|
||||
return 0;
|
||||
*/
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
// pGraphCtrl = TGraphCtrl::LookupGraphCtrl(hWnd);
|
||||
// if (pGraphCtrl) pGraphCtrl->Paint(hdc);
|
||||
GetClientRect(hWnd, &rcClient);
|
||||
if (hWnd == hPerformancePageMemUsageHistoryGraph) {
|
||||
PerformancePageMemUsageHistoryGraph.Paint(hWnd, hdc);
|
||||
}
|
||||
if (hWnd == hPerformancePageCpuUsageHistoryGraph) {
|
||||
PerformancePageCpuUsageHistoryGraph.Paint(hWnd, hdc);
|
||||
}
|
||||
EndPaint(hWnd, &ps);
|
||||
return 0;
|
||||
/*
|
||||
WindowId = GetWindowLong(hWnd, GWL_ID);
|
||||
switch (WindowId) {
|
||||
case IDC_CPU_USAGE_GRAPH:
|
||||
Graph_DrawCpuUsageGraph(hdc, hWnd);
|
||||
break;
|
||||
case IDC_MEM_USAGE_GRAPH:
|
||||
Graph_DrawMemUsageGraph(hdc, hWnd);
|
||||
break;
|
||||
case IDC_MEM_USAGE_HISTORY_GRAPH:
|
||||
Graph_DrawMemUsageHistoryGraph(hdc, hWnd);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case WM_SIZE:
|
||||
// pGraphCtrl = TGraphCtrl::LookupGraphCtrl(hWnd);
|
||||
// if (pGraphCtrl) pGraphCtrl->Resize(wParam, HIWORD(lParam), LOWORD(lParam));
|
||||
if (hWnd == hPerformancePageMemUsageHistoryGraph) {
|
||||
PerformancePageMemUsageHistoryGraph.Resize();
|
||||
}
|
||||
if (hWnd == hPerformancePageCpuUsageHistoryGraph) {
|
||||
PerformancePageCpuUsageHistoryGraph.Resize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// We pass on all non-handled messages
|
||||
//
|
||||
return CallWindowProc((WNDPROC)OldGraphCtrlWndProc, hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
#include "GraphCtrl.h"
|
||||
|
||||
TGraphCtrl* TGraphCtrl::pCtrlArray[] = { 0, 0, 0, 0 };
|
||||
int TGraphCtrl::CtrlCount = 0;
|
||||
|
||||
TGraphCtrl* TGraphCtrl::LookupGraphCtrl(HWND hWnd)
|
||||
{
|
||||
for (int i = 0; i < MAX_CTRLS; i++) {
|
||||
if (pCtrlArray[i] != 0) {
|
||||
if (pCtrlArray[i]->m_hParentWnd == hWnd) {
|
||||
return pCtrlArray[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
112
rosapps/taskmgr/GraphCtrl.h
Normal file
112
rosapps/taskmgr/GraphCtrl.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* ReactOS Task Manager
|
||||
*
|
||||
* GraphCtrl.h
|
||||
*
|
||||
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GRAPH_CTRL_H__
|
||||
#define __GRAPH_CTRL_H__
|
||||
|
||||
#define MAX_PLOTS 4
|
||||
#define MAX_CTRLS 4
|
||||
|
||||
|
||||
class TGraphCtrl
|
||||
{
|
||||
// Attributes
|
||||
public:
|
||||
double AppendPoint(double dNewPoint0, double dNewPoint1 = 0.0,
|
||||
double dNewPoint2 = 0.0, double dNewPoint3 = 0.0);
|
||||
void SetRange(double dLower, double dUpper, int nDecimalPlaces=1);
|
||||
void SetXUnits(const char* string);
|
||||
void SetYUnits(const char* string);
|
||||
void SetGridColor(COLORREF color);
|
||||
void SetPlotColor(int plot, COLORREF color);
|
||||
void SetBackgroundColor(COLORREF color);
|
||||
void InvalidateCtrl();
|
||||
void DrawPoint();
|
||||
void Reset();
|
||||
|
||||
// Operations
|
||||
public:
|
||||
BOOL Create(DWORD dwStyle, const RECT& rect, HWND hParentWnd, UINT nID=NULL);
|
||||
BOOL Create(HWND hWnd, HWND hParentWnd, UINT nID=NULL);
|
||||
void Paint(HWND hWnd, HDC dc);
|
||||
void Resize(void);
|
||||
|
||||
#if 0
|
||||
static TGraphCtrl* LookupGraphCtrl(HWND hWnd);
|
||||
static TGraphCtrl* pCtrlArray[MAX_CTRLS];
|
||||
static int CtrlCount;
|
||||
#endif
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
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
|
||||
|
||||
// Construction
|
||||
public:
|
||||
TGraphCtrl();
|
||||
virtual ~TGraphCtrl();
|
||||
|
||||
protected:
|
||||
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;
|
||||
};
|
||||
|
||||
extern LONG OldGraphCtrlWndProc;
|
||||
|
||||
LRESULT CALLBACK GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
#endif /* __GRAPH_CTRL_H__ */
|
||||
/////////////////////////////////////////////////////////////////////////////
|
|
@ -20,16 +20,35 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#include "TASKMGR.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "TaskMgr.h"
|
||||
#include "PerformancePage.h"
|
||||
#include "perfdata.h"
|
||||
|
||||
#include "graph.h"
|
||||
#include "GraphCtrl.h"
|
||||
|
||||
TGraphCtrl PerformancePageCpuUsageHistoryGraph;
|
||||
TGraphCtrl PerformancePageMemUsageHistoryGraph;
|
||||
|
||||
HWND hPerformancePage; // Performance Property Page
|
||||
|
||||
HWND hPerformancePageCpuUsageGraph; // CPU Usage Graph
|
||||
HWND hPerformancePageMemUsageGraph; // MEM Usage Graph
|
||||
HWND hPerformancePageCpuUsageHistoryGraph; // CPU Usage History Graph
|
||||
HWND hPerformancePageMemUsageHistoryGraph; // Memory Usage History Graph
|
||||
|
||||
HWND hPerformancePageTotalsFrame; // Totals Frame
|
||||
|
@ -37,6 +56,11 @@ HWND hPerformancePageCommitChargeFrame; // Commit Charge Frame
|
|||
HWND hPerformancePageKernelMemoryFrame; // Kernel Memory Frame
|
||||
HWND hPerformancePagePhysicalMemoryFrame; // Physical Memory Frame
|
||||
|
||||
HWND hPerformancePageCpuUsageFrame;
|
||||
HWND hPerformancePageMemUsageFrame;
|
||||
HWND hPerformancePageCpuUsageHistoryFrame;
|
||||
HWND hPerformancePageMemUsageHistoryFrame;
|
||||
|
||||
HWND hPerformancePageCommitChargeTotalEdit; // Commit Charge Total Edit Control
|
||||
HWND hPerformancePageCommitChargeLimitEdit; // Commit Charge Limit Edit Control
|
||||
HWND hPerformancePageCommitChargePeakEdit; // Commit Charge Peak Edit Control
|
||||
|
@ -52,6 +76,21 @@ HWND hPerformancePagePhysicalMemorySystemCacheEdit; // Physical Memory System C
|
|||
HWND hPerformancePageTotalsHandleCountEdit; // Total Handles Edit Control
|
||||
HWND hPerformancePageTotalsProcessCountEdit; // Total Processes Edit Control
|
||||
HWND hPerformancePageTotalsThreadCountEdit; // Total Threads Edit Control
|
||||
#if 0
|
||||
HWND hPerformancePageCommitChargeTotalLabel;
|
||||
HWND hPerformancePageCommitChargeLimitLabel;
|
||||
HWND hPerformancePageCommitChargePeakLabel;
|
||||
HWND hPerformancePageKernelMemoryTotalLabel;
|
||||
HWND hPerformancePageKernelMemoryPagedLabel;
|
||||
HWND hPerformancePageKernelMemoryNonPagedLabel;
|
||||
HWND hPerformancePagePhysicalMemoryTotalLabel;
|
||||
HWND hPerformancePagePhysicalMemoryAvailableLabel;
|
||||
HWND hPerformancePagePhysicalMemorySystemCacheLabel;
|
||||
HWND hPerformancePageTotalsHandleCountLabel;
|
||||
HWND hPerformancePageTotalsProcessCountLabel;
|
||||
HWND hPerformancePageTotalsThreadCountLabel;
|
||||
#endif
|
||||
|
||||
|
||||
static int nPerformancePageWidth;
|
||||
static int nPerformancePageHeight;
|
||||
|
@ -60,6 +99,54 @@ static HANDLE hPerformancePageEvent = NULL; // When this event becomes signaled
|
|||
|
||||
void PerformancePageRefreshThread(void *lpParameter);
|
||||
|
||||
void AdjustFramePostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
|
||||
{
|
||||
RECT rc;
|
||||
int cx, cy;
|
||||
GetClientRect(hCntrl, &rc);
|
||||
MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
||||
cx = rc.left + nXDifference;
|
||||
cy = rc.top + nYDifference;
|
||||
SetWindowPos(hCntrl, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
InvalidateRect(hCntrl, NULL, TRUE);
|
||||
}
|
||||
|
||||
void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
|
||||
{
|
||||
RECT rc;
|
||||
int cx, cy, sx, sy;
|
||||
GetClientRect(hCntrl, &rc);
|
||||
MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
||||
// cx = rc.left + nXDifference;
|
||||
// cy = rc.top + nYDifference;
|
||||
cx = rc.left;
|
||||
cy = rc.top;
|
||||
sx = rc.right - rc.left + nXDifference;
|
||||
sy = rc.bottom - rc.top + nYDifference;
|
||||
// SetWindowPos(hCntrl, NULL, 0, 0, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
// SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
SetWindowPos(hCntrl, NULL, cx, cy, sx, sy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
|
||||
InvalidateRect(hCntrl, NULL, TRUE);
|
||||
}
|
||||
|
||||
void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
|
||||
{
|
||||
RECT rc;
|
||||
int cx, cy;
|
||||
|
||||
GetClientRect(hCntrl, &rc);
|
||||
MapWindowPoints(hCntrl, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)));
|
||||
cx = rc.left + nXDifference;
|
||||
cy = rc.top + nYDifference;
|
||||
SetWindowPos(hCntrl, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
InvalidateRect(hCntrl, NULL, TRUE);
|
||||
}
|
||||
|
||||
void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
|
||||
{
|
||||
AdjustControlPostion(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT rc;
|
||||
|
@ -85,6 +172,12 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
|
|||
hPerformancePageCommitChargeFrame = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_FRAME);
|
||||
hPerformancePageKernelMemoryFrame = GetDlgItem(hDlg, IDC_KERNEL_MEMORY_FRAME);
|
||||
hPerformancePagePhysicalMemoryFrame = GetDlgItem(hDlg, IDC_PHYSICAL_MEMORY_FRAME);
|
||||
|
||||
hPerformancePageCpuUsageFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_FRAME);
|
||||
hPerformancePageMemUsageFrame = GetDlgItem(hDlg, IDC_MEM_USAGE_FRAME);
|
||||
hPerformancePageCpuUsageHistoryFrame = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_FRAME);
|
||||
hPerformancePageMemUsageHistoryFrame = GetDlgItem(hDlg, IDC_MEMORY_USAGE_HISTORY_FRAME);
|
||||
|
||||
hPerformancePageCommitChargeTotalEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_TOTAL);
|
||||
hPerformancePageCommitChargeLimitEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_LIMIT);
|
||||
hPerformancePageCommitChargePeakEdit = GetDlgItem(hDlg, IDC_COMMIT_CHARGE_PEAK);
|
||||
|
@ -97,20 +190,63 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
|
|||
hPerformancePageTotalsHandleCountEdit = GetDlgItem(hDlg, IDC_TOTALS_HANDLE_COUNT);
|
||||
hPerformancePageTotalsProcessCountEdit = GetDlgItem(hDlg, IDC_TOTALS_PROCESS_COUNT);
|
||||
hPerformancePageTotalsThreadCountEdit = GetDlgItem(hDlg, IDC_TOTALS_THREAD_COUNT);
|
||||
#if 0
|
||||
hPerformancePageCommitChargeTotalLabel = GetDlgItem(hDlg, IDS_COMMIT_CHARGE_TOTAL);
|
||||
hPerformancePageCommitChargeLimitLabel = GetDlgItem(hDlg, IDS_COMMIT_CHARGE_LIMIT);
|
||||
hPerformancePageCommitChargePeakLabel = GetDlgItem(hDlg, IDS_COMMIT_CHARGE_PEAK);
|
||||
hPerformancePageKernelMemoryTotalLabel = GetDlgItem(hDlg, IDS_KERNEL_MEMORY_TOTAL);
|
||||
hPerformancePageKernelMemoryPagedLabel = GetDlgItem(hDlg, IDS_KERNEL_MEMORY_PAGED);
|
||||
hPerformancePageKernelMemoryNonPagedLabel = GetDlgItem(hDlg, IDS_KERNEL_MEMORY_NONPAGED);
|
||||
hPerformancePagePhysicalMemoryTotalLabel = GetDlgItem(hDlg, IDS_PHYSICAL_MEMORY_TOTAL);
|
||||
hPerformancePagePhysicalMemoryAvailableLabel = GetDlgItem(hDlg, IDS_PHYSICAL_MEMORY_AVAILABLE);
|
||||
hPerformancePagePhysicalMemorySystemCacheLabel = GetDlgItem(hDlg, IDS_PHYSICAL_MEMORY_SYSTEM_CACHE);
|
||||
hPerformancePageTotalsHandleCountLabel = GetDlgItem(hDlg, IDS_TOTALS_HANDLE_COUNT);
|
||||
hPerformancePageTotalsProcessCountLabel = GetDlgItem(hDlg, IDS_TOTALS_PROCESS_COUNT);
|
||||
hPerformancePageTotalsThreadCountLabel = GetDlgItem(hDlg, IDS_TOTALS_THREAD_COUNT);
|
||||
#endif
|
||||
hPerformancePageCpuUsageGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_GRAPH);
|
||||
hPerformancePageMemUsageGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_GRAPH);
|
||||
hPerformancePageMemUsageHistoryGraph = GetDlgItem(hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
|
||||
hPerformancePageCpuUsageHistoryGraph = GetDlgItem(hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
|
||||
|
||||
// Start our refresh thread
|
||||
_beginthread(PerformancePageRefreshThread, 0, NULL);
|
||||
GetClientRect(hPerformancePageCpuUsageHistoryGraph, &rc);
|
||||
// create the control
|
||||
//PerformancePageCpuUsageHistoryGraph.Create(0, rc, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
|
||||
PerformancePageCpuUsageHistoryGraph.Create(hPerformancePageCpuUsageHistoryGraph, hDlg, IDC_CPU_USAGE_HISTORY_GRAPH);
|
||||
// customize the control
|
||||
PerformancePageCpuUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
|
||||
// PerformancePageCpuUsageHistoryGraph.SetYUnits("Current") ;
|
||||
// PerformancePageCpuUsageHistoryGraph.SetXUnits("Samples (Windows Timer: 100 msec)") ;
|
||||
// PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 64)) ;
|
||||
// PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(192, 192, 255)) ;
|
||||
// PerformancePageCpuUsageHistoryGraph.SetPlotColor(RGB(255, 255, 255)) ;
|
||||
PerformancePageCpuUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 0)) ;
|
||||
PerformancePageCpuUsageHistoryGraph.SetGridColor(RGB(152, 205, 152)) ;
|
||||
PerformancePageCpuUsageHistoryGraph.SetPlotColor(0, RGB(255, 0, 0)) ;
|
||||
PerformancePageCpuUsageHistoryGraph.SetPlotColor(1, RGB(0, 255, 0)) ;
|
||||
|
||||
GetClientRect(hPerformancePageMemUsageHistoryGraph, &rc);
|
||||
PerformancePageMemUsageHistoryGraph.Create(hPerformancePageMemUsageHistoryGraph, hDlg, IDC_MEM_USAGE_HISTORY_GRAPH);
|
||||
PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
|
||||
PerformancePageMemUsageHistoryGraph.SetBackgroundColor(RGB(0, 0, 0)) ;
|
||||
PerformancePageMemUsageHistoryGraph.SetGridColor(RGB(152, 215, 152)) ;
|
||||
PerformancePageMemUsageHistoryGraph.SetPlotColor(0, RGB(255, 255, 0)) ;
|
||||
|
||||
// Start our refresh thread
|
||||
#ifdef RUN_PERF_PAGE
|
||||
_beginthread(PerformancePageRefreshThread, 0, NULL);
|
||||
#endif
|
||||
//
|
||||
// Subclass graph buttons
|
||||
//
|
||||
OldGraphWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
||||
SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
||||
SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
||||
OldGraphWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
||||
SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
||||
// SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)Graph_WndProc);
|
||||
|
||||
// OldGraphCtrlWndProc = SetWindowLong(hPerformancePageCpuUsageGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
|
||||
// SetWindowLong(hPerformancePageMemUsageGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
|
||||
OldGraphCtrlWndProc = SetWindowLong(hPerformancePageMemUsageHistoryGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
|
||||
SetWindowLong(hPerformancePageCpuUsageHistoryGraph, GWL_WNDPROC, (LONG)GraphCtrl_WndProc);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
|
@ -128,35 +264,63 @@ LRESULT CALLBACK PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam,
|
|||
nYDifference = cy - nPerformancePageHeight;
|
||||
nPerformancePageWidth = cx;
|
||||
nPerformancePageHeight = cy;
|
||||
// SetWindowPos(hPerformancePageMemUsageHistoryGraph, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
// SetWindowPos(hPerformancePageCpuUsageHistoryGraph, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
|
||||
// Reposition the performance page's controls
|
||||
/*GetWindowRect(hApplicationPageListCtrl, &rc);
|
||||
cx = (rc.right - rc.left) + nXDifference;
|
||||
cy = (rc.bottom - rc.top) + nYDifference;
|
||||
SetWindowPos(hApplicationPageListCtrl, NULL, 0, 0, cx, cy, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOMOVE|SWP_NOZORDER);
|
||||
InvalidateRect(hApplicationPageListCtrl, NULL, TRUE);
|
||||
|
||||
GetClientRect(hApplicationPageEndTaskButton, &rc);
|
||||
MapWindowPoints(hApplicationPageEndTaskButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
||||
cx = rc.left + nXDifference;
|
||||
cy = rc.top + nYDifference;
|
||||
SetWindowPos(hApplicationPageEndTaskButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
InvalidateRect(hApplicationPageEndTaskButton, NULL, TRUE);
|
||||
|
||||
GetClientRect(hApplicationPageSwitchToButton, &rc);
|
||||
MapWindowPoints(hApplicationPageSwitchToButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
||||
cx = rc.left + nXDifference;
|
||||
cy = rc.top + nYDifference;
|
||||
SetWindowPos(hApplicationPageSwitchToButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
InvalidateRect(hApplicationPageSwitchToButton, NULL, TRUE);
|
||||
|
||||
GetClientRect(hApplicationPageNewTaskButton, &rc);
|
||||
MapWindowPoints(hApplicationPageNewTaskButton, hDlg, (LPPOINT)(&rc), (sizeof(RECT)/sizeof(POINT)) );
|
||||
cx = rc.left + nXDifference;
|
||||
cy = rc.top + nYDifference;
|
||||
SetWindowPos(hApplicationPageNewTaskButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
|
||||
InvalidateRect(hApplicationPageNewTaskButton, NULL, TRUE);*/
|
||||
AdjustFramePostion(hPerformancePageTotalsFrame, hDlg, nXDifference, nYDifference);
|
||||
AdjustFramePostion(hPerformancePageCommitChargeFrame, hDlg, nXDifference, nYDifference);
|
||||
AdjustFramePostion(hPerformancePageKernelMemoryFrame, hDlg, nXDifference, nYDifference);
|
||||
AdjustFramePostion(hPerformancePagePhysicalMemoryFrame, hDlg, nXDifference, nYDifference);
|
||||
AdjustFrameSize(hPerformancePageCpuUsageFrame, hDlg, nXDifference, nYDifference);
|
||||
// AdjustFrameSize(hPerformancePageMemUsageFrame, hDlg, nXDifference, nYDifference);
|
||||
// AdjustFrameSize(hPerformancePageCpuUsageHistoryFrame, hDlg, nXDifference, nYDifference);
|
||||
// AdjustFrameSize(hPerformancePageMemUsageHistoryFrame, hDlg, nXDifference, nYDifference);
|
||||
#if 0
|
||||
AdjustControlPostion(hPerformancePageCommitChargeTotalLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageCommitChargeLimitLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageCommitChargePeakLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageKernelMemoryTotalLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageKernelMemoryPagedLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageKernelMemoryNonPagedLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePagePhysicalMemoryTotalLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageTotalsHandleCountLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageTotalsProcessCountLabel, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageTotalsThreadCountLabel, hDlg, nXDifference, nYDifference);
|
||||
#else
|
||||
AdjustCntrlPos(IDS_COMMIT_CHARGE_TOTAL, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_COMMIT_CHARGE_LIMIT, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_COMMIT_CHARGE_PEAK, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_KERNEL_MEMORY_TOTAL, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_KERNEL_MEMORY_PAGED, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_KERNEL_MEMORY_NONPAGED, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_PHYSICAL_MEMORY_TOTAL, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_PHYSICAL_MEMORY_AVAILABLE, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_PHYSICAL_MEMORY_SYSTEM_CACHE, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_TOTALS_HANDLE_COUNT, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_TOTALS_PROCESS_COUNT, hDlg, nXDifference, nYDifference);
|
||||
AdjustCntrlPos(IDS_TOTALS_THREAD_COUNT, hDlg, nXDifference, nYDifference);
|
||||
#endif
|
||||
|
||||
AdjustControlPostion(hPerformancePageCommitChargeTotalEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageCommitChargeLimitEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageCommitChargePeakEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageKernelMemoryTotalEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageKernelMemoryPagedEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageKernelMemoryNonPagedEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePagePhysicalMemoryTotalEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePagePhysicalMemoryAvailableEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePagePhysicalMemorySystemCacheEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageTotalsHandleCountEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageTotalsProcessCountEdit, hDlg, nXDifference, nYDifference);
|
||||
AdjustControlPostion(hPerformancePageTotalsThreadCountEdit, hDlg, nXDifference, nYDifference);
|
||||
|
||||
// AdjustControlPostion(hPerformancePageCpuUsageGraph, hDlg, nXDifference, nYDifference);
|
||||
// AdjustControlPostion(hPerformancePageMemUsageGraph, hDlg, nXDifference, nYDifference);
|
||||
// AdjustControlPostion(hPerformancePageMemUsageHistoryGraph, hDlg, nXDifference, nYDifference);
|
||||
// AdjustControlPostion(hPerformancePageCpuUsageHistoryGraph, hDlg, nXDifference, nYDifference);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -273,7 +437,45 @@ void PerformancePageRefreshThread(void *lpParameter)
|
|||
//
|
||||
InvalidateRect(hPerformancePageCpuUsageGraph, NULL, FALSE);
|
||||
InvalidateRect(hPerformancePageMemUsageGraph, NULL, FALSE);
|
||||
|
||||
//
|
||||
|
||||
ULONG CpuUsage;
|
||||
ULONG CpuKernelUsage;
|
||||
ULONGLONG CommitChargeTotal;
|
||||
ULONGLONG CommitChargeLimit;
|
||||
ULONG PhysicalMemoryTotal;
|
||||
ULONG PhysicalMemoryAvailable;
|
||||
int nBarsUsed1;
|
||||
int nBarsUsed2;
|
||||
|
||||
//
|
||||
// Get the CPU usage
|
||||
//
|
||||
CpuUsage = PerfDataGetProcessorUsage();
|
||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||
if (CpuUsage < 0 ) CpuUsage = 0;
|
||||
if (CpuUsage > 100) CpuUsage = 100;
|
||||
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
|
||||
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
||||
|
||||
//
|
||||
// Get the memory usage
|
||||
//
|
||||
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
|
||||
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
|
||||
nBarsUsed1 = ((CommitChargeTotal * 100) / CommitChargeLimit);
|
||||
|
||||
PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK();
|
||||
PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
|
||||
nBarsUsed2 = ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal);
|
||||
|
||||
|
||||
PerformancePageCpuUsageHistoryGraph.AppendPoint(CpuUsage, CpuKernelUsage);
|
||||
PerformancePageMemUsageHistoryGraph.AppendPoint(nBarsUsed1, nBarsUsed2);
|
||||
//PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ;
|
||||
InvalidateRect(hPerformancePageMemUsageHistoryGraph, NULL, FALSE);
|
||||
InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,30 +20,43 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#include "TASKMGR.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "TaskMgr.h"
|
||||
#include "ProcessPage.h"
|
||||
#include "perfdata.h"
|
||||
#include "column.h"
|
||||
#include "proclist.h"
|
||||
#include <ctype.h>
|
||||
|
||||
HWND hProcessPage; // Process List Property Page
|
||||
HWND hProcessPage; // Process List Property Page
|
||||
|
||||
HWND hProcessPageListCtrl; // Process ListCtrl Window
|
||||
HWND hProcessPageHeaderCtrl; // Process Header Control
|
||||
HWND hProcessPageEndProcessButton; // Process End Process button
|
||||
HWND hProcessPageShowAllProcessesButton; // Process Show All Processes checkbox
|
||||
HWND hProcessPageListCtrl; // Process ListCtrl Window
|
||||
HWND hProcessPageHeaderCtrl; // Process Header Control
|
||||
HWND hProcessPageEndProcessButton; // Process End Process button
|
||||
HWND hProcessPageShowAllProcessesButton;// Process Show All Processes checkbox
|
||||
|
||||
static int nProcessPageWidth;
|
||||
static int nProcessPageHeight;
|
||||
|
||||
static HANDLE hProcessPageEvent = NULL; // When this event becomes signaled then we refresh the process list
|
||||
|
||||
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam);
|
||||
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount);
|
||||
void ProcessPageShowContextMenu(DWORD dwProcessId);
|
||||
void ProcessPageRefreshThread(void *lpParameter);
|
||||
void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam);
|
||||
void CommaSeparateNumberString(LPTSTR strNumber, int nMaxCount);
|
||||
void ProcessPageShowContextMenu(DWORD dwProcessId);
|
||||
void ProcessPageRefreshThread(void *lpParameter);
|
||||
|
||||
LRESULT CALLBACK ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -197,11 +210,15 @@ void ProcessPageOnNotify(WPARAM wParam, LPARAM lParam)
|
|||
if (ColumnDataHints[ColumnIndex] == COLUMN_CPUTIME)
|
||||
{
|
||||
time = PerfDataGetCPUTime(Index);
|
||||
|
||||
DWORD dwHours = (DWORD)(time.QuadPart / 36000000000LL);
|
||||
DWORD dwMinutes = (DWORD)((time.QuadPart % 36000000000LL) / 600000000LL);
|
||||
DWORD dwSeconds = (DWORD)(((time.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
DWORD dwHours = (DWORD)(time.QuadPart / 36000000000L);
|
||||
DWORD dwMinutes = (DWORD)((time.QuadPart % 36000000000L) / 600000000L);
|
||||
DWORD dwSeconds = (DWORD)(((time.QuadPart % 36000000000L) % 600000000L) / 10000000L);
|
||||
#else
|
||||
DWORD dwHours = (DWORD)(time.QuadPart / 36000000000LL);
|
||||
DWORD dwMinutes = (DWORD)((time.QuadPart % 36000000000LL) / 600000000LL);
|
||||
DWORD dwSeconds = (DWORD)(((time.QuadPart % 36000000000LL) % 600000000LL) / 10000000LL);
|
||||
#endif
|
||||
wsprintf(pnmdi->item.pszText, _T("%d:%02d:%02d"), dwHours, dwMinutes, dwSeconds);
|
||||
}
|
||||
if (ColumnDataHints[ColumnIndex] == COLUMN_MEMORYUSAGE)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "about.h"
|
||||
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "ProcessPage.h"
|
||||
#include "affinity.h"
|
||||
|
|
|
@ -19,8 +19,21 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "column.h"
|
||||
#include "ProcessPage.h"
|
||||
|
|
|
@ -19,8 +19,21 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "debug.h"
|
||||
#include "ProcessPage.h"
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "endproc.h"
|
||||
#include "ProcessPage.h"
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "font.h"
|
||||
|
||||
|
@ -32,15 +45,11 @@ void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y)
|
|||
int i;
|
||||
|
||||
hFontDC = CreateCompatibleDC(hDC);
|
||||
|
||||
hFontBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_FONT));
|
||||
|
||||
hOldBitmap = (HBITMAP)SelectObject(hFontDC, hFontBitmap);
|
||||
|
||||
for (i=0; i< (int) _tcslen(lpszText); i++)
|
||||
{
|
||||
if ((lpszText[i] >= '0') && (lpszText[i] <= '9'))
|
||||
{
|
||||
for (i = 0; i < (int)_tcslen(lpszText); i++) {
|
||||
if ((lpszText[i] >= '0') && (lpszText[i] <= '9')) {
|
||||
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, (lpszText[i] - '0') * 8, 0, SRCCOPY);
|
||||
}
|
||||
else if (lpszText[i] == 'K')
|
||||
|
@ -52,7 +61,6 @@ void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y)
|
|||
BitBlt(hDC, x + (i * 8), y, 8, 11, hFontDC, 88, 0, SRCCOPY);
|
||||
}
|
||||
}
|
||||
|
||||
SelectObject(hFontDC, hOldBitmap);
|
||||
DeleteObject(hFontBitmap);
|
||||
DeleteDC(hFontDC);
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "graph.h"
|
||||
#include "font.h"
|
||||
|
@ -160,7 +173,11 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
//
|
||||
CpuUsage = PerfDataGetProcessorUsage();
|
||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||
|
||||
if (CpuUsage < 0) CpuUsage = 0;
|
||||
if (CpuUsage > 100) CpuUsage = 100;
|
||||
if (CpuKernelUsage < 0) CpuKernelUsage = 0;
|
||||
if (CpuKernelUsage > 100) CpuKernelUsage = 100;
|
||||
|
||||
//
|
||||
// Check and see how many digits it will take
|
||||
// so we get the indentation right every time.
|
||||
|
@ -215,6 +232,15 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
rcBarLeft.top = rcBarRight.top = 5;
|
||||
rcBarLeft.bottom = rcBarRight.bottom = 7;
|
||||
|
||||
if (nBarsUsed < 0) nBarsUsed = 0;
|
||||
if (nBarsUsed > nBars) nBarsUsed = nBars;
|
||||
|
||||
if (nBarsFree < 0) nBarsFree = 0;
|
||||
if (nBarsFree > nBars) nBarsFree = nBars;
|
||||
|
||||
if (nBarsUsedKernel < 0) nBarsUsedKernel = 0;
|
||||
if (nBarsUsedKernel > nBars) nBarsUsedKernel = nBars;
|
||||
|
||||
//
|
||||
// Draw the "free" bars
|
||||
//
|
||||
|
@ -235,6 +261,8 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
//
|
||||
for (i=0; i<nBarsUsed; i++)
|
||||
{
|
||||
if (nBarsUsed > 5000) nBarsUsed = 5000;
|
||||
|
||||
FillSolidRect(hDC, &rcBarLeft, BRIGHT_GREEN);
|
||||
FillSolidRect(hDC, &rcBarRight, BRIGHT_GREEN);
|
||||
|
||||
|
@ -250,7 +278,7 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
//
|
||||
rcBarLeft.bottom--;
|
||||
rcBarRight.bottom--;
|
||||
if (nBarsUsedKernel % 2)
|
||||
if (nBarsUsedKernel && nBarsUsedKernel % 2)
|
||||
{
|
||||
rcBarLeft.top -= 2;
|
||||
rcBarLeft.bottom -= 2;
|
||||
|
@ -271,6 +299,8 @@ void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
|
|||
}
|
||||
for (i=0; i<nBarsUsedKernel; i++)
|
||||
{
|
||||
if (nBarsUsedKernel > 5000) nBarsUsedKernel = 5000;
|
||||
|
||||
FillSolidRect(hDC, &rcBarLeft, RED);
|
||||
FillSolidRect(hDC, &rcBarRight, RED);
|
||||
|
||||
|
@ -336,6 +366,12 @@ void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
|
|||
nBarsUsed = (nBars * (int)((CommitChargeTotal * 100) / CommitChargeLimit)) / 100;
|
||||
nBarsFree = nBars - nBarsUsed;
|
||||
|
||||
if (nBarsUsed < 0) nBarsUsed = 0;
|
||||
if (nBarsUsed > nBars) nBarsUsed = nBars;
|
||||
|
||||
if (nBarsFree < 0) nBarsFree = 0;
|
||||
if (nBarsFree > nBars) nBarsFree = nBars;
|
||||
|
||||
//
|
||||
// Now draw the bar graph
|
||||
//
|
||||
|
|
|
@ -26,7 +26,20 @@
|
|||
// Menu item handlers for the options menu.
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "optnmenu.h"
|
||||
#include "ProcessPage.h"
|
||||
|
|
|
@ -20,8 +20,21 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#include "TASKMGR.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "TaskMgr.h"
|
||||
#include "perfdata.h"
|
||||
|
||||
PROCNTQSI NtQuerySystemInformation = NULL;
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "priority.h"
|
||||
#include "ProcessPage.h"
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "ProcessPage.h"
|
||||
#include "proclist.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by TASKMGR.rc
|
||||
// Used by TaskMgr.rc
|
||||
//
|
||||
#define IDD_TASKMGR_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
|
@ -117,7 +117,23 @@
|
|||
#define IDC_MEM_USAGE_GRAPH 1048
|
||||
#define IDC_CPU30 1049
|
||||
#define IDC_MEM_USAGE_HISTORY_GRAPH 1049
|
||||
#define IDC_CPU31 1050
|
||||
#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
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "run.h"
|
||||
|
||||
|
|
|
@ -20,7 +20,20 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#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 <process.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "taskmgr.h"
|
||||
#include "trayicon.h"
|
||||
#include "perfdata.h"
|
||||
|
|
Loading…
Reference in a new issue