?
Solved

Inheritance and message maps/data exchanges

Posted on 2009-06-29
2
Medium Priority
?
358 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
[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
2 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 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