crypt32: Add stub for CryptMsgEncodeAndSignCTL.
[wine/multimedia.git] / programs / taskmgr / graphctl.c
blobea5129323167a83bcaa73e24e44a74845e4c3167
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 BOOL GraphCtrl_Create(TGraphCtrl* this, HWND hWnd, HWND hParentWnd, UINT nID)
129 GraphCtrl_Init(this);
130 this->m_hParentWnd = hParentWnd;
131 this->m_hWnd = hWnd;
132 GraphCtrl_Resize(this);
133 return 0;
136 void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDecimalPlaces)
138 /* ASSERT(dUpper > dLower); */
139 this->m_dLowerLimit = dLower;
140 this->m_dUpperLimit = dUpper;
141 this->m_nYDecimals = nDecimalPlaces;
142 this->m_dRange = this->m_dUpperLimit - this->m_dLowerLimit;
143 this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
144 /* clear out the existing garbage, re-start with a clean plot */
145 GraphCtrl_InvalidateCtrl(this);
148 #if 0
149 void TGraphCtrl::SetXUnits(const char* string)
151 lstrcpynA(m_strXUnitsString, string, sizeof(m_strXUnitsString));
152 /* clear out the existing garbage, re-start with a clean plot */
153 InvalidateCtrl();
156 void TGraphCtrl::SetYUnits(const char* string)
158 lstrcpynA(m_strYUnitsString, string, sizeof(m_strYUnitsString));
159 /* clear out the existing garbage, re-start with a clean plot */
160 InvalidateCtrl();
162 #endif
164 void GraphCtrl_SetGridColor(TGraphCtrl* this, COLORREF color)
166 this->m_crGridColor = color;
167 /* clear out the existing garbage, re-start with a clean plot */
168 GraphCtrl_InvalidateCtrl(this);
171 void GraphCtrl_SetPlotColor(TGraphCtrl* this, int plot, COLORREF color)
173 this->m_crPlotColor[plot] = color;
174 DeleteObject(this->m_penPlot[plot]);
175 this->m_penPlot[plot] = CreatePen(PS_SOLID, 0, this->m_crPlotColor[plot]);
176 /* clear out the existing garbage, re-start with a clean plot */
177 GraphCtrl_InvalidateCtrl(this);
180 void GraphCtrl_SetBackgroundColor(TGraphCtrl* this, COLORREF color)
182 this->m_crBackColor = color;
183 DeleteObject(this->m_brushBack);
184 this->m_brushBack = CreateSolidBrush(this->m_crBackColor);
185 /* clear out the existing garbage, re-start with a clean plot */
186 GraphCtrl_InvalidateCtrl(this);
189 void GraphCtrl_InvalidateCtrl(TGraphCtrl* this)
191 /* There is a lot of drawing going on here - particularly in terms of */
192 /* drawing the grid. Don't panic, this is all being drawn (only once) */
193 /* to a bitmap. The result is then BitBlt'd to the control whenever needed. */
194 int i, j;
195 int nCharacters;
196 int nTopGridPix, nMidGridPix, nBottomGridPix;
198 HPEN oldPen;
199 HPEN solidPen = CreatePen(PS_SOLID, 0, this->m_crGridColor);
200 /* HFONT axisFont, yUnitFont, oldFont; */
201 /* char strTemp[50]; */
203 /* in case we haven't established the memory dc's */
204 /* CClientDC dc(this); */
205 HDC dc = GetDC(this->m_hParentWnd);
207 /* if we don't have one yet, set up a memory dc for the grid */
208 if (this->m_dcGrid == NULL)
210 this->m_dcGrid = CreateCompatibleDC(dc);
211 this->m_bitmapGrid = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
212 this->m_bitmapOldGrid = SelectObject(this->m_dcGrid, this->m_bitmapGrid);
215 SetBkColor(this->m_dcGrid, this->m_crBackColor);
217 /* fill the grid background */
218 FillRect(this->m_dcGrid, &this->m_rectClient, this->m_brushBack);
220 /* draw the plot rectangle: */
221 /* determine how wide the y axis scaling values are */
222 nCharacters = abs((int)log10(fabs(this->m_dUpperLimit)));
223 nCharacters = max(nCharacters, abs((int)log10(fabs(this->m_dLowerLimit))));
225 /* add the units digit, decimal point and a minus sign, and an extra space */
226 /* as well as the number of decimal places to display */
227 nCharacters = nCharacters + 4 + this->m_nYDecimals;
229 /* adjust the plot rectangle dimensions */
230 /* assume 6 pixels per character (this may need to be adjusted) */
231 /* m_rectPlot.left = m_rectClient.left + 6*(nCharacters); */
232 this->m_rectPlot.left = this->m_rectClient.left;
233 this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
235 /* draw the plot rectangle */
236 oldPen = SelectObject(this->m_dcGrid, solidPen);
237 MoveToEx(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.top, NULL);
238 LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.top);
239 LineTo(this->m_dcGrid, this->m_rectPlot.right+1, this->m_rectPlot.bottom+1);
240 LineTo(this->m_dcGrid, this->m_rectPlot.left, this->m_rectPlot.bottom+1);
241 /* LineTo(m_dcGrid, m_rectPlot.left, m_rectPlot.top); */
242 SelectObject(this->m_dcGrid, oldPen);
243 DeleteObject(solidPen);
245 /* draw the dotted lines,
246 * use SetPixel instead of a dotted pen - this allows for a
247 * finer dotted line and a more "technical" look
249 nMidGridPix = (this->m_rectPlot.top + this->m_rectPlot.bottom)/2;
250 nTopGridPix = nMidGridPix - this->m_nPlotHeight/4;
251 nBottomGridPix = nMidGridPix + this->m_nPlotHeight/4;
253 for (i=this->m_rectPlot.left; i<this->m_rectPlot.right; i+=2)
255 SetPixel(this->m_dcGrid, i, nTopGridPix, this->m_crGridColor);
256 SetPixel(this->m_dcGrid, i, nMidGridPix, this->m_crGridColor);
257 SetPixel(this->m_dcGrid, i, nBottomGridPix, this->m_crGridColor);
260 for (i=this->m_rectPlot.left; i<this->m_rectPlot.right; i+=10)
262 for (j=this->m_rectPlot.top; j<this->m_rectPlot.bottom; j+=2)
264 SetPixel(this->m_dcGrid, i, j, this->m_crGridColor);
265 /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
266 /* SetPixel(m_dcGrid, i, j, m_crGridColor); */
270 #if 0
271 /* create some fonts (horizontal and vertical) */
272 /* use a height of 14 pixels and 300 weight */
273 /* (these may need to be adjusted depending on the display) */
274 axisFont = CreateFont (14, 0, 0, 0, 300,
275 FALSE, FALSE, 0, ANSI_CHARSET,
276 OUT_DEFAULT_PRECIS,
277 CLIP_DEFAULT_PRECIS,
278 DEFAULT_QUALITY,
279 DEFAULT_PITCH|FF_SWISS, "Arial");
280 yUnitFont = CreateFont (14, 0, 900, 0, 300,
281 FALSE, FALSE, 0, ANSI_CHARSET,
282 OUT_DEFAULT_PRECIS,
283 CLIP_DEFAULT_PRECIS,
284 DEFAULT_QUALITY,
285 DEFAULT_PITCH|FF_SWISS, "Arial");
287 /* grab the horizontal font */
288 oldFont = SelectObject(m_dcGrid, axisFont);
290 /* y max */
291 SetTextColor(m_dcGrid, m_crGridColor);
292 SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
293 sprintf(strTemp, "%.*lf", m_nYDecimals, m_dUpperLimit);
294 TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.top, strTemp, _tcslen(strTemp));
296 /* y min */
297 SetTextAlign(m_dcGrid, TA_RIGHT|TA_BASELINE);
298 sprintf(strTemp, "%.*lf", m_nYDecimals, m_dLowerLimit);
299 TextOut(m_dcGrid, m_rectPlot.left-4, m_rectPlot.bottom, strTemp, _tcslen(strTemp));
301 /* x min */
302 SetTextAlign(m_dcGrid, TA_LEFT|TA_TOP);
303 TextOut(m_dcGrid, m_rectPlot.left, m_rectPlot.bottom+4, "0", 1);
305 /* x max */
306 SetTextAlign(m_dcGrid, TA_RIGHT|TA_TOP);
307 sprintf(strTemp, "%d", m_nPlotWidth/m_nShiftPixels);
308 TextOut(m_dcGrid, m_rectPlot.right, m_rectPlot.bottom+4, strTemp, _tcslen(strTemp));
310 /* x units */
311 SetTextAlign(m_dcGrid, TA_CENTER|TA_TOP);
312 TextOut(m_dcGrid, (m_rectPlot.left+m_rectPlot.right)/2,
313 m_rectPlot.bottom+4, m_strXUnitsString, _tcslen(m_strXUnitsString));
315 /* restore the font */
316 SelectObject(m_dcGrid, oldFont);
318 /* y units */
319 oldFont = SelectObject(m_dcGrid, yUnitFont);
320 SetTextAlign(m_dcGrid, TA_CENTER|TA_BASELINE);
321 TextOut(m_dcGrid, (m_rectClient.left+m_rectPlot.left)/2,
322 (m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString, _tcslen(m_strYUnitsString));
323 SelectObject(m_dcGrid, oldFont);
324 #endif
325 /* at this point we are done filling the grid bitmap, */
326 /* no more drawing to this bitmap is needed until the settings are changed */
328 /* if we don't have one yet, set up a memory dc for the plot */
329 if (this->m_dcPlot == NULL)
331 this->m_dcPlot = CreateCompatibleDC(dc);
332 this->m_bitmapPlot = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
333 this->m_bitmapOldPlot = SelectObject(this->m_dcPlot, this->m_bitmapPlot);
336 /* make sure the plot bitmap is cleared */
337 SetBkColor(this->m_dcPlot, this->m_crBackColor);
338 FillRect(this->m_dcPlot, &this->m_rectClient, this->m_brushBack);
340 /* finally, force the plot area to redraw */
341 InvalidateRect(this->m_hParentWnd, &this->m_rectClient, TRUE);
342 ReleaseDC(this->m_hParentWnd, dc);
345 double GraphCtrl_AppendPoint(TGraphCtrl* this,
346 double dNewPoint0, double dNewPoint1,
347 double dNewPoint2, double dNewPoint3)
349 /* append a data point to the plot & return the previous point */
350 double dPrevious;
352 dPrevious = this->m_dCurrentPosition[0];
353 this->m_dCurrentPosition[0] = dNewPoint0;
354 this->m_dCurrentPosition[1] = dNewPoint1;
355 this->m_dCurrentPosition[2] = dNewPoint2;
356 this->m_dCurrentPosition[3] = dNewPoint3;
357 GraphCtrl_DrawPoint(this);
358 /* Invalidate(); */
359 return dPrevious;
362 void GraphCtrl_Paint(TGraphCtrl* this, HWND hWnd, HDC dc)
364 HDC memDC;
365 HBITMAP memBitmap;
366 HBITMAP oldBitmap; /* bitmap originally found in CMemDC */
368 /* RECT rcClient; */
369 /* GetClientRect(hWnd, &rcClient); */
370 /* FillSolidRect(dc, &rcClient, RGB(255, 0, 255)); */
371 /* m_nClientWidth = rcClient.right - rcClient.left; */
372 /* m_nClientHeight = rcClient.bottom - rcClient.top; */
374 /* no real plotting work is performed here, */
375 /* just putting the existing bitmaps on the client */
377 /* to avoid flicker, establish a memory dc, draw to it */
378 /* and then BitBlt it to the client */
379 memDC = CreateCompatibleDC(dc);
380 memBitmap = CreateCompatibleBitmap(dc, this->m_nClientWidth, this->m_nClientHeight);
381 oldBitmap = SelectObject(memDC, memBitmap);
383 if (memDC != NULL)
385 /* first drop the grid on the memory dc */
386 BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcGrid, 0, 0, SRCCOPY);
387 /* now add the plot on top as a "pattern" via SRCPAINT. */
388 /* works well with dark background and a light plot */
389 BitBlt(memDC, 0, 0, this->m_nClientWidth, this->m_nClientHeight, this->m_dcPlot, 0, 0, SRCPAINT); /* SRCPAINT */
390 /* finally send the result to the display */
391 BitBlt(dc, 0, 0, this->m_nClientWidth, this->m_nClientHeight, memDC, 0, 0, SRCCOPY);
393 SelectObject(memDC, oldBitmap);
394 DeleteObject(memBitmap);
395 DeleteDC(memDC);
398 void GraphCtrl_DrawPoint(TGraphCtrl* this)
400 /* this does the work of "scrolling" the plot to the left
401 * and appending a new data point all of the plotting is
402 * directed to the memory based bitmap associated with m_dcPlot
403 * the will subsequently be BitBlt'd to the client in Paint
405 int currX, prevX, currY, prevY;
406 HPEN oldPen;
407 RECT rectCleanUp;
408 int i;
410 if (this->m_dcPlot != NULL)
412 /* shift the plot by BitBlt'ing it to itself
413 * note: the m_dcPlot covers the entire client
414 * but we only shift bitmap that is the size
415 * of the plot rectangle
416 * grab the right side of the plot (excluding m_nShiftPixels on the left)
417 * move this grabbed bitmap to the left by m_nShiftPixels
419 BitBlt(this->m_dcPlot, this->m_rectPlot.left, this->m_rectPlot.top+1,
420 this->m_nPlotWidth, this->m_nPlotHeight, this->m_dcPlot,
421 this->m_rectPlot.left+this->m_nShiftPixels, this->m_rectPlot.top+1,
422 SRCCOPY);
424 /* establish a rectangle over the right side of plot */
425 /* which now needs to be cleaned up proir to adding the new point */
426 rectCleanUp = this->m_rectPlot;
427 rectCleanUp.left = rectCleanUp.right - this->m_nShiftPixels;
429 /* fill the cleanup area with the background */
430 FillRect(this->m_dcPlot, &rectCleanUp, this->m_brushBack);
432 /* draw the next line segment */
433 for (i = 0; i < MAX_PLOTS; i++)
435 /* grab the plotting pen */
436 oldPen = SelectObject(this->m_dcPlot, this->m_penPlot[i]);
438 /* move to the previous point */
439 prevX = this->m_rectPlot.right-this->m_nPlotShiftPixels;
440 prevY = this->m_rectPlot.bottom -
441 (long)((this->m_dPreviousPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor);
442 MoveToEx(this->m_dcPlot, prevX, prevY, NULL);
444 /* draw to the current point */
445 currX = this->m_rectPlot.right-this->m_nHalfShiftPixels;
446 currY = this->m_rectPlot.bottom -
447 (long)((this->m_dCurrentPosition[i] - this->m_dLowerLimit) * this->m_dVerticalFactor);
448 LineTo(this->m_dcPlot, currX, currY);
450 /* Restore the pen */
451 SelectObject(this->m_dcPlot, oldPen);
453 /* if the data leaks over the upper or lower plot boundaries
454 * fill the upper and lower leakage with the background
455 * this will facilitate clipping on an as needed basis
456 * as opposed to always calling IntersectClipRect
458 if ((prevY <= this->m_rectPlot.top) || (currY <= this->m_rectPlot.top))
460 RECT rc;
461 rc.bottom = this->m_rectPlot.top+1;
462 rc.left = prevX;
463 rc.right = currX+1;
464 rc.top = this->m_rectClient.top;
465 FillRect(this->m_dcPlot, &rc, this->m_brushBack);
467 if ((prevY >= this->m_rectPlot.bottom) || (currY >= this->m_rectPlot.bottom))
469 RECT rc;
470 rc.bottom = this->m_rectClient.bottom+1;
471 rc.left = prevX;
472 rc.right = currX+1;
473 rc.top = this->m_rectPlot.bottom+1;
474 /* RECT rc(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1); */
475 FillRect(this->m_dcPlot, &rc, this->m_brushBack);
478 /* store the current point for connection to the next point */
479 this->m_dPreviousPosition[i] = this->m_dCurrentPosition[i];
484 void GraphCtrl_Resize(TGraphCtrl* this)
486 /* NOTE: Resize automatically gets called during the setup of the control */
487 GetClientRect(this->m_hWnd, &this->m_rectClient);
489 /* set some member variables to avoid multiple function calls */
490 this->m_nClientHeight = this->m_rectClient.bottom - this->m_rectClient.top;/* m_rectClient.Height(); */
491 this->m_nClientWidth = this->m_rectClient.right - this->m_rectClient.left;/* m_rectClient.Width(); */
493 /* the "left" coordinate and "width" will be modified in */
494 /* InvalidateCtrl to be based on the width of the y axis scaling */
495 #if 0
496 this->m_rectPlot.left = 20;
497 this->m_rectPlot.top = 10;
498 this->m_rectPlot.right = this->m_rectClient.right-10;
499 this->m_rectPlot.bottom = this->m_rectClient.bottom-25;
500 #else
501 this->m_rectPlot.left = 0;
502 this->m_rectPlot.top = -1;
503 this->m_rectPlot.right = this->m_rectClient.right-0;
504 this->m_rectPlot.bottom = this->m_rectClient.bottom-0;
505 #endif
507 /* set some member variables to avoid multiple function calls */
508 this->m_nPlotHeight = this->m_rectPlot.bottom - this->m_rectPlot.top;/* m_rectPlot.Height(); */
509 this->m_nPlotWidth = this->m_rectPlot.right - this->m_rectPlot.left;/* m_rectPlot.Width(); */
511 /* set the scaling factor for now, this can be adjusted */
512 /* in the SetRange functions */
513 this->m_dVerticalFactor = (double)this->m_nPlotHeight / this->m_dRange;
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);