ARGH
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / MDIFrameDemo / src / MDIChildRect.cpp
1 //////////////////////////////////////////////\r
2 // MDIChildRect.cpp\r
3 //  Definitions for the CViewRect and CMDIChildRect class\r
4 \r
5 #include "stdafx.h"\r
6 #include "MDIChildRect.h"\r
7 #include "resource.h"\r
8 \r
9 \r
10 ////////////////////////\r
11 // CViewRect definitions\r
12 LRESULT CViewRect::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
13 {\r
14         switch (uMsg)\r
15         {\r
16         case WM_CREATE:\r
17                 SetTimer (1, 250, NULL) ;\r
18                 break;\r
19         case WM_CLOSE:\r
20                 KillTimer(1);\r
21                 break;\r
22 \r
23         case WM_TIMER:            // Display a random rectangle\r
24                 {\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
34 \r
35                         CClientDC dcRect(this);\r
36                         dcRect.CreateSolidBrush (RGB (nRed, nGreen, nBlue));\r
37 \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
43                 }\r
44                 break;\r
45 \r
46         case WM_SIZE:             // If not minimized, save the window size\r
47           if (wParam != SIZE_MINIMIZED)\r
48           {\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
53           }\r
54           break ;        // WM_SIZE must be processed by DefMDIChildProc\r
55         }\r
56 \r
57         return WndProcDefault(uMsg, wParam, lParam);\r
58 }\r
59 \r
60 ////////////////////////////\r
61 // CMDIChildRect definitions\r
62 CMDIChildRect::CMDIChildRect()\r
63 {\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
68 }\r
69 \r
70 CMDIChildRect::~CMDIChildRect()\r
71 {\r
72 }\r
73 \r
74 void CMDIChildRect::OnInitialUpdate()\r
75 {\r
76         SetWindowText(_T("Rectangle Window"));\r
77         SetIconLarge(IDI_RECT);\r
78         SetIconSmall(IDI_RECT);\r
79 }\r
80 \r

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