Code: Select all
CMyApplication theApp;
DWORD WINAPI ThreadStart (LPVOID dwThreadId) {
::Sleep(300);
//Change the module state
AFX_MODULE_STATE *ModStat;
ModStat = AfxGetStaticModuleState();
ModStat->m_pCurrentWinApp = &theApp;
ModStat->m_hCurrentInstanceHandle = ::GetModuleHandle(NULL);
AFX_MANAGE_STATE(ModStat);
//put the new params for us application
theApp.m_hThread = ::GetCurrentThread();
theApp.m_nThreadID = m_nThreadID;
theApp.m_hInstance = ::GetModuleHandle(NULL);
//We create the windows
CFrameWnd *MainWin = new CFrameWnd();
MainWin->Create(NULL,"Prueba");
MainWin->ShowWindow(SW_SHOW);
theApp.m_pMainWnd = MainWin;
//Run the message loop
theApp.Run();
return TRUE;
}
BOOL CMyApplication::InitInstance()
{
DWORD dwThreadId;
::CreateThread(NULL,0,ThreadStart,0,0,&dwThreadId);
return CWinApp::InitInstance();
}
- Madshi thks for the support and ideas to solve this problem
References:
- The bug: http://support.microsoft.com/default.as ... -US;142243
- MFC Source Code