[英]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. 我正在开发一些C#应用程序,以帮助自己学习C#。 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. 当我的应用程序最小化时,它将在系统托盘中显示一个notifyicon。 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.
我也想知道如何防止这种情况的发生。
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? 另外,在Visual C#Studio 2010中,调试时是否有方法可以准确确定我所关注的代码的哪种形式/部分,以便我可以单击其中一个窗口以查看其确切含义?
How are you showing the ContextMenu? 您如何显示ContextMenu? I suspect you are calling ContextMenu/ContextMenuStrip.Show(x,y) directly.
我怀疑您是直接调用ContextMenu / ContextMenuStrip.Show(x,y)。 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. 而是将ContextMenu / ContextMenuStrip分配给NotifyIcon的ContextMenu / ContextMenuStrip属性,而不是在鼠标单击处理程序中手动显示它。 If it is used as part of ContextMenu/ContextMenuStrip property, it won't show in the taskbar.
如果将它用作ContextMenu / ContextMenuStrip属性的一部分,它将不会显示在任务栏中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.