--- /dev/null
+//////////////////////////////////////////////\r
+// Rect.cpp\r
+// Definitions for the CViewRect class\r
+\r
+#include "stdafx.h"\r
+#include "Rect.h"\r
+#include "resource.h"\r
+\r
+// CViewRect definitions\r
+LRESULT CViewRect::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ switch (uMsg)\r
+ {\r
+ case WM_CREATE:\r
+ SetTimer (1, 250, NULL) ;\r
+ break;\r
+ case WM_CLOSE:\r
+ KillTimer(1);\r
+ break;\r
+\r
+ case WM_TIMER: // Display a random rectangle\r
+ {\r
+ int nRed, nGreen, nBlue;\r
+ int xLeft, xRight, yTop, yBottom;\r
+ xLeft = rand () % m_cxClientMax;\r
+ xRight = rand () % m_cxClientMax;\r
+ yTop = rand () % m_cyClientMax;\r
+ yBottom = rand () % m_cyClientMax;\r
+ nRed = rand () & 255;\r
+ nGreen = rand () & 255;\r
+ nBlue = rand () & 255;\r
+\r
+ CClientDC RectDC(this);\r
+ RectDC.CreateSolidBrush (RGB (nRed, nGreen, nBlue));\r
+\r
+ int Left = (xLeft < xRight) ? xLeft : xRight;\r
+ int Top = (yTop < yBottom) ? yTop : yBottom;\r
+ int Right = (xLeft > xRight) ? xLeft : xRight;\r
+ int Bottom = (yTop > yBottom) ? yTop : yBottom;\r
+ RectDC.Rectangle(Left, Top, Right, Bottom);\r
+ }\r
+ break;\r
+\r
+ case WM_SIZE: // If not minimized, save the window size\r
+ if (wParam != SIZE_MINIMIZED)\r
+ {\r
+ m_cxClientMax = LOWORD (lParam) ;\r
+ if (m_cxClientMax < 1) m_cxClientMax = 1;\r
+ m_cyClientMax = HIWORD (lParam) ;\r
+ if (m_cyClientMax < 1) m_cyClientMax = 1;\r
+ }\r
+ break ; // WM_SIZE must be processed by DefMDIChildProc\r
+ }\r
+\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+}\r
+\r
+\r
+\r