all groups > dotnet windows forms > june 2006 >
You're in the

dotnet windows forms

group:

Disable a context menu in sys tray??


Disable a context menu in sys tray?? Amil Hanish
6/29/2006 7:46:55 PM
dotnet windows forms:
I have a sys tray icon with a context menu set. I only want to allow a
right-click on the icon if the control key is pressed with the right-click
is done.

I can't figure out how to do this? I've tried overriding a lot of the
events and attempted at things like Visible and Enabled, but I can't seem to
just not allow (i.e. ignore) a right-click on the sys tray icon.

I can override events and check the right click event (and the control key),
but I can't figure out how to then just indicate to ignore the click if
control is pressed.

Amil

Re: Disable a context menu in sys tray?? MuZZy
6/29/2006 11:57:43 PM
[quoted text, click to view]

private void OnClick(object sender, EventArgs e)
{
if ((Control.Modifiers & Keys.Control) != 0)
{
.. Do your stuff here ...
}

}

Control.Modifiers is i believe (don't have VS at hand right now)
enumeration and contains currently pressed buttons. So when you binary
add your key of interest the result wil be not zero if that button is
pressed

Hope it helps,
AddThis Social Bookmark Button