Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is this possible?

Posted on 2000-03-16
4
Medium Priority
?
172 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 200 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

670 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