views:

132

answers:

3

I have a dialog box based application (MFC - VS 2008). I have a list control on it. I pop up other dialog boxes, but I also want to be able to get back to the parent app dialog. I can get back to the parent app dilaog box, but the problem is that even if I click on it with the mouse it remains hidden behind the "child" windows.

I want it to come to the front.

There is probably something obvious I am doing wrong. What do I need to do to make the parent window come to the front when it has focus? I assume there is some property on the child dlg that should not be there, or something missing

I can post the rc code if that helps.

EDIT:

here is the .rc code for the two dialog boxes. The first is the mainframe window.

The second is launched with the following code:

HistogramWindow *histwind;

histwind = new  HistogramWindow(this);  
histwind->Create(IDD_DIALOG_HISTOGRAM);
histwind->ShowWindow(SW_SHOW);

IDD_DTHISTOGRAMDLG_DIALOG DIALOGEX 0, 0, 320, 200
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW
CAPTION "dtHistogramDlg"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,209,179,50,14,NOT WS_VISIBLE
    PUSHBUTTON      "Cancel",IDCANCEL,263,179,50,14,NOT WS_VISIBLE
    CONTROL         "",IDC_LIST_SYMBOL_SETS,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,60,50
END

IDD_DIALOG_HISTOGRAM DIALOGEX 0, 0, 317, 184
STYLE DS_SETFONT | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW
CAPTION "Histogram"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,205,163,50,14,NOT WS_VISIBLE
    PUSHBUTTON      "Cancel",IDCANCEL,260,163,50,14,NOT WS_VISIBLE
    CONTROL         "",IDC_STATIC,"Static",SS_BLACKFRAME,7,7,20,20
END
+4  A: 

You are probably using a modal dialog box via calling DoModal.
Instead, you need to create a modeless dialog box.

To do this, use CWnd::Create and CWnd::ShowWindow.

Example:

CMyDialog *m_pMyDialog = new CMyDialog(this);
m_pMyDialog->Create(CMyDialog::IDD);
m_pMyDialog->ShowWindow(SW_SHOW);
Brian R. Bondy
I was already doing that. The problem is not that I can't get to the mainframe parent window - I can, it is just that the child windows always are in front - even if the mainframe has focus.
Tim
You could always SetWindowPos for the correct z-order.
Brian R. Bondy
+1  A: 

Try removing EXSTYLE WS_EX_APPWINDOW for the second dialog.

fretje
Ok, I'll try that.
Tim
A: 

A friend of mine suggested the following (and it work)

  • set the style of the 2nd dlg to WS_CHILD
  • histwind->SetParent( NULL );
  • histwind->ModifyStyle( WS_CHILD, 0 );

This works, however thereis a strange behavior when i move the parent window from behind a child. While moving the window is hidden until I release the mouse.

This will work for now.

thanks to all who helped.

Tim