14b8102fcf4e6298e16877dd8aa0c41bef09f1bd
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / DockTabbedMDI / src / Rect.cpp
1 //////////////////////////////////////////////\r
2 // Rect.cpp\r
3 //  Definitions for the CViewRect class\r
4 \r
5 #include "stdafx.h"\r
6 #include "Rect.h"\r
7 #include "resource.h"\r
8 \r
9 // CViewRect definitions\r
10 LRESULT CViewRect::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
11 {\r
12         switch (uMsg)\r
13         {\r
14         case WM_CREATE:\r
15                 SetTimer (1, 250, NULL) ;\r
16                 break;\r
17         case WM_CLOSE:\r
18                 KillTimer(1);\r
19                 break;\r
20 \r
21         case WM_TIMER:            // Display a random rectangle\r
22                 {\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
32 \r
33                         CClientDC RectDC(this);\r
34                         RectDC.CreateSolidBrush (RGB (nRed, nGreen, nBlue));\r
35 \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
41                 }\r
42                 break;\r
43 \r
44         case WM_SIZE:             // If not minimized, save the window size\r
45           if (wParam != SIZE_MINIMIZED)\r
46           {\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
51           }\r
52           break ;        // WM_SIZE must be processed by DefMDIChildProc\r
53         }\r
54 \r
55         return WndProcDefault(uMsg, wParam, lParam);\r
56 }\r
57 \r
58 \r
59 \r

UCC git Repository :: git.ucc.asn.au