Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Different Child Dialogs Within a Popup Dialog

Status
Not open for further replies.

milner

Programmer
Apr 15, 1999
28
CA
I have a dialog that looks similar to Explorer's layout. It is a tree control on the left with an empty area on the right.

I want to have different dialogs (child dialogs created in resource editor) display depending on what I select in the tree view. For Example, a text box when I select a text file, a couple dialog controls when I select a database, etc. I also want each child dialog to have it's own view class to handle messages from it's client area.

Any Ideas?

Thanks
 
Not sure for a definite solution, but why is that you are having a dialog control to display an explorer interface. How about if you use an SDI application, where you could display the tree control on the view and then create other dialog boxes/controls on the right empty area based on user choice.
Sounds sensible ?

Sriks
 
This part is actually not the main interface to the program. This is a seperate dialog that is displayed when a "Configuration" menu is selected. In the tree control I actually have a list of different objects related to the program. I have customers then, below each customer is a list of regions, then below each region is another object.

The Customer refers to a customer class object; the region to a region class, etc.

If the user selects a customer I want to display a "sub-dialog" to change the options for that customer (ex. name, address, phone, fax). When they click on a region, I want it to display a different "sub-dialog" with different controls and different data.

I need to be able to change the sub-dialog as well as the data that the sub-dialog displays.

Almost exactly like the "Winamp" preferences dialog. (If you happen to use winamp)
 
Not sure if I got what u want, but lets see.
Once u click on the customer/region/etc in the tree control you want to display a "sub-dialog". Well not sure what exactly u mean by a "sub-dialog". Let me assume that its a normal dialog box that is created in this dialog box(the one with the tree control).
Now when an object is created, what you cud do is created this child dialog and pass a set of parameters like this.

// For customer
CChildDialog dlg (name, phone_num, ...)
dlg.DoModal ()
// For region
CChildDialog dlg (regionName, regionAddress, ...)
dlg.DoModal ()

Now all u need to do is add/modify the constructor of the child dialog to suit the parameters that are passed.

Now since a region or the customer dialog will have to display different controls, you need to dynamically create then in you "OnInitdialog" code using the create command.

Hope this helped.
Sriks

 
milner,

There are five steps to using dialogs in the fashion you are requesting.

1) Create each dialog resource to be compatible with it's intended use.

2) Create the dialog window at runtime.

3) Make the dialog window available to the runtime code.

4) Position and size the window within it's parent.

5) Show and Hide the dialogs as desired.

Step (1) Requires setting the dialog properties correctly for using it as a child window:
Style = child
Border = none
All other 'styles' unchecked

Step (2) After the parent window has been created ( For a parent of dialog perhaps in the InitDialog() member ) call the CDialog derived classes Create( ResourceID, ParentWnd) function.

Step (3) You need to have proper lifetime (scope) access to each dialog instance during the operations of the application. For instance each one could be a member variable of the Parent Dialog class.

class CMainDlg : public CDialog{
CSubDlgOne _dlgOne;
CSubDlgTwo _dlgTwo;
... etc
};

These would then be the instances that you use when creating the dialogs

CMainDlg::InitDialog(){
_dlgOne.Create(IDD_SUBDLGONE, this);
_dlgTwo.Create(IDD_SUBDLGTWO, this);
}

Step (4) You need to postion and size the dialog to your needs within the parent window. Perhaps using MoveWindow() or SetWindowPos().

Step (5) In response to the events of interest to your application you will use each dialogs ShowWindow() function to 'show' and 'hide' the dialogs.

Hope this helps
-pete
 
Thanks Palbano, that's exactly what I need.

One other question, I want to make all my subdialog classes to be an extension of another generic subdialog:

class CsubDlgOne : public CsubDlg

I want my generic class (CsubDlg) to have some pure virtual functions (headers) to take care of checking whether the data has been modified, saving it, and any other checking/cleanup I need to do before the next dialog is changed. I want to use virtual functions to make my main dialog code a bit simpler.

I basically want to know if I'm allowed to have:

class CsubDlg : public CDialog

and

class CSubDlg1 : CSubDlg
class CSubDlg2 : CSubDlg, etc

while still being able to have my message handlers in my subdialogs (CSubDlg1, CSubDlg2, etc.) and not in my generic sub dialog (CSubDlg)

If you can make heads or tails of all that,
Thanks,

milner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top