tags:

views:

157

answers:

5

I see there are BN_CLICKED and BN_DBLCLK notification messages for a button control. but how would i catch a right click message for any button control?

+1  A: 

You can use WM_RBUTTONDOWN, WM_RBUTTONUP, and WM_RBUTTONDBLCLK.

Brian R. Bondy
would there be need to subclass the button control?
Dave18
A: 

NM_RCLICK is sent so look closer at the windows messages.

you can check on reciving BN_CLICKED to see if NM_RCLICK or even WM_RBUTTONDOWN

Reallyethical
A: 

BN_CLICKED is a notification message sent to the parent window of the button by the button itself. To intercept the WM_RBUTTONDOWN, etc messages you need to subclass the button since those are messages sent from Windows itself to the button window. See the section named "Instance Subclassing" in Safe Subclassing in Win32

Murray
A: 

Not really an answer, but I think you might be able to catch the context menu on the button. (don't know the event off the top of my head). If you can catch the context menu press on the button, then it's the same as the right click.

the BUTTON down is not a good path. The click is only caught when the user does a button up. Try pressing a button and before you take your finger off the button, move your mouse off of it.. the up stroke isn't recorded for that button, nor is the click.

Again I know this isn't an answer, but it might be a clue. I'm a handheld guy, so most often I don't have a "right mouse button".

baash05
A: 

Handle WM_CONTEXTMENU. The advantage of this over handling right-button mouse messages is that your users will be able to use the keyboard equivalents to right-clicking.

Michael Dunn