Solved

Inheritance and message maps/data exchanges

Posted on 2009-06-29
2
297 Views
Last Modified: 2013-12-14
Hello,

I'm writing an MFC app. There are many "add" and "edit" dialogs for various record types, with a lot of redundant repetition - obvious candidates for refactoring so that each inherits from a common base class.

I have concerns about mixing inheritance with MFC's message/command routing. I seemingly cannot put a messagemap or data exchange in my base class.

Must I maintain mappings and data exchanges in my derived classes? It would be convenient to push that up into the base class.

Regards,
Sternocera
0
Comment
Question by:sternocera
2 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 500 total points
ID: 24737444
Hi sternocera,

IMO there shouldn't be a problem using message maps/data exchange with base- and derived dialog classes. This method is even used in MFC, i.e. CFileDialog is derived from CCommonDialog which is derived from CDialog - all of them have their own message map.

You have to take care that in derived dialog classes you call the correct base-class functions. And it maybe that class-wizard doesn't support to add message handlers/variables as used with CDialog derived classes, so maybe you have to add them manually.

Hope that helps,

ZOPPO
0
 

Author Comment

by:sternocera
ID: 24738079
Zoppo,

I see. Thanks for that,

Regards,
Sternocera
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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.

746 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