Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / samples / Threads / src / TestWnd.cpp
1 //////////////////////////////////////////////\r
2 // TestWnd.cpp\r
3 //  Definitions for the CTestWindow class\r
4 \r
5 #include "stdafx.h"\r
6 #include "TestWnd.h"\r
7 #include "ThreadApp.h"\r
8 \r
9 \r
10 CTestWindow::CTestWindow(int nWindow) : m_nWindow(nWindow)\r
11 {\r
12 }\r
13 \r
14 HWND CTestWindow::Create(CWnd* pParent)\r
15 {\r
16         UNREFERENCED_PARAMETER(pParent);\r
17 \r
18         CString Title;\r
19         Title.Format( _T("Test Window %d"), m_nWindow );\r
20         return CreateEx(0L, NULL, Title, WS_OVERLAPPEDWINDOW | WS_VISIBLE,\r
21                 70 + 20*m_nWindow, 120 + 20*m_nWindow, 300, 200, NULL, NULL);\r
22 }\r
23 \r
24 BOOL CTestWindow::InitInstance()\r
25 {\r
26         // This function runs when the thread starts\r
27 \r
28         // Create a test window for this thread\r
29         Create();\r
30 \r
31         return TRUE;    // return TRUE to run the message loop\r
32 }\r
33 \r
34 void CTestWindow::OnInitialUpdate()\r
35 {\r
36         // Get a reference to the CMainWnd object\r
37         CMainWindow& MainWnd = ((CThreadApp*)GetApp())->GetMainWnd();\r
38 \r
39         // Post a message to MainWnd when the window is created. The MainWnd window\r
40         //  is in a different thread, so PostMessage is preferred over SendMessage.\r
41         //  SendMessage would wait for the MainWnd thread to respond.\r
42         ::PostMessage(MainWnd.GetHwnd(), WM_WINDOWCREATED, 0, 0);\r
43 }\r
44 \r
45 LRESULT CTestWindow::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
46 {\r
47         switch (uMsg)\r
48         {\r
49         case WM_CLOSE:\r
50                 {\r
51                         CString str;\r
52                         str.Format( _T("Closing test Window %d\n"), m_nWindow );\r
53                         TRACE(str);\r
54                 }\r
55                 break;\r
56 \r
57         case WM_DESTROY:\r
58                 // Terminate the thread.\r
59                 ::PostQuitMessage(0);\r
60                 break;\r
61 \r
62         }\r
63 \r
64         return WndProcDefault(uMsg, wParam, lParam);\r
65 }\r
66 \r

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