简体   繁体   English

如何防止C#应用程序在上下文菜单期间打开新窗口?

[英]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. 我也想知道如何防止这种情况的发生。

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? 另外,在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.

相关问题 如何防止上下文菜单溢出到C#中的其他监视器上? - How can I keep my context menu from spilling onto another monitor in C#? 如何在 c# windows 表单应用程序中将图标添加到上下文菜单 - how to add icon to context menu in c# windows form application 如何防止我的C#应用​​程序两次打开同一文件 - How to prevent my C# application from opening the same file twice 如何从 C# 应用程序显示 Windows 资源管理器上下文菜单? - How do you show the Windows Explorer context menu from a C# application? 如何防止用户关闭我的 C# 应用程序? - How can I prevent a user from closing my C# application? 如何防止他人在C#应用程序中使用我的非托管DLL? - How can I prevent others from using my unmanaged DLL in their C# application? C# 打开 excel 工作簿后,如何防止用户在同一个 excel 实例中打开另一个 excel 文件(通过 windows)? - C# After opening an excel workbook, how can I prevent a user from opening another excel file(via windows) in the same excel instance? 如何从我的 C# 应用程序中检查新 Microsoft Edge Chromium 的版本? - How can I check the version of the new Microsoft Edge Chromium from inside my C# application? 我如何在DataGridView中的C#中创建上下文菜单 - How can i create a context menu in c# in a datagridview 如何防止Windows显示屏幕保护程序或从应用程序关闭电源? - How can i prevent my windows from showing screensaver or powering down from my application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM