Disable a context menu in sys tray??

  • Thread starter Thread starter Amil Hanish
  • Start date Start date
A

Amil Hanish

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
 
Amil said:
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

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,
MuZZy
 
Back
Top