tags:

views:

51

answers:

3

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?

A: 

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.

bdhar
+2  A: 

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.

Nick D
Displays fine but can't extend past parent window. Is there an easy style change?
John
Actually that's a whole other question. I'll raise it as such!
John
@John, yeah, that's another story. On that senario you'll have to create modeless dialogs and write code to reposition them. I don't think there is an easy way because MFC doesn't support that.
Nick D
http://stackoverflow.com/questions/2637628/mfc-gluing-two-windows-dialogs-together is new topic
John
A: 

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

dlb