views:

154

answers:

2

Sorry for stupid questions, I'm doing everything as described in this tutorial: http://www.functionx.com/visualc/howto/calldlgfromdlg.htm

I create the dialog window and try to call another dialog in response to a button press using the following code:

CSecondDlg Dlg;
Dlg.DoModal();

Modal window appears but isn't active, and main window isn't active too and everything lags. Here is a screenshot:

Two dialogs interfering with each other

And here are the definitions for my dialogs:

IDD_DIARY_TEST_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "diary_test"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "Second",IDC_SECOND_BTN,209,179,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,263,179,50,14
    CTEXT           "TODO: Place dialog controls here.",IDC_STATIC,10,96,300,8
END

IDD_SECOND_DLG DIALOGEX 0, 0, 195, 127
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_DISABLED | WS_CAPTION
CAPTION "Second"
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
    LTEXT           "TODO: layout property page",IDC_STATIC,53,59,90,8
    PUSHBUTTON      "Button1",IDC_BUTTON1,61,93,50,14
END
+3  A: 

You dont show your source code but it's probable that your second dialog box is defined as a child window instead of popup. Just verify in the resource editor.

patriiice
yes it was defined as a child but after change to popup problem remains the same
Sergey
@isergeymd: find the dialog definition in the RC file and paste that into your question. Otherwise, we're all just guessing...
Shog9
+4  A: 

Let's just compare the styles of the two dialogs:

STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_DISABLED | WS_CAPTION

I've indicated the differences in bold, and the reason for your problems should now be obvious: your second dialog is disabled (WS_DISABLED), thus preventing it from being activated! Another difference, the missing DS_MODALFRAME style, will cause it to appear slightly abnormal (but shouldn't greatly affect the behavior); the final difference (WS_SYSMENU) merely prevents a system menu (and left icon, right close button) from being displayed.

The other oddity illustrated in your screenshot, the second dialog displayed mixed into the controls on the first, is probably due to your initial use of WS_CHILD as patriiice surmised...

Given this and the other code you posted, I suspect you originally created this as a property page. Property pages, while similar to normal dialog templates, are intended to be displayed as child windows; normal modal dialogs are not.

Shog9
Thanks a lot!!!
Sergey