首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

MFC线程机制是如何造成上面情况的?

2013-01-02 
MFC线程机制是怎么造成下面情况的???InitInstance()函数里 if (nResponse IDOK){// TODO: 在此放置处理

MFC线程机制是怎么造成下面情况的???


InitInstance()函数里
 if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
    AfxMessageBox("God a girl"); //弹不出来
}

加到OnOk里面的话//对话框程序
AfxGetApp()->m_pMainWnd = NULL;  
再次运行程序 就可以弹出
AfxMessageBox("God a girl"); 

[解决办法]
The Microsoft Foundation Class Library will automatically terminate your thread when the window referred to by m_pMainWnd is closed. If this thread is the primary thread for an application, the application will also be terminated. If this data member is NULL, the main window for the application's CWinApp object will be used to determine when to terminate the thread. m_pMainWnd is a public variable of type CWnd*. 
[解决办法]
首先m_pMainWnd是CWnd类型的
m_pMainWnd如果被关闭了,MFC会自动终结你的线程(包括主线程)

MSDN的意思是,他如何关闭这个机制,微软不会告诉你的。但是是以m_pMainWnd这个参数关闭为标记来启动关闭的

热点排行