Creating a Modal Dialog before calling DoModal()
-
I need to get a Modal-Dialog's handle (HWND) before I enter the blocking DoModal() call. The thing is the Dialog is only created inside DoModal(). Is there a way to create it in some way and then call DoModal() seperately ?
Why? Maybe you should try a modeless dialog. Check out this web site below. http://www.codeproject.com/dialog/gettingmodeless.asp
-
Why? Maybe you should try a modeless dialog. Check out this web site below. http://www.codeproject.com/dialog/gettingmodeless.asp
-
I need to get a Modal-Dialog's handle (HWND) before I enter the blocking DoModal() call. The thing is the Dialog is only created inside DoModal(). Is there a way to create it in some way and then call DoModal() seperately ?
ohadp wrote: I need to get a Modal-Dialog's handle (HWND) before I enter the blocking DoModal() call Why?? Put your code inside
OnInitDialog()
orOnCreate()
in your dialog.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
ohadp wrote: I need to get a Modal-Dialog's handle (HWND) before I enter the blocking DoModal() call Why?? Put your code inside
OnInitDialog()
orOnCreate()
in your dialog.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
if you r planning to intialize any variable then you can just write some function in the dialog class and call these just by creating the Object of the class and calling the function before calling domodal Thanx TAKE CARE
-
ohadp wrote: I need to get a Modal-Dialog's handle (HWND) before I enter the blocking DoModal() call Why?? Put your code inside
OnInitDialog()
orOnCreate()
in your dialog.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
This specific dialog doesn't need to knwo to do special stuff in it's OnInitDialog(). What I did eventually was send it a pointer to : class CRunner { public: virtual void Run() = 0; }; but I'm still looking for a better way, as in externaly creating the dialog, accessing it's HWND, then entering the Modal-Loop. Does someone have an example of creating the dialog Modeless, and then entering some sort of message-pumping loop that would make it modal ? thanks
-
This specific dialog doesn't need to knwo to do special stuff in it's OnInitDialog(). What I did eventually was send it a pointer to : class CRunner { public: virtual void Run() = 0; }; but I'm still looking for a better way, as in externaly creating the dialog, accessing it's HWND, then entering the Modal-Loop. Does someone have an example of creating the dialog Modeless, and then entering some sort of message-pumping loop that would make it modal ? thanks
I don't have the exact code, but you can do something like this:
CMyDlg dlg = this;
// Create it modeless
dlg.Create(dlg.IDD);// Get your HWND
HWND hWnd = dlg.m_hWnd// Modalize it
EnableWindow(FALSE); // disable parent
dlg.CenterWindow(); // center dlg
dlg.ShowWindow(SW_SHOW); // show dlg
int nResult = dlg.RunModalLoop(MLF_SHOWONIDLE); // wait for it close
dlg.DestroyWindow(); // destroy dlg
EnableWindow(TRUE); // reenable parentYou can also check out MFC's code for DoModal. Regards, Alvaro
Hey! It compiles! Ship it.