[RESOLVED] Ruling out right click
After a bit of research, I decided to ask a question to rule out an option that doesn't look viable. I have seldom used the right mouse button. Now I want to have a menu pop up whenever ANY control is right clicked, or even if the form (no control) is right clicked. This appears to be somewhere between tricky and impossible as 'default' right mouse button behavior. It looks like some controls, perhaps buttons as an example, don't generally deal with right mouse button clicks.
Re: Ruling out right click
VB.net noob here but I have done this in other languages using hook proceedures such as "SetWindowsHookEx". Yet again VB noob here but it works in AutoIt to trap mouse events.
Re: Ruling out right click
Yeah, I'm looking at that route for a different reason. Might suit...might not.
Re: Ruling out right click
Here is something I researched and found. it doesn't seem intuitive as I don't know why they don't have a RightClicked event. Create a listbox(i.e. just serving as an example of a control you might use) on your form/whatever and call it lstResults. Here is some sample code:
vb Code:
Private Sub lstResults_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstResults.MouseUp
If e.Button = Windows.Forms.MouseButtons.Right Then
MsgBox("You right clicked on the ListBox")
End If
End Sub
Re: Ruling out right click
Re: Ruling out right click
the button's mousedown + mouseup events have an e.button property as do all controls i think
Re: Ruling out right click
Yes, I believe that to be the case. As long as I handle the mouse down or up event, I should be sort of ok.
But doggone it, the more I think about it, the less I think that is the right direction to go.
I'm going to close this off and ponder a bit more.
Thanks for the responses.
(I was about to add something else, but a thought occurred to me and I'm now off in a better direction).