求教,一个有关线程的简单例子
这是一个线程的例子,能够编译和联接,但不能运行.请高手指教一下.
代码如下:
class CUIThread:public CWinThread
{
DECLARE_DYNCREATE(CUIThread)
public:
virtual BOOL InitInstance();
};
class CMainWindow:public CFrameWnd
{
public:
CMainWindow();
protected:
afx_msg void OnLButtonDown(UINT,CPoint);
DECLARE_MESSAGE_MAP()
};
IMPLEMENT_DYNCREATE(CUIThread,CWinThread)
BOOL CUIThread::InitInstance()
{
m_pMainWnd=new CMainWindow;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return true;
}
BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
CMainWindow::CMainWindow()
{
Create(NULL,_T("UI Threadwindow"));
}
void CMainWindow::OnLButtonDown(UINT nFlags,CPoint point)
{
PostMessage(WM_CLOSE,0,0);
}