请问在线程中如何使用MFC类创建对话框?
我的做法如下:
1.CreateThread(NULL,0,monitor_get_event_control,&m_hWnd,NULL,&ThreadId);
2.DWORD WINAPI monitor_get_event_control(void* param)
{
CTestMsgDlgDlg *Dlg = (CTestMsgDlgDlg*)param;
Dlg->DisplayIncomingMsgDlg();
return 0;
}
3.void CTestMsgDlgDlg::DisplayIncomingMsgDlg()
{
pMsgDlg=new CIncomingMsgDlg(this); CIncomingMsgDlg& MsgDlg=*pMsgDlg;
FromName = strdup("From:lgg");
MsgDlg.Create(IDD_INCOMINGMSG_DIALOG);
MsgDlg.ShowWindow(SW_SHOW);
MsgDlg.UpdateWindow();
}但是这样做,不能创建对话框,请问如何修改呢?
我的做法如下:
1.CreateThread(NULL,0,monitor_get_event_control,&m_hWnd,NULL,&ThreadId);
2.DWORD WINAPI monitor_get_event_control(void* param)
{
CTestMsgDlgDlg *Dlg = (CTestMsgDlgDlg*)param;
Dlg->DisplayIncomingMsgDlg();
return 0;
}
3.void CTestMsgDlgDlg::DisplayIncomingMsgDlg()
{
pMsgDlg=new CIncomingMsgDlg(this); CIncomingMsgDlg& MsgDlg=*pMsgDlg;
FromName = strdup("From:lgg");
MsgDlg.Create(IDD_INCOMINGMSG_DIALOG);
MsgDlg.ShowWindow(SW_SHOW);
MsgDlg.UpdateWindow();
}但是这样做,不能创建对话框,请问如何修改呢?
{
CAboutDlg Dlg;
Dlg.DoModal();
return 1;
}
void CMyDlg::OnButton2()
{
// TODO: Add your control notification handler code here
AfxBeginThread(threadFunc,NULL); //创建线程
}