Re: Can i use a popup modal window whose parent window is not visualable?
See below.
"Seetharam" <smisro@gmail.com> wrote in message
news:b1b5671b-f0db-4a9d-8579-b22d16c260de@d25g2000prn.googlegroups.com...
Show us some code.
I just tried this *test* in a sample MFC MDI app. It works OK.
void CtestAppApp::OnAppAbout()
{
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
CWnd* pFrame = pMainFrame->GetActiveFrame();
pFrame->ShowWindow(SW_HIDE);
CAboutDlg dlg(pFrame);
dlg.DoModal();
}
-Seetharam
The detail is that i also write a IE addin which provides some interfaces
invoked by the Web application.
And the IE addin needs the sdi application be started so that the IE addin
can do some commucations with the sdi application.
So i create a event by calling CreateEvent function in the interface of the
IE addin,
then i call CreateProcess to start the sdi application,
after calling the createprocess function i call WaitForSingleObject to wait
the hCheckCompleteEvent is signaled. then i can do some things .see below.
BSTR CAddin::setData(LPCTSTR astrParam)
{
HANDLE hCheckCompleteEvent =
CreateEvent(NULL,FALSE,FALSE,_T("26E440F6-0535-4e36-BC77-8482940535E4"));
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
si.wShowWindow = SW_HIDE;
ZeroMemory( &pi, sizeof(pi) );
if(CreateProcess(_T("c:\\sdi.exe"),NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi))
{
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
DWORD waitRt = WaitForSingleObject(hCheckCompleteEvent ,10000);
if (waitRt==WAIT_OBJECT_0)
{
//do somethings.
}
}
While the application is starting. i start another thread (here we call it
WorkThread) to do somethings. some codes like below.
UINT WorkThread(LPVOID lParam)
{
CMainFrame *pFrame = (CMainFrame*)lParam;
//do somethings
HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE,
_T("CAE80711-F161-4fd7-87A9-3CB354A87A96"));
LRESULT lRet =
pFrame->SendMessage(WM_SHOW_MODAL_DIALOG,(WPARAM)hEvent );
WaitForSingleObject(hEvent, INFINITE);//wait for the dialog is showed
CloseHandle(hEvent);
HANDLE hCheckCompleteEvent =
CreateEvent(NULL,FALSE,FALSE,_T("26E440F6-0535-4e36-BC77-8482940535E4"));
if (hCheckCompleteEvent !=NULL)
{
SetEvent(hCheckCompleteEvent );//set the hCheckCompleteEvent be
signaled so that the addin can be waken.
CloseHandle(hCheckCompleteEvent );
}
}
//call this function when the application start.
void CMainFrame::OnStartup(WPARAM wParam, LPARAM lParam)
{
//do somethings...
AfxBeginThread(&WorkThread, this);
// do other things.
}
LRESULT CMainFrame::OnShowModalDialog(WPARAM wParam, LPARAM lParam)
{
//do somethings...
CModalDialog dlg(AfxGetMainWnd());
dlg.DoModal();//The problem is here. the dialog is visualable ,but i can
do nothing with it, it seems die there ( there is't any long computation is
doing in the CModalDialog).
HANDLE hEvent = (HANDLE)wParam;
if(hEvent )
SetEvent(hEvent);//make the event signaled.
return dlg.state;
}
The problem happened when i PostMessage to the main gui thread to show the
popup modal dialog(the main gui window is created and hided). the popup
modal dialog is visualable ,but i can do nothing with it.
i don't know why?
Thanks.
Best regards.