1 //////////////////////////////////////////////
\r
3 // Definitions for the CViewRect class
\r
7 #include "resource.h"
\r
9 // CViewRect definitions
\r
10 LRESULT CViewRect::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
15 SetTimer (1, 250, NULL) ;
\r
21 case WM_TIMER: // Display a random rectangle
\r
23 int nRed, nGreen, nBlue;
\r
24 int xLeft, xRight, yTop, yBottom;
\r
25 xLeft = rand () % m_cxClientMax;
\r
26 xRight = rand () % m_cxClientMax;
\r
27 yTop = rand () % m_cyClientMax;
\r
28 yBottom = rand () % m_cyClientMax;
\r
29 nRed = rand () & 255;
\r
30 nGreen = rand () & 255;
\r
31 nBlue = rand () & 255;
\r
33 CClientDC RectDC(this);
\r
34 RectDC.CreateSolidBrush (RGB (nRed, nGreen, nBlue));
\r
36 int Left = (xLeft < xRight) ? xLeft : xRight;
\r
37 int Top = (yTop < yBottom) ? yTop : yBottom;
\r
38 int Right = (xLeft > xRight) ? xLeft : xRight;
\r
39 int Bottom = (yTop > yBottom) ? yTop : yBottom;
\r
40 RectDC.Rectangle(Left, Top, Right, Bottom);
\r
44 case WM_SIZE: // If not minimized, save the window size
\r
45 if (wParam != SIZE_MINIMIZED)
\r
47 m_cxClientMax = LOWORD (lParam) ;
\r
48 if (m_cxClientMax < 1) m_cxClientMax = 1;
\r
49 m_cyClientMax = HIWORD (lParam) ;
\r
50 if (m_cyClientMax < 1) m_cyClientMax = 1;
\r
52 break ; // WM_SIZE must be processed by DefMDIChildProc
\r
55 return WndProcDefault(uMsg, wParam, lParam);
\r