Right click on the button

I see that there are BN_CLICKED and BN_DBLCLK notifications for button controls. but how would I catch a right-click message for any button control?

+4
source share
6 answers
+2
source

BN_CLICKED is a notification sent to the button’s parent window by the button itself. To intercept WM_RBUTTONDOWN messages, etc., you need to subclass the button, since these are messages sent from Windows to the button window. See Section “Subclassing Podcasts” in Safe Subclass in Win32

+1
source

Pen WM_CONTEXTMENU . The advantage of this in handling right-click messages is that your users will be able to use keyboard equivalents to right-click.

+1
source

NM_RCLICK is dispatched, so see Windows messages.

you can check when returning BN_CLICKED to see that NM_RCLICK or even WM_RBUTTONDOWN

0
source

Not quite the answer, but I think you can catch the context menu on the button. (I do not know the events from my head). If you can catch the context menu, click on the button, then it will be the same as the right click.

BUTTON down is not a good way. A click will only be caught when the user makes the button up. Try to press the button and, before you take your finger away from the button, disconnect the mouse from it. At the same time, there is no upward recording for this button, as well as a click.

Again, I know this is not the answer, but that might be the key. I’m a pocket guy, so most often I don’t have a “right mouse button”.

0
source

This is an old question, but I still have not satisfactorily answered, as far as I know. I ran into the same problem, found that the accepted answer simply didn't work - the messages mentioned above are intercepted before I can pick them up; I just could not use WM_RBUTTONDOWN etc.

Therefore, people who come to this question really need to know about this solution , which includes subclassing the button by processing the message (s) of the right mouse button in a subclass, using them to send the NM_RCLICK message back to the parent window.

0
source

All Articles