Solved

Is this possible?

Posted on 2000-03-16
4
159 Views
Last Modified: 2013-11-20
I have a dialog box (CDialog1) that has a few buttons and a list control.  Now I have another Dialog Box (CDialog2) that has the same items plus one more list control on it.  Is it possible to derive Dialog2 from Dialog2??  Do I have to name the controls the same?  The two dialog boxes do the same thing except CDialog2 has one more control, I am trying to avoid writting the same code for both dialog boxes.  Thanks.
0
Comment
Question by:meetze
4 Comments
 
LVL 1

Expert Comment

by:TKII
ID: 2624568
Have a look at control subclassing in the online-help. Perhaps you can drive the class for the second dialog from the class for dialog1 or create a base class for both dialogs.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2625373
The solutoion for meetze has nothing to do with control subclassing. meetze's needs can be addressed with C++ subclassing.

..B ekiM
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 2626633
Yes .. you can do this.  As long as the control id's are the same it is pretty easy .. just add the extra code for your extra controls.

Unfortunately it is not easy to have your disloag reousrces inherit from each other .. they will have to remain copies.  But inheriting one CDialog-derived class from another (instead of directly from CDialog) works well .. I use it all the time.
0
 
LVL 1

Expert Comment

by:kjetilr
ID: 2627030

The solution to your problem seem to be:

class CDialog1 : public CDialog
{
   public:
       CDialog1();
   private:
       CControl1   *m_pCont1;
};

class CDialog2 : public CDialog1
{
   public:
      CDialog2();
   private:
      CControl   *m_pCont2;
};


Here the second object is derived from the first.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 80
Tab names are off by one 5 54
iSeries DB2 Query 2 97
Shell script to login to remote m/c and execute commands 10 78
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question