在线程中执行Create会崩溃, 把它放在外面创建就没问题, 请问这是什么原因?
有没有消息循环先不管, 怎么才能创建成功? static CPlatfromMgr* s_pPlatfromMgr = NULL;AfxBeginThread(InitThread,(void*)NULL);UINT InitCudevThread(LPVOID param)
{
if (!s_pPlatfromMgr)
{
s_pPlatfromMgr = new CPlatfromMgr();
} if (s_pPlatfromMgr)
{
s_pPlatfromMgr->Create(CPlatfromMgr::IDD,NULL);
}
return 0;
}
有没有消息循环先不管, 怎么才能创建成功? static CPlatfromMgr* s_pPlatfromMgr = NULL;AfxBeginThread(InitThread,(void*)NULL);UINT InitCudevThread(LPVOID param)
{
if (!s_pPlatfromMgr)
{
s_pPlatfromMgr = new CPlatfromMgr();
} if (s_pPlatfromMgr)
{
s_pPlatfromMgr->Create(CPlatfromMgr::IDD,NULL);
}
return 0;
}
我也不想这么干的, 无奈啊~
CoInitialize是com里用的吧, 跟这个有什么关系?
UINT __cdecl ThreadProc(LPVOID lParam)
{
if(NULL != pDlg)
{
pDlg->DestroyWindow();
delete pDlg;
pDlg = NULL;
}
pDlg = new CAboutDlg;
pDlg->Create(IDD_ABOUTBOX);
pDlg->ShowWindow(SW_SHOW); MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
也许我代码根本没问题, 我这个对话框上有一个ocx控件, 很有可能是这个ocx控件引起的..