简体   繁体   中英

How can I prevent my C# application from opening new windows during context menu?

I'm working on some C# application to help myself learn C# a bit. I've been searching for a solution, but I can't seem to find one.

When my application minimizes, it shows a notifyicon in the system tray. When I right click it, a context menu pops up on the mouse. However, for each level of the menu and submenu, a blank window pops up on the taskbar until I exit that submenu or the contextmenu.

I don't know why, and I'd like to. I'd also like to know how to prevent that from happening.

Edit

Also, in Visual C# Studio 2010, when debugging, is there a way to determine exactly which form/part of the code I've focused on, so that I could click one of those windows to see what exactly it is?

How are you showing the ContextMenu? I suspect you are calling ContextMenu/ContextMenuStrip.Show(x,y) directly. That will cause it to show in the taskbar.

Instead, assign your ContextMenu/ContextMenuStrip to the ContextMenu/ContextMenuStrip property of your NotifyIcon rather than manually showing it in the mouse click handler. If it is used as part of ContextMenu/ContextMenuStrip property, it won't show in the taskbar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM