Jump to content
  • Advertisement
Sign in to follow this  
Aramoug

How can you differentiate between Click and RightClick events? (VB.NET)

This topic is 4855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in vb.net when you click or right click, they both trigger the .click event of a control, but how can I tell which one it was, left click or right click? or is there a different event for .rightclick? also, is there a way to code something to trigger an event without it actually occurring? for example, context menus only appear when you right click, but I want to be able to show a context menu without a person actually having to right click, is there a way to do that? thanks

Share this post


Link to post
Share on other sites
Advertisement
For the first question, you might want to handle the mouseup event instead of the click event. As for the second one, I don't have a clue.

Share this post


Link to post
Share on other sites
MouseEventArgs.Button doesnt exist for click? thats kind of stupid....=
I'll try the MouseUp event, but does anybody know how I can manually trigger an event for the 2nd question?

Share this post


Link to post
Share on other sites
If you have your System.Windows.Forms.ContextMenu instance, call the Show-function.

Other than that, you can simply create your contextmenu and add menu items as in a default menu.

Share this post


Link to post
Share on other sites
I hate VB, but I use VC++.net and have a VB book, so if no one else does then I will take the time to look up the answer tomorrow after I get some sleep. For now here are some basic answers.

1) yes, try looking it up in a tutorial or the MSDN KNowledge base, here is there home website http://msdn.microsoft.com/default.aspx

2) yes, in C++ it is recommended to add a message to the system. Lets take a keystroke or mouse click for example, as I understand it how it works behind the scenes is Windows keeps checking the status of everything. So if you tell it you want to be notified when a key is press then it sends you a message when it happens. The same type of thing happens for menus. If Windows registers a mouse click in the specified area of the menu then it sends you a message. There is no reason you can't just send yourself a message to trigger your other code.

I know this has its limits in usefulness but I didn't see anyone else with the answer and right now I am too tired to actually look it up. So, is it good enough to know that both questions are answered as yes and I will try to take the time to look them up on my day off tomorrow.

Share this post


Link to post
Share on other sites
I'm sorry, I am just gonna say the others had it right and I will stick to C++. I really hate VB. I found Window's system messages but in VB you can't add custom ones. I did find an interesting way to send messages between programs and computers. I found a OnClick event for forms but it doesn't get sent with middle or right button clicks, only left...

So, I apologize for opening my big mouth and I promise to stick to C++ from now on. Good luck.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endurion
If you have your System.Windows.Forms.ContextMenu instance, call the Show-function.

Other than that, you can simply create your contextmenu and add menu items as in a default menu.


hopefully you can set the .location of the context menu as well to make sure that it shows up on the control of my choice? i havent tried it yet, but I'm assuming there is



StubornAH: I appreciate you trying to look it up, but I search MSDN for quite some time before posting and I could not find anything about how to differentiate between left and right clicks either. Thanks for trying though, I still give you a very helpful rating =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!