MenuItem.Select event is not raised for ContextMenu

  • Thread starter Thread starter MartinBsx
  • Start date Start date
M

MartinBsx

Hello,
I'm using .NET Framework 1.1 and I've found that MenuItem.Select event is
not raised for ContextMenu used at NotifyIcon.
Menu associated with NotifyIcon at Windows systray area is not created
dynamically, Menu was created in Form designer. Particular MenuItems have
their Select += new EventHandler(...) properly registered, but when mouse is
over menu item then Select event handler never gets called. Click event
works just fine and MenuItem.Select when used in normal (MainMenu) menu
works also.
Anyone has an idea how to fix/workaround that problem?
Thanks',
Martin
 
Hi Martin,

Thanks for your post.

Yes, I can reproduce out this issue.

Actually, this is because MenuItem.Select event is triggered by menu's
parent window. When the MenuItem has got focus, it will send a
WM_MENUSELECT notification to its parent window. Then the parent window
intercept this message and fires MenuItem.Select event event.
However, in notifyIcon scenario, the ContextMenu's parent window becomes
Shell's SysTray window, not any windows in your app. So no MenuItem.Select
event will fire.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jeffrey,

Thank you for an explanation of the source of the problem. I believe it is a
bug in .NET 1.1. Any hint how to wokaround it?

I've found that this works perfectly in .NET 2.0. In this version MenuItem
(preciselly ToolStripMenuItem) allows register for MouseHover event which is
even better than Select for my purpose. Select is called immediately when
mouse is over menu item while MouseHover takes some time. But I don't want
to abandon .NET 1.1 yet.

Martin

""Jeffrey Tan[MSFT]"" wrote in message
 
Hi Martin,

Thanks for your feedback.

I do not think this is a bug of VS.net2003. Because .Net 1.1 uses
WM_MENUSELECT notification to implement the ContextMenu.Select event, this
issue has been caused by the windows system design. If we use
ContextMenu.Select event in VS2005, we will still get this result.

Oh, yes, Whidbey contextmenustrip really works well in NotifyIcon. This is
because Whidbey ContextMenuStrip uses different way to implement
item1ToolStripMenuItem.MouseHover event. It internally does not just use
WM_MENUSELECT notification, it just uses some hook technology to get the
mouse hover messages and fires the event.

Anyway, we can resolve this issue through item1ToolStripMenuItem.MouseHover
event.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hello Jeffrey,
""Jeffrey Tan[MSFT]"" wrote in message
Hi Martin,

Thanks for your feedback.

I do not think this is a bug of VS.net2003. Because .Net 1.1 uses
WM_MENUSELECT notification to implement the ContextMenu.Select event, this
issue has been caused by the windows system design.

I think that if you use Select event in this case (it is available to be
used) and it does nothing then it is a problem, somewhere. But I understand
you and I don't want to argue about this. Thank you very much for your time
and explanation.
If we use ContextMenu.Select event in VS2005, we will still get this
result.
Oh, yes, Whidbey contextmenustrip really works well in NotifyIcon. This is
because Whidbey ContextMenuStrip uses different way to implement
item1ToolStripMenuItem.MouseHover event. It internally does not just use
WM_MENUSELECT notification, it just uses some hook technology to get the
mouse hover messages and fires the event.

Yes, and its set of events is much, much richer than old .NET 1.1 MenuItem.
That's great.
Anyway, we can resolve this issue through
item1ToolStripMenuItem.MouseHover
event.
I will do it when I move to .NET 2.0, probably sooned than I thought:-)

Thanks'
Martin
 
Hi Martin,

Thanks for your understanding. Also, I am glad that we have a good
workaround for this issue in .Net2.0.
If you have further concern, please feel free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top