--- /dev/null
+///////////////////////////////\r
+// View.cpp\r
+\r
+#include "View.h"\r
+#include "resource.h"\r
+\r
+\r
+// Definitions for the CView class\r
+void CView::OnCreate()\r
+{\r
+ // OnCreate is called automatically during window creation when a\r
+ // WM_CREATE message received.\r
+\r
+ // Tasks such as setting the icon, creating child windows, or anything\r
+ // associated with creating windows are normally performed here.\r
+\r
+ // Set the window's icon\r
+ SetIconSmall(IDW_MAIN);\r
+ SetIconLarge(IDW_MAIN);\r
+\r
+ // Set the window title\r
+ SetWindowText(LoadString(IDW_MAIN));\r
+\r
+ TRACE(_T("OnCreate\n"));\r
+}\r
+\r
+void CView::OnDestroy()\r
+{\r
+ // End the application when the window is destroyed\r
+ ::PostQuitMessage(0);\r
+}\r
+\r
+void CView::OnDraw(CDC* pDC)\r
+{\r
+ // OnPaint is called automatically whenever a part of the\r
+ // window needs to be repainted.\r
+\r
+ // Centre some text in our view window\r
+ CRect rc = GetClientRect();\r
+ CString cs = LoadString(IDW_MAIN);\r
+ pDC->DrawText(cs, cs.GetLength(), rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE);\r
+}\r
+\r
+void CView::OnInitialUpdate()\r
+{\r
+ // OnInitialUpdate is called after the window is created.\r
+ // Tasks which are to be done after the window is created go here.\r
+\r
+ TRACE(_T("OnInitialUpdate\n"));\r
+}\r
+\r
+void CView::OnSize()\r
+{\r
+ // Force the window to be repainted during resizing\r
+ Invalidate();\r
+}\r
+\r
+void CView::PreCreate(CREATESTRUCT& cs)\r
+{\r
+ // This function will be called automatically by Create. It provides an\r
+ // opportunity to set various window parameters prior to window creation.\r
+ // You are not required to set these parameters, any paramters which\r
+ // aren't specified are set to reasonable defaults.\r
+\r
+ // Set some optional parameters for the window\r
+ cs.dwExStyle = WS_EX_CLIENTEDGE; // Extended style\r
+ cs.lpszClass = _T("View Window"); // Window Class\r
+ cs.x = 50; // top x\r
+ cs.y = 50; // top y\r
+ cs.cx = 400; // width\r
+ cs.cy = 300; // height\r
+}\r
+\r
+LRESULT CView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ // This function is our message procedure. We process the messages for\r
+ // the view window here. Unprocessed messages are passed on for\r
+ // default processing.\r
+\r
+ switch(uMsg)\r
+ {\r
+ case WM_DESTROY:\r
+ OnDestroy();\r
+ return 0; // return a value. No default processing\r
+\r
+ case WM_SIZE:\r
+ OnSize();\r
+ break; // and also do default processing for this message\r
+ }\r
+\r
+ // pass unhandled messages on for default processing\r
+ return WndProcDefault(uMsg, wParam, lParam);\r
+}\r