1 //////////////////////////////////////////////
\r
3 // Definitions for the CTestWindow class
\r
7 #include "ThreadApp.h"
\r
10 CTestWindow::CTestWindow(int nWindow) : m_nWindow(nWindow)
\r
14 HWND CTestWindow::Create(CWnd* pParent)
\r
16 UNREFERENCED_PARAMETER(pParent);
\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
24 BOOL CTestWindow::InitInstance()
\r
26 // This function runs when the thread starts
\r
28 // Create a test window for this thread
\r
31 return TRUE; // return TRUE to run the message loop
\r
34 void CTestWindow::OnInitialUpdate()
\r
36 // Get a reference to the CMainWnd object
\r
37 CMainWindow& MainWnd = ((CThreadApp*)GetApp())->GetMainWnd();
\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
45 LRESULT CTestWindow::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
52 str.Format( _T("Closing test Window %d\n"), m_nWindow );
\r
58 // Terminate the thread.
\r
59 ::PostQuitMessage(0);
\r
64 return WndProcDefault(uMsg, wParam, lParam);
\r