![]() |
#2
yuccn2013-03-13 12:12
|
点击twopoint对话框上的Button1和Button2分别进入子对话框1和子对话框2;
点击子对话框2上的按钮会启动线程函数xthread;但是却出现了断言错误,不知道为什么?
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
代码如下:
// twopointsDlg.h
CCdialog1 *xxx;
// Cdialog1.h
#define UM_ALARM WM_USER+100
afx_msg void alarm(WPARAM wParam, LPARAM lParam);
// Cdialog1.cpp
ON_MESSAGE(UM_ALARM,alarm)
void CCdialog1::alarm(WPARAM wParam, LPARAM lParam)
{
MessageBox("BMS告警开入1");
}
// Cdialog2.cpp
UINT CCdialog2::xthread(void *param)//线程函数
{
CCdialog2 *dlg=(CCdialog2*)param;
CTwopointsDlg *m_Host = (CTwopointsDlg*)AfxGetMainWnd();//获取主对话框的指针
m_Host->xxx->SendMessage(UM_ALARM,0,0);
return 0;
}
void CCdialog2::OnButton1()
{
// TODO: Add your control notification handler code here
AfxBeginThread(xthread,this);
}