本文介绍了CButton封装的按钮按下事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个我认为很容易解决的问题,但这是您可能知道或不知道的事情之一,而我却不知道!

我创建了一个从CButton继承的类,并在构造此新类的过程中传递了指向回调函数的指针,该函数需要在按下按钮时触发.

问题在于我无法在继承的CButton类本身中找到合适的事件使用,即使像BN_CLICKED这样的事件似乎也只能在继承于继承的CButton类的父窗口中工作.

任何帮助深表感谢.谢谢,戴夫.

Hi,

I have a problem that I imagine is fairly easy to solve but is one of those things you probably know or you don''t - and I don''t!

I have created a class inherited from a CButton, and as part of the construction of this new class I pass in a pointer to a callback function which I need to trigger when the button is pressed.

The trouble is that I can''t find an appropriate event to use within the inheritied CButton class itself as even such as BN_CLICKED only seem to work if trapped on the inherited CButton class'' parent window.

Any help massively appreciated. Thanks, Dave.

推荐答案

afx_msg BOOL OnClicked();





BEGIN_MESSAGE_MAP(YourButton, CButton)
    //{{AFX_MSG_MAP(CMtButton)
    ON_CONTROL_REFLECT_EX(BN_CLICKED, OnClicked)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()


这篇关于CButton封装的按钮按下事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 22:45