C++ AfxBeginThread1
9*9乘法口诀
关键点
实现过程
在
class CMfc01Dlg : public CDialog
{
// Construction
public:
CMfc01Dlg(CWnd* pParent = NULL); // standard constructor
CWinThread *m_mulProc;
// Dialog Data
//{{AFX_DATA(CMfc01Dlg)
UINT mulProc(LPVOID pParam)
{
CMfc01Dlg *pDlg=(CMfc01Dlg*)pParam;
char pszText[128]={0};
char pszFormat[128]={0};
for (int i=1;i<10;i++)
{
memset(pszText,0,128);
for (int j=1;j<i+1;j++)
{
wsprintf(pszFormat,"%d *%d=%-3d",i,j,i*j);
strcat(pszText,pszFormat);
}
pDlg->m_listbox1.AddString(pszText);
}
return 0;
}
void CMfc01Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
m_mulProc=AfxBeginThread(mulProc,this,0,0,0,NULL);
}
void CMfc01Dlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if (mulProc!=NULL)
{
DWORD dwExit=0;
BOOL bRet=GetExitCodeThread(m_mulProc->m_hThread,&dwExit);
if (dwExit==STILL_ACTIVE)
{
m_mulProc->ExitInstance();
delete m_mulProc;
}
}
CDialog::OnClose();
} |
图
备注
相关链接