14c63263b30daaf0201ec9ddb17705acbe7d5e2a
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / Simple / src / View.cpp
1 ///////////////////////////////\r
2 // View.cpp\r
3 \r
4 #include "View.h"\r
5 #include "resource.h"\r
6 \r
7 \r
8 // Definitions for the CView class\r
9 void CView::OnCreate()\r
10 {\r
11         // OnCreate is called automatically during window creation when a\r
12         // WM_CREATE message received.\r
13 \r
14         // Tasks such as setting the icon, creating child windows, or anything\r
15         // associated with creating windows are normally performed here.\r
16 \r
17         // Set the window's icon\r
18         SetIconSmall(IDW_MAIN);\r
19         SetIconLarge(IDW_MAIN);\r
20 \r
21         // Set the window title\r
22         SetWindowText(LoadString(IDW_MAIN));\r
23 \r
24         TRACE(_T("OnCreate\n"));\r
25 }\r
26 \r
27 void CView::OnDestroy()\r
28 {\r
29         // End the application when the window is destroyed\r
30         ::PostQuitMessage(0);\r
31 }\r
32 \r
33 void CView::OnDraw(CDC* pDC)\r
34 {\r
35         // OnPaint is called automatically whenever a part of the\r
36         // window needs to be repainted.\r
37 \r
38         // Centre some text in our view window\r
39         CRect rc = GetClientRect();\r
40         CString cs = LoadString(IDW_MAIN);\r
41         pDC->DrawText(cs, cs.GetLength(), rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);\r
42 }\r
43 \r
44 void CView::OnInitialUpdate()\r
45 {\r
46         // OnInitialUpdate is called after the window is created.\r
47         // Tasks which are to be done after the window is created go here.\r
48 \r
49         TRACE(_T("OnInitialUpdate\n"));\r
50 }\r
51 \r
52 void CView::OnSize()\r
53 {\r
54         // Force the window to be repainted during resizing\r
55         Invalidate();\r
56 }\r
57 \r
58 void CView::PreCreate(CREATESTRUCT& cs)\r
59 {\r
60         // This function will be called automatically by Create. It provides an\r
61         // opportunity to set various window parameters prior to window creation.\r
62         // You are not required to set these parameters, any paramters which\r
63         // aren't specified are set to reasonable defaults.\r
64 \r
65         // Set some optional parameters for the window\r
66         cs.dwExStyle = WS_EX_CLIENTEDGE;                // Extended style\r
67         cs.lpszClass = _T("View Window");               // Window Class\r
68         cs.x = 50;                                                              // top x\r
69         cs.y = 50;                                                              // top y\r
70         cs.cx = 400;                                                    // width\r
71         cs.cy = 300;                                                    // height\r
72 }\r
73 \r
74 LRESULT CView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
75 {\r
76         // This function is our message procedure. We process the messages for\r
77         // the view window here.  Unprocessed messages are passed on for\r
78         //  default processing.\r
79 \r
80         switch(uMsg)\r
81         {\r
82         case WM_DESTROY:\r
83                 OnDestroy();\r
84                 return 0;       // return a value. No default processing\r
85 \r
86         case WM_SIZE:\r
87                 OnSize();\r
88                 break;  // and also do default processing for this message\r
89         }\r
90 \r
91         // pass unhandled messages on for default processing\r
92         return WndProcDefault(uMsg, wParam, lParam);\r
93 }\r

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