我用VC2005在一个MFC对话框工程里面,放了一个按钮控件,从CButton继承了一个子类并重载了消息映射    ON_CONTROL_REFLECT(BN_SETFOCUS, &MyButton::OnBnSetfocus)
    ON_WM_SETFOCUS()但是我在运行时发现,点击按钮的时候,只调用了OnSetFocus函数,没有调用OnBnSetfocus()函数。这是为什么?

解决方案 »

  1.   

    不是所有的消息都能够被reflect吧
      

  2.   

    那时因为你没有把Notify前面打勾,打个勾就可以了,应该是 BS_NOTIFY 吧
      

  3.   

    Sent when a button receives the keyboard focus. The button must have the BS_NOTIFY style to send this notification message. The parent window of the button receives the BN_SETFOCUS notification code through the WM_COMMAND message.
    看了一下MSDN,确实是这样的