Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MessageMaps on derived classes

Status
Not open for further replies.

MinnisotaFreezing

Programmer
Jun 21, 2001
120
KR
Hey all,

I have a CDialog with a ListCtrl and 3 buttons, but I don't use the buttons, they are not visible. I then derive a new class, UserDialog, from that dialog and enable the buttons. Obviously, I want to do OnButton1. I can easily do this in my parent class using message maps, but the thing is, my derived class does not have that infrastructure. I can add the message mapping to the parent class as virtual, then override the functions in my derived class, but that seems wastfull. Why add the functions to the parent class when I only want to use them in the derived class.

Does this make sense? I want to add message mapping to only the derived class, but do not know how becuase usually the message mapping functions are in place already. I tried just copying this part

BEGIN_MESSAGE_MAP(AccRecReport, CDialog)
//{{AFX_MSG_MAP(AccRecReport)
ON_BN_CLICKED(IDC_FILTER, OnInitDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

but that obviosly was not going to work.

Any ideas or tips would be great.

CJB
 
I think your messege map in the cpp file is right.
BEGIN_MESSAGE_MAP(AccRecReport, CDialog)
//{{AFX_MSG_MAP(AccRecReport)
ON_BN_CLICKED(IDC_FILTER, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


You should have AFX_MSG block in your .h file as below:
//{{AFX_MSG(AccRecReport)
....

//}}AFX_MSG

add the statement:
afx_msg void OnButton1();
inside the block.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top