Mr. Boy
Mr. Boy

Reputation: 63728

What's the right way to show a non-modal child dialog in MFC (VS2005)?

Rather than have everything in one big dialog, I'm looking at being able to display child dialogs for separate groups of controls. The idea is these are not free-floating child dialogs like floating toolbars, but would be shown with no title-bar, their position locked to the parent dialog... so as you drag the parent dialog any open child is dragged too.

NOTE: these child windows are not inside the parent dialog, they would typically be 'glued' to the edge of it.

In MFC/VC++ 2005, what's the best way to do this? For testing, I currently have a standard MFC Dialog-based app setup with CMainDlg, and I've then created a 'widget dialog' CWidgetDlg. So far I've got a member variable CWidgetDlg MainDlg::m_Widget and a button on CMainDlg with a handler like

CMainDlg::OnDisplayWidgetBtn()
{
 m_Widget.ShowWindow(TRUE);
}

But of course m_Widget hasn't got a HWND setup, and I am trying to remember the right way to do this? For dialog controls I can use DDX but what about child dialogs?

And is this a reasonable approach, or is there a nicer, more automated way?

Upvotes: 3

Views: 2036

Answers (3)

dlb
dlb

Reputation: 983

You could go with a tab dialog. There is some sample code here... http://www.codeproject.com/KB/dialog/embedded_dialog.aspx

Upvotes: 0

Nick Dandoulakis
Nick Dandoulakis

Reputation: 43110

Try:

// IDD_WIDGET is the resource id for your widget dialog
m_Widget.Create(IDD_WIDGET, this);

Don't forget to set style property to child.

Upvotes: 3

bdhar
bdhar

Reputation: 22983

Rather than have everything in one big dialog, I'm looking at being able to display child dialogs for separate groups of controls. The idea is these are not free-floating child dialogs like floating toolbars, but would be shown with no title-bar, their position locked to the parent dialog... so as you drag the parent dialog any open child is dragged too.

I guess you could go for Multi-Document Interface. You could create your own dialogs, add the document template and use them for appropriate functionalities. The child will remain inside one main parent frame and will move along the parent whenever the parent is dragged.

Upvotes: 0

Related Questions