16,467
社区成员
发帖
与我相关
我的任务
分享
class CMainWindow : public CFrameWnd
{
public:
CMainWindow();
afx_msg void OnLButtonDown(UINT,CPoint);
afx_msg void OnRButtonDown(UINT,CPoint);
CStatic a,b;
DECLARE_MESSAGE_MAP()
};
CMainWindow::CMainWindow ()
{
Create(0,L"");
CRect r(10,10,110,210);
a.Create (L"1",WS_CHILD|WS_VISIBLE|SS_LEFT,r,this,1111);
r.left =10;r.top =220;r.right = 210;r.bottom= 310;
b.Create (L"1",WS_CHILD|WS_VISIBLE|SS_LEFT,r,this,2222);
}
UINT ThreadFucn1(LPVOID pParam)
{
static CStatic * c = (CStatic*)pParam;
for(int i = 0; i<= 1000000; i++)
{
::Sleep (10);
wchar_t n[100];
::ZeroMemory (n,200);
wsprintf(n,L"%d",i);
c->SetWindowTextW (n);
}
return 0;
}
UINT ThreadFucn2(LPVOID pParam)
{
static CStatic * c = (CStatic*)pParam;
for(int i = 0; i<= 1000000; i++)
{
::Sleep (10);
wchar_t n[100];
::ZeroMemory (n,200);
wsprintf(n,L"%d",i);
c->SetWindowTextW (n);
}
return 0;
}
void CMainWindow::OnLButtonDown (UINT,CPoint)
{
CWinThread * a = AfxBeginThread(ThreadFucn1,&a);
CWinThread * b = AfxBeginThread(ThreadFucn2,&b);
}