BOOL bend=FALSE;
UINT CThreDlg::ThreadFunction(LPVOID pParam)
{
while(!bend){
Beep(100,100);
Sleep(1000);
}
return 0;
}CWinThread *pThread;
HWND hWnd;BOOL CThreDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
hWnd = GetSafeHwnd();
pThread = AfxBeginThread(ThreadFunction, hWnd);
pThread->m_bAutoDelete = FALSE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}void CThreDlg::OnCancel()
{
// TODO: Add your control notification handler code here
bend=TRUE;//改变变量,线程结束
WaitForSingleObject(pThread->m_hThread,INFINITE);//等待线程结束
delete pThread;//删除线程
}编译不通过:error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'找半天找不出来,郁闷了...
UINT CThreDlg::ThreadFunction(LPVOID pParam)
{
while(!bend){
Beep(100,100);
Sleep(1000);
}
return 0;
}CWinThread *pThread;
HWND hWnd;BOOL CThreDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
hWnd = GetSafeHwnd();
pThread = AfxBeginThread(ThreadFunction, hWnd);
pThread->m_bAutoDelete = FALSE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}void CThreDlg::OnCancel()
{
// TODO: Add your control notification handler code here
bend=TRUE;//改变变量,线程结束
WaitForSingleObject(pThread->m_hThread,INFINITE);//等待线程结束
delete pThread;//删除线程
}编译不通过:error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'找半天找不出来,郁闷了...
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货