Problem with Dialog Bar Message Map
Posted on 1998-06-03
I have developed my own sticky button class (CColourButton) derived from
CButton. When the button is clicked on with the mouse it pushes in and stays
pushed in. It is also repainted in a certain colour. When the button is
clicked on again it pops back out and is repainted in the standard button
The class works great when I subclass the CColourButton class to button controls
in a dialog application.
Problems occur though when I subclass the CColourButton class to button controls
in a dialog bar (CDialogBar). The dialog bar is attached to the frame of an
SDI application. Each time the mouse is clicked on a button, the CColourButton
class receives two BN_CLICKED notifications.
The CColurButton class is described below:
I am using message reflection so that my button class can handle the
BN_CLICKED notification message. It is from within the BN_CLICKED
notification handler that I determine whether to keep the button pushed in
or to pop it out.
Message reflection has been set up by adding the ON_CONTROL_REFLECT_EX macro
to the CColourButton message map as follows:
ON_CONTROL_REFLECT_EX is used instead of ON_CONTROL_REFLECT because I want
the owner of the button control to be able to process BN_CLICKED messages as
The OnClicked() member function is as follows:
// TODO: Add your control notification handler code here
// Does some processing....
return FALSE; // Returning false ensures that the parent also gets
to see the
// BN_CLICKED message
Can someone please explain why I am receiving two BN_CLICKED messages when
subclassing to a button control in a dialog bar?
I believe there may be some problem with the dialog bar message map which is causing two BN_CLICKED messages to be posted each time the button is clicked.