模态对话框的自动执行

void CCAutoDetectDlg::OnBtSimulate() { // TODO: Add your control notification handler code here //HANDLE handle = AfxBeginThread(AutoThread,this); myDlg.DoModal(); } UINT CCAutoDetectDlg::AutoThread(LPVOID pParam) { int iSecond = 1000; Sleep(1*iSecond); CCAutoDetectDlg *dlg = (CCAutoDetectDlg*)pParam; dlg->myDlg.m_Bt_AutoPush.PostMessage(WM_LBUTTONDOWN); Sleep(2*iSecond); dlg->myDlg.m_Bt_AutoPush.PostMessage(WM_LBUTTONUP); //也可发自定义消息或者添加IDC_BT_AUTOPUSH的映射函数自动运行 dlg->myDlg.PostMessage(WM_MYEIDT,0,0); Sleep(2*iSecond); dlg->myDlg.PostMessage(WM_CLOSE,0,0); return 0; }

在打开模态对话框后,在另一线程中使模态对话框自动执行

因为是模态对话框,DoModal后主线程挂起,所以只能另开线程执行;

 

 

 

 

你可能感兴趣的:(MFC)