detect context menu

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
481
Programming Experience
3-5
Is there a way to detect if a right click context menu is opened when i hit a left click on a panel? since the menu will disappear by the time i left click the panel, i cant check it.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,255
Location
Sydney, Australia
Programming Experience
10+
I'm not sure that that would be possible. You could handle the Opened event of the ContextMenuStrip and set a flag but you'd have to reset that flag when the menu closes and so you still wouldn't catch it. What are you actually trying to achieve?
 

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
481
Programming Experience
3-5
i am trying to catch a click event on a panel so that if it's context menu is open, the click is canceled.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,255
Location
Sydney, Australia
Programming Experience
10+
I just did a quick test and the Closed event of the ContextMenuStrip is raised before the MouseDown event of the Panel, so I'd say that that's conclusive evidence that you won't be able to do what you want with managed code alone. You may be able to intercept the Windows messages for the two and see if the order of the messages received allows you to detect something in the Panel before the menu is dismissed.
 

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
481
Programming Experience
3-5
I used a global variable and a timer of 200ms to track the context menu status and it worked.
 
Top Bottom