1 //////////////////////////////////////////////
\r
3 // Definitions for the CViewRect and CMDIChildRect class
\r
6 #include "MDIChildRect.h"
\r
7 #include "resource.h"
\r
10 ////////////////////////
\r
11 // CViewRect definitions
\r
12 LRESULT CViewRect::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
17 SetTimer (1, 250, NULL) ;
\r
23 case WM_TIMER: // Display a random rectangle
\r
25 int nRed, nGreen, nBlue;
\r
26 int xLeft, xRight, yTop, yBottom;
\r
27 xLeft = rand () % m_cxClientMax;
\r
28 xRight = rand () % m_cxClientMax;
\r
29 yTop = rand () % m_cyClientMax;
\r
30 yBottom = rand () % m_cyClientMax;
\r
31 nRed = rand () & 255;
\r
32 nGreen = rand () & 255;
\r
33 nBlue = rand () & 255;
\r
35 CClientDC dcRect(this);
\r
36 dcRect.CreateSolidBrush (RGB (nRed, nGreen, nBlue));
\r
38 int Left = (xLeft < xRight) ? xLeft : xRight;
\r
39 int Top = (yTop < yBottom) ? yTop : yBottom;
\r
40 int Right = (xLeft > xRight) ? xLeft : xRight;
\r
41 int Bottom = (yTop > yBottom) ? yTop : yBottom;
\r
42 dcRect.Rectangle(Left, Top, Right, Bottom);
\r
46 case WM_SIZE: // If not minimized, save the window size
\r
47 if (wParam != SIZE_MINIMIZED)
\r
49 m_cxClientMax = LOWORD (lParam) ;
\r
50 if (m_cxClientMax < 1) m_cxClientMax = 1;
\r
51 m_cyClientMax = HIWORD (lParam) ;
\r
52 if (m_cyClientMax < 1) m_cyClientMax = 1;
\r
54 break ; // WM_SIZE must be processed by DefMDIChildProc
\r
57 return WndProcDefault(uMsg, wParam, lParam);
\r
60 ////////////////////////////
\r
61 // CMDIChildRect definitions
\r
62 CMDIChildRect::CMDIChildRect()
\r
64 HINSTANCE hResource = GetApp()->GetResourceHandle();
\r
65 HMENU hChildMenu = LoadMenu(hResource, _T("MdiMenuRect"));
\r
66 SetHandles(hChildMenu, NULL);
\r
67 SetView(m_RectView);
\r
70 CMDIChildRect::~CMDIChildRect()
\r
74 void CMDIChildRect::OnInitialUpdate()
\r
76 SetWindowText(_T("Rectangle Window"));
\r
77 SetIconLarge(IDI_RECT);
\r
78 SetIconSmall(IDI_RECT);
\r