DoModal() not bringing up dlg box as modal
I have a window with the following properties set int he .rc file:
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
It has an associated class (derived from CDialog) and when I instantiate it, then call that object's DoModal() on it it is not really modal - I can click on the "parent" window.
CMyDlg dlg;
int result = dlg.DoModal();
The "parent" window is a dlg box but treated as a main window. its properties are:
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "My Main App"
MENU IDR_MENU_MAIN
Other dlg boxes I call from the main window with DoModal I WANT to leave as not modal. But this other one I would like to have modal.
I am a bit confused about what is going on. Can someone explain how to get this "child" dlg box to be modal (while allowing other "children" not to be modal?
Additional information:
The GUI for this app is not the main thread of the app. It is a command line app that starts another thread and loads a DLL which contains the GUI in it. I am not sure if this has any bearing on the issue.
Main dlg window == A This new dlg box window I want to behave as modal == B A different dlg box == C
Within A : calling B.DoModal is not modal, but I would like it to be Within A : calling C.DoModal is not modal, and I want to keep it that way
Within C, if i call D.DoModal it is modal and I want to keep it that way (so the app does show modal functionality)
More scary information
From A: calling the standard file open or save as dlg boxes result in NON MODAL dlg boxes.
CFileDialog dlg(TRUE);
dlg.DoModal();
This is not desirable either.
These two questions seem to have some good possibilitie开发者_运维技巧s for one of the issues, but they do NOT address how to make sure the standard file open/save dlgs that get called are modal...
Convert a modeless dialog to modal at runtime How do I create Modal dialog in worker thread(Non-UI thread)?
I don't see that you're specifying a parent window for your modal dialogs.
Perhaps that's what's lacking.
If you are loading the dialog box from the .rc file, specify the resource id while creating the dialog object.
CMyDlg dlg(IDR_DLG1);
int result = dlg.DoModal();
精彩评论