Solved

Is this possible?

Posted on 2000-03-16
4
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

630 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