Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 362
  • Last Modified:

Inheritance and message maps/data exchanges

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
sternocera
Asked:
sternocera
1 Solution
 
ZoppoCommented:
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
 
sternoceraAuthor Commented:
Zoppo,

I see. Thanks for that,

Regards,
Sternocera
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now