setupapi: Update Korean resource.
[wine/testsucceed.git] / programs / taskmgr / graphctl.c
blob2fe2a2968745156108ac038acf474ff57fa1160e
1 /*
2 * ReactOS Task Manager
4 * graphctl.c
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
24 #include <windows.h>
25 #include <commctrl.h>
26 #include <stdlib.h>
27 #include <memory.h>
28 #include <tchar.h>
29 #include <stdio.h>
31 #include <math.h>
32 #include "graphctl.h"
33 #include "taskmgr.h"
35 WNDPROC OldGraphCtrlWndProc;
37 static void GraphCtrl_Init(TGraphCtrl* this)
39 int i;
41 this->m_hWnd = 0;
42 this->m_hParentWnd = 0;
43 this->m_dcGrid = 0;
44 this->m_dcPlot = 0;
45 this->m_bitmapOldGrid = 0;
46 this->m_bitmapOldPlot = 0;
47 this->m_bitmapGrid = 0;
48 this->m_bitmapPlot = 0;
49 this->m_brushBack = 0;
51 this->m_penPlot[0] = 0;
52 this->m_penPlot[1] = 0;
53 this->m_penPlot[2] = 0;
54 this->m_penPlot[3] = 0;
56 /* since plotting is based on a LineTo for each new point
57 * we need a starting point (i.e. a "previous" point)
58 * use 0.0 as the default first point.
59 * these are public member variables, and can be changed outside
60 * (after construction). Therefore m_perviousPosition could be set to
61 * a more appropriate value prior to the first call to SetPosition.
63 this->m_dPreviousPosition[0] = 0.0;
64 this->m_dPreviousPosition[1] = 0.0;
65 this->m_dPreviousPosition[2] = 0.0;
66 this->m_dPreviousPosition[3] = 0.0;
68 /* public variable for the number of decimal places on the y axis */
69 this->m_nYDecimals = 3;
71 /* set some initial values for the scaling until "SetRange" is called.
72 * these are protected varaibles and must be set with SetRange
73 * in order to ensure that m_dRange is updated accordingly
75 /* m_dLowerLimit = -10.0; */
76 /* m_dUpperLimit = 10.0; */
77 this->m_dLowerLimit = 0.0;
78 this->m_dUpperLimit = 100.0;
79 this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit; /* protected member variable */
81 /* m_nShiftPixels determines how much the plot shifts (in terms of pixels) */
82 /* with the addition of a new data point */
83 this->m_nShiftPixels = 4;
84 this->m_nHalfShiftPixels = this->m_nShiftPixels/2; /* protected */
85 this->m_nPlotShiftPixels = this->m_nShiftPixels + this->m_nHalfShiftPixels; /* protected */
87 /* background, grid and data colors */
88 /* these are public variables and can be set directly */
89 this->m_crBackColor = RGB( 0, 0, 0); /* see also SetBackgroundColor */
90 this->m_crGridColor = RGB( 0, 255, 255); /* see also SetGridColor */
91 this->m_crPlotColor[0] = RGB(255, 255, 255); /* see also SetPlotColor */
92 this->m_crPlotColor[1] = RGB(100, 255, 255); /* see also SetPlotColor */
93 this->m_crPlotColor[2] = RGB(255, 100, 255); /* see also SetPlotColor */
94 this->m_crPlotColor[3] = RGB(255, 255, 100); /* see also SetPlotColor */
96 /* protected variables */
97 for (i = 0; i < MAX_PLOTS; i++)
99 this->m_penPlot[i] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[i]);
101 this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
103 /* public member variables, can be set directly */
104 strcpy(this->m_strXUnitsString, "Samples"); /* can also be set with SetXUnits */
105 strcpy(this->m_strYUnitsString, "Y units"); /* can also be set with SetYUnits */
107 /* protected bitmaps to restore the memory DC's */
108 this->m_bitmapOldGrid = NULL;
109 this->m_bitmapOldPlot = NULL;
112 #if 0
113 TGraphCtrl::~TGraphCtrl(void)
115 /* just to be picky restore the bitmaps for the two memory dc's */
116 /* (these dc's are being destroyed so there shouldn't be any leaks) */
117 if (m_bitmapOldGrid != NULL) SelectObject(m_dcGrid, m_bitmapOldGrid);
118 if (m_bitmapOldPlot != NULL) SelectObject(m_dcPlot, m_bitmapOldPlot);
119 if (m_bitmapGrid != NULL) DeleteObject(m_bitmapGrid);
120 if (m_bitmapPlot != NULL) DeleteObject(m_bitmapPlot);
121 if (m_dcGrid != NULL) DeleteDC(m_dcGrid);
122 if (m_dcPlot != NULL) DeleteDC(m_dcPlot);
123 if (m_brushBack != NULL) DeleteObject(m_brushBack);
125 #endif
127 static void GraphCtrl_Resize(TGraphCtrl* this)
129 /* NOTE: Resize automatically gets called during the setup of the control */
130 GetClientRect(this->m_hWnd, &this->m_rectClient);
132 /* set some member variables to avoid multiple function calls */
133 this->m_nClientHeight = this->m_rectClient.bottom - this->m_rectClient.top;/* m_rectClient.Height(); */
134 this->m_nClientWidth = this->m_rectClient.right - this->m_rectClient.left;/* m_rectClient.Width(); */
136 /* the "left" coordinate and "width" will be modified in */
137 /* InvalidateCtrl to be based on the width of the y axis scaling */
138 #if 0
139 this->m_rectPlot.left = 20;
140 this->m_rectPlot.top = 10;
141 this->m_rectPlot.right = this->m_rectClient.right-10;
142 this->m_rectPlot.bottom = this->m_rectClient.bottom-25;
143 #else
144 this->m_rectPlot.left = 0;
145 this->m_rectPlot.top = -1;
146 this->m_rectPlot.right = this->m_rectClient.right-0;
147 this->m_rectPlot.bottom = this->m_rectClient.bottom-0;
148 #endif
150 /* set some member variables to avoid multiple function calls */
151 this->m_nPlotHeight = this->m_rectPlot.bottom - this->m_rectPlot.top;/* m_rectPlot.Height(); */
152 this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
154 /* set the scaling factor for now, this can be adjusted */
155 /* in the SetRange functions */
156 this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
159 BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
161 GraphCtrl_Init(this);
162 this->m_hParentWnd = hParentWnd;
163 this->m_hWnd = hWnd;
164 GraphCtrl_Resize(this);
165 return 0;
168 static void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
170 /* There is a lot of drawing going on here - particularly in terms of */
171 /* drawing the grid. Don't panic, this is all being drawn (only once) */
172 /* to a bitmap. The result is then BitBlt'd to the control whenever needed. */
173 int i, j;
174 int nCharacters;
175 int nTopGridPix, nMidGridPix, nBottomGridPix;
177 HPEN oldPen;
178 HPEN solidPen = CreatePen(PS_SOLID, 0, this->m_crGridColor);
179 /* HFONT axisFont, yUnitFont, oldFont; */
180 /* char strTemp[50]; */
182 /* in case we haven't established the memory dc's */
183 /* CClientDC dc(this); */
184 HDC dc = GetDC(this->m_hParentWnd);
186 /* if we don't have one yet, set up a memory dc for the grid */
187 if (this->m_dcGrid == NULL)
189 this->m_dcGrid = CreateCompatibleDC(dc);
190 this->m_bitmapGrid = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
191 this->m_bitmapOldGrid = SelectObject(this->m_dcGrid, this->m_bitmapGrid);
194 SetBkColor(this->m_dcGrid, this->m_crBackColor);
196 /* fill the grid background */
197 FillRect(this->m_dcGrid, &this->m_rectClient, this->m_brushBack);
199 /* draw the plot rectangle: */
200 /* determine how wide the y axis scaling values are */
201 nCharacters = abs((int)log10(fabs(this->m_dUpperLimit)));
202 nCharacters = max(nCharacters, abs((int)log10(fabs(this->m_dLowerLimit))));
204 /* add the units digit, decimal point and a minus sign, and an extra space */
205 /* as well as the number of decimal places to display */
206 nCharacters = nCharacters + 4 + this->m_nYDecimals;
208 /* adjust the plot rectangle dimensions */
209 /* assume 6 pixels per character (this may need to be adjusted) */
210 /* m_rectPlot.left = m_rectClient.left + 6*(nCharacters); */
211 this->m_rectPlot.left = this->m_rectClient.left;
212 this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
214 /* draw the plot rectangle */
215 oldPen = SelectObject(this->m_dcGrid, solidPen);
216 MoveToEx(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.top, NULL);
217 LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.top);
218 LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.bottom+1);
219 LineTo(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.bottom+1);
220 /* LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top); */
221 SelectObject(this->m_dcGrid, oldPen);
222 DeleteObject(solidPen);
224 /* draw the dotted lines,
225 * use SetPixel instead of a dotted pen - this allows for a
226 * finer dotted line and a more "technical" look
228 nMidGridPix = (this->m_rectPlot.top + this->m_rectPlot.bottom)/2;
229 nTopGridPix = nMidGridPix - this->m_nPlotHeight/4;
230 nBottomGridPix = nMidGridPix + this->m_nPlotHeight/4;
232 for (i=this->m_rectPlot.left; i<this->m_rectPlot.right; i+=2)
234 SetPixel(this->m_dcGrid, i, nTopGridPix, this->m_crGridColor);
235 SetPixel(this->m_dcGrid, i, nMidGridPix, this->m_crGridColor);
236 SetPixel(this->m_dcGrid, i, nBottomGridPix, this->m_crGridColor);
239 for (i=this->m_rectPlot.left; i<this->m_rectPlot.right; i+=10)
241 for (j=this->m_rectPlot.top; j<this->m_rectPlot.bottom; j+=2)
243 SetPixel(this->m_dcGrid, i, j, this->m_crGridColor);
244 /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
245 /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
249 #if 0
250 /* create some fonts (horizontal and vertical) */
251 /* use a height of 14 pixels and 300 weight */
252 /* (these may need to be adjusted depending on the display) */
253 axisFont = CreateFont (14, 0, 0, 0, 300,
254 FALSE, FALSE, 0, ANSI_CHARSET,
255 OUT_DEFAULT_PRECIS,
256 CLIP_DEFAULT_PRECIS,
257 DEFAULT_QUALITY,
258 DEFAULT_PITCH|FF_SWISS, "Arial");
259 yUnitFont = CreateFont (14, 0, 900, 0, 300,
260 FALSE, FALSE, 0, ANSI_CHARSET,
261 OUT_DEFAULT_PRECIS,
262 CLIP_DEFAULT_PRECIS,
263 DEFAULT_QUALITY,
264 DEFAULT_PITCH|FF_SWISS, "Arial");
266 /* grab the horizontal font */
267 oldFont = SelectObject(m_dcGrid, axisFont);
269 /* y max */
270 SetTextColor(m_dcGrid, m_crGridColor);
271 SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
272 sprintf(strTemp, "%.*lf", m_nYDecimals, m_dUpperLimit);
273 TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.top, strTemp, _tcslen(strTemp));
275 /* y min */
276 SetTextAlign(m_dcGrid, TA_RIGHT|TA_BASELINE);
277 sprintf(strTemp, "%.*lf", m_nYDecimals, m_dLowerLimit);
278 TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.bottom, strTemp, _tcslen(strTemp));
280 /* x min */
281 SetTextAlign(m_dcGrid, TA_LEFT|TA_TOP);
282 TextOut(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+4, "0", 1);
284 /* x max */
285 SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
286 sprintf(strTemp, "%d", m_nPlotWidth/m_nShiftPixels);
287 TextOut(m_dcGrid, m_rectPlot.right, m_rectPlot.bottom+4, strTemp, _tcslen(strTemp));
289 /* x units */
290 SetTextAlign(m_dcGrid, TA_CENTER|TA_TOP);
291 TextOut(m_dcGrid, (m_rectPlot.left+m_rectPlot.right)/2,
292 m_rectPlot.bottom+4, m_strXUnitsString, _tcslen(m_strXUnitsString));
294 /* restore the font */
295 SelectObject(m_dcGrid, oldFont);
297 /* y units */
298 oldFont = SelectObject(m_dcGrid, yUnitFont);
299 SetTextAlign(m_dcGrid, TA_CENTER|TA_BASELINE);
300 TextOut(m_dcGrid, (m_rectClient.left+m_rectPlot.left)/2,
301 (m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString, _tcslen(m_strYUnitsString));
302 SelectObject(m_dcGrid, oldFont);
303 #endif
304 /* at this point we are done filling the grid bitmap, */
305 /* no more drawing to this bitmap is needed until the settings are changed */
307 /* if we don't have one yet, set up a memory dc for the plot */
308 if (this->m_dcPlot == NULL)
310 this->m_dcPlot = CreateCompatibleDC(dc);
311 this->m_bitmapPlot = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
312 this->m_bitmapOldPlot = SelectObject(this->m_dcPlot, this->m_bitmapPlot);
315 /* make sure the plot bitmap is cleared */
316 SetBkColor(this->m_dcPlot, this->m_crBackColor);
317 FillRect(this->m_dcPlot, &this->m_rectClient, this->m_brushBack);
319 /* finally, force the plot area to redraw */
320 InvalidateRect(this->m_hParentWnd, &this->m_rectClient, TRUE);
321 ReleaseDC(this->m_hParentWnd, dc);
324 void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces)
326 /* ASSERT(dUpper > dLower); */
327 this->m_dLowerLimit = dLower;
328 this->m_dUpperLimit = dUpper;
329 this->m_nYDecimals = nDecimalPlaces;
330 this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit;
331 this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
332 /* clear out the existing garbage, re-start with a clean plot */
333 GraphCtrl_InvalidateCtrl(this);
336 #if 0
337 void TGraphCtrl::SetXUnits(const char* string)
339 lstrcpynA(m_strXUnitsString, string, sizeof(m_strXUnitsString));
340 /* clear out the existing garbage, re-start with a clean plot */
341 InvalidateCtrl();
344 void TGraphCtrl::SetYUnits(const char* string)
346 lstrcpynA(m_strYUnitsString, string, sizeof(m_strYUnitsString));
347 /* clear out the existing garbage, re-start with a clean plot */
348 InvalidateCtrl();
350 #endif
352 void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color)
354 this->m_crGridColor = color;
355 /* clear out the existing garbage, re-start with a clean plot */
356 GraphCtrl_InvalidateCtrl(this);
359 void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF color)
361 this->m_crPlotColor[plot] = color;
362 DeleteObject(this->m_penPlot[plot]);
363 this->m_penPlot[plot] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[plot]);
364 /* clear out the existing garbage, re-start with a clean plot */
365 GraphCtrl_InvalidateCtrl(this);
368 void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF color)
370 this->m_crBackColor = color;
371 DeleteObject(this->m_brushBack);
372 this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
373 /* clear out the existing garbage, re-start with a clean plot */
374 GraphCtrl_InvalidateCtrl(this);
377 static void GraphCtrl_DrawPoint(TGraphCtrl* this)
379 /* this does the work of "scrolling" the plot to the left
380 * and appending a new data point all of the plotting is
381 * directed to the memory based bitmap associated with m_dcPlot
382 * the will subsequently be BitBlt'd to the client in Paint
384 int currX, prevX, currY, prevY;
385 HPEN oldPen;
386 RECT rectCleanUp;
387 int i;
389 if (this->m_dcPlot != NULL)
391 /* shift the plot by BitBlt'ing it to itself
392 * note: the m_dcPlot covers the entire client
393 * but we only shift bitmap that is the size
394 * of the plot rectangle
395 * grab the right side of the plot (excluding m_nShiftPixels on the left)
396 * move this grabbed bitmap to the left by m_nShiftPixels
398 BitBlt(this->m_dcPlot, this->m_rectPlot.left, this->m_rectPlot.top+1,
399 this->m_nPlotWidth, this->m_nPlotHeight, this->m_dcPlot,
400 this->m_rectPlot.left+this->m_nShiftPixels, this->m_rectPlot.top+1,
401 SRCCOPY);
403 /* establish a rectangle over the right side of plot */
404 /* which now needs to be cleaned up proir to adding the new point */
405 rectCleanUp = this->m_rectPlot;
406 rectCleanUp.left = rectCleanUp.right - this->m_nShiftPixels;
408 /* fill the cleanup area with the background */
409 FillRect(this->m_dcPlot, &rectCleanUp, this->m_brushBack);
411 /* draw the next line segment */
412 for (i = 0; i < MAX_PLOTS; i++)
414 /* grab the plotting pen */
415 oldPen = SelectObject(this->m_dcPlot, this->m_penPlot[i]);
417 /* move to the previous point */
418 prevX = this->m_rectPlot.right-this->m_nPlotShiftPixels;
419 prevY = this->m_rectPlot.bottom -
420 (int)((this->m_dPreviousPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor);
421 MoveToEx(this->m_dcPlot, prevX, prevY, NULL);
423 /* draw to the current point */
424 currX = this->m_rectPlot.right-this->m_nHalfShiftPixels;
425 currY = this->m_rectPlot.bottom -
426 (int)((this->m_dCurrentPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor);
427 LineTo(this->m_dcPlot, currX, currY);
429 /* Restore the pen */
430 SelectObject(this->m_dcPlot, oldPen);
432 /* if the data leaks over the upper or lower plot boundaries
433 * fill the upper and lower leakage with the background
434 * this will facilitate clipping on an as needed basis
435 * as opposed to always calling IntersectClipRect
437 if ((prevY <= this->m_rectPlot.top) || (currY <= this->m_rectPlot.top))
439 RECT rc;
440 rc.bottom = this->m_rectPlot.top+1;
441 rc.left = prevX;
442 rc.right = currX+1;
443 rc.top = this->m_rectClient.top;
444 FillRect(this->m_dcPlot, &rc, this->m_brushBack);
446 if ((prevY >= this->m_rectPlot.bottom) || (currY >= this->m_rectPlot.bottom))
448 RECT rc;
449 rc.bottom = this->m_rectClient.bottom+1;
450 rc.left = prevX;
451 rc.right = currX+1;
452 rc.top = this->m_rectPlot.bottom+1;
453 /* RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1); */
454 FillRect(this->m_dcPlot, &rc, this->m_brushBack);
457 /* store the current point for connection to the next point */
458 this->m_dPreviousPosition[i] = this->m_dCurrentPosition[i];
463 double GraphCtrl_AppendPoint(TGraphCtrl* this,
464 double dNewPoint0, double dNewPoint1,
465 double dNewPoint2, double dNewPoint3)
467 /* append a data point to the plot & return the previous point */
468 double dPrevious;
470 dPrevious = this->m_dCurrentPosition[0];
471 this->m_dCurrentPosition[0] = dNewPoint0;
472 this->m_dCurrentPosition[1] = dNewPoint1;
473 this->m_dCurrentPosition[2] = dNewPoint2;
474 this->m_dCurrentPosition[3] = dNewPoint3;
475 GraphCtrl_DrawPoint(this);
476 /* Invalidate(); */
477 return dPrevious;
480 static void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc)
482 HDC memDC;
483 HBITMAP memBitmap;
484 HBITMAP oldBitmap; /* bitmap originally found in CMemDC */
486 /* RECT rcClient; */
487 /* GetClientRect(hWnd, &rcClient); */
488 /* FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); */
489 /* m_nClientWidth = rcClient.right - rcClient.left; */
490 /* m_nClientHeight = rcClient.bottom - rcClient.top; */
492 /* no real plotting work is performed here, */
493 /* just putting the existing bitmaps on the client */
495 /* to avoid flicker, establish a memory dc, draw to it */
496 /* and then BitBlt it to the client */
497 memDC = CreateCompatibleDC(dc);
498 memBitmap = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
499 oldBitmap = SelectObject(memDC, memBitmap);
501 if (memDC != NULL)
503 /* first drop the grid on the memory dc */
504 BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcGrid, 0, 0, SRCCOPY);
505 /* now add the plot on top as a "pattern" via SRCPAINT. */
506 /* works well with dark background and a light plot */
507 BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcPlot, 0, 0, SRCPAINT); /* SRCPAINT */
508 /* finally send the result to the display */
509 BitBlt(dc, 0, 0, this->m_nClientWidth, this->m_nClientHeight, memDC, 0, 0, SRCCOPY);
511 SelectObject(memDC, oldBitmap);
512 DeleteObject(memBitmap);
513 DeleteDC(memDC);
516 #if 0
517 void TGraphCtrl::Reset(void)
519 /* to clear the existing data (in the form of a bitmap) */
520 /* simply invalidate the entire control */
521 InvalidateCtrl();
523 #endif
525 extern TGraphCtrl PerformancePageCpuUsageHistoryGraph;
526 extern TGraphCtrl PerformancePageMemUsageHistoryGraph;
527 extern HWND hPerformancePageCpuUsageHistoryGraph;
528 extern HWND hPerformancePageMemUsageHistoryGraph;
530 INT_PTR CALLBACK
531 GraphCtrl_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
533 RECT rcClient;
534 HDC hdc;
535 PAINTSTRUCT ps;
537 switch (message)
539 case WM_ERASEBKGND:
540 return TRUE;
542 * Filter out mouse & keyboard messages
544 /* case WM_APPCOMMAND: */
545 case WM_CAPTURECHANGED:
546 case WM_LBUTTONDBLCLK:
547 case WM_LBUTTONDOWN:
548 case WM_LBUTTONUP:
549 case WM_MBUTTONDBLCLK:
550 case WM_MBUTTONDOWN:
551 case WM_MBUTTONUP:
552 case WM_MOUSEACTIVATE:
553 case WM_MOUSEHOVER:
554 case WM_MOUSELEAVE:
555 case WM_MOUSEMOVE:
556 /* case WM_MOUSEWHEEL: */
557 case WM_NCHITTEST:
558 case WM_NCLBUTTONDBLCLK:
559 case WM_NCLBUTTONDOWN:
560 case WM_NCLBUTTONUP:
561 case WM_NCMBUTTONDBLCLK:
562 case WM_NCMBUTTONDOWN:
563 case WM_NCMBUTTONUP:
564 /* case WM_NCMOUSEHOVER: */
565 /* case WM_NCMOUSELEAVE: */
566 case WM_NCMOUSEMOVE:
567 case WM_NCRBUTTONDBLCLK:
568 case WM_NCRBUTTONDOWN:
569 case WM_NCRBUTTONUP:
570 /* case WM_NCXBUTTONDBLCLK: */
571 /* case WM_NCXBUTTONDOWN: */
572 /* case WM_NCXBUTTONUP: */
573 case WM_RBUTTONDBLCLK:
574 case WM_RBUTTONDOWN:
575 case WM_RBUTTONUP:
576 /* case WM_XBUTTONDBLCLK: */
577 /* case WM_XBUTTONDOWN: */
578 /* case WM_XBUTTONUP: */
579 case WM_ACTIVATE:
580 case WM_CHAR:
581 case WM_DEADCHAR:
582 case WM_GETHOTKEY:
583 case WM_HOTKEY:
584 case WM_KEYDOWN:
585 case WM_KEYUP:
586 case WM_KILLFOCUS:
587 case WM_SETFOCUS:
588 case WM_SETHOTKEY:
589 case WM_SYSCHAR:
590 case WM_SYSDEADCHAR:
591 case WM_SYSKEYDOWN:
592 case WM_SYSKEYUP:
593 return 0;
595 case WM_NCCALCSIZE:
596 return 0;
598 case WM_SIZE:
599 if (hWnd == hPerformancePageMemUsageHistoryGraph)
601 GraphCtrl_Resize(&PerformancePageMemUsageHistoryGraph);
602 GraphCtrl_InvalidateCtrl(&PerformancePageMemUsageHistoryGraph);
604 if (hWnd == hPerformancePageCpuUsageHistoryGraph)
606 GraphCtrl_Resize(&PerformancePageCpuUsageHistoryGraph);
607 GraphCtrl_InvalidateCtrl(&PerformancePageCpuUsageHistoryGraph);
609 return 0;
611 case WM_PAINT:
612 hdc = BeginPaint(hWnd, &ps);
613 GetClientRect(hWnd, &rcClient);
614 if (hWnd == hPerformancePageMemUsageHistoryGraph)
615 GraphCtrl_Paint(&PerformancePageMemUsageHistoryGraph, hWnd, hdc);
616 if (hWnd == hPerformancePageCpuUsageHistoryGraph)
617 GraphCtrl_Paint(&PerformancePageCpuUsageHistoryGraph, hWnd, hdc);
618 EndPaint(hWnd, &ps);
619 return 0;
623 * We pass on all non-handled messages
625 return CallWindowProc((WNDPROC)OldGraphCtrlWndProc, hWnd, message, wParam, lParam);