简体   繁体   English

如何处理MFC中的同一按钮上的单击和双击?

[英]how to handle single click and double on same button in mfc?

In my VC++ project I am using a button in dialog. 在我的VC ++项目中,我使用对话框中的按钮。 I already add single click event of a button. 我已经添加了按钮的单击事件。 Now I want to handle double click event of the same button. 现在,我想处理同一按钮的双击事件。 So I add ON_BN_DOUBLECLICKED( IDC_BUTTON1, OnDBClick ) for the same button. 因此,我为同一按钮添加了ON_BN_DOUBLECLICKED(IDC_BUTTON1,OnDBClick)。 But it is not working. 但这是行不通的。 Can anyone explain it? 有人可以解释吗?

Look here: http://www.codeproject.com/Articles/2488/Getting-BN_DOUBLECLICK-to-work-for-buttons 在这里查看: http : //www.codeproject.com/Articles/2488/Getting-BN_DOUBLECLICK-to-work-for-buttons

Article describe how to make it work. 文章描述了如何使其工作。

From the Microsoft documentation: 从Microsoft文档:

This notification code is sent automatically for BS_USERBUTTON, BS_RADIOBUTTON, and BS_OWNERDRAW buttons. 此通知代码是针对BS_USERBUTTON,BS_RADIOBUTTON和BS_OWNERDRAW按钮自动发送的。 Other button types send BN_DOUBLECLICKED only if they have the BS_NOTIFY style. 其他按钮类型仅在具有BS_NOTIFY样式时才发送BN_DOUBLECLICKED。

So set the BS_NOTIFY style on the button. 因此,在按钮上设置BS_NOTIFY样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM