Solved

Is this possible?

Posted on 2000-03-16
4
156 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 85
Macro to save highlighted rows as a separate file 5 38
iSeries DB2 Query 2 82
List out all word 7 218
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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now