Disable a context menu in sys tray??

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
 
M

MuZZy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top