|
-
April 19th, 1999, 06:22 AM
#1
New Notifications
I think I must have missed something obvious here, but how do you send a notification from a control to the parent window/dialog?
I have written a subclass of CButton, but it needs to send a message to the parent window. Is it possible to set this up in such a way that MFC (and, if possible, ClassWizard) can handle the message in a similar way to how BN_CLICKED is turned into a call to On??Clicked()?
-
April 22nd, 1999, 12:07 PM
#2
Re: New Notifications
I assume that you are using ON_CONTROL_REFLECT in the subclass' message map. Change this to ON_CONTROL_REFLECT_EX and have the handler return a BOOL.
BEGIN_MESSAGE_MAP(CSubClassButton, CButton)
//{{AFX_MSG_MAP(CSubClassButton)
//}}AFX_MSG_MAP
ON_CONTROL_REFLECT_EX(BN_CLICKED, OnSubclassClick)
END_MESSAGE_MAP()
BOOL CSubClassButton::OnSubclassClick()
{
// do useful work
return FALSE; // Let parent window also process the message
}
Add a normal ON_BN_CLICK message to the parent window.
Refer to "TN062: Message Reflection for Windows Controls".
Note that TN062 states that handler must return a TRUE if you want the parent to also process the message, but I found (with VC 6.0) it works the other way around.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|