如何在启动时不显示窗口?
可能的重复:
如何使启动表单最初不可见或隐藏
我的应用程序有一个系统托盘,我不希望该窗口在启动时出现。
我怎样才能做到这一点?
这是默认的 Windows 窗体应用程序。
我拖动了一个notifyIcon和一个contexualMenuStrip
当表单关闭时,应用程序退出(也不希望这样)。但是当应用程序启动时,Windows 窗体也变得可见。那么如何在启动时不启动表单(并且在关闭窗口时不退出)?
Possible Duplicate:
How to make the startup form initially invisible or hidden
My application has a System Tray and I don't want the Window appearing on launch.
How can I accomplish this?
This is a default Windows Form application.
I dragged over a notifyIcon and a contexualMenuStrip
When the Form is closed, the application quits (don't want that either). But when the application is launched, the Windows Form is also made visible. So how do I not launch the form on start up (and not quit on closing the window)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,您需要覆盖
SetVisibleCore()
才能实现这一点...另一个选择是将ShowInTaskbar
设置为false
并使用ApplicationContext< /code> 在
Application.Run
中。一些参考链接和示例代码:
Basically you need to overwrite
SetVisibleCore()
to achieve that... another option is to setShowInTaskbar
tofalse
and useApplicationContext
inApplication.Run
.Some reference links and sample code:
答案不是隐藏您的主表单,而是首先不显示/加载它。
一种方法是创建自定义
ApplicationContext
:然后,您可以将处理程序附加到
Application.Run(context)
行之前的通知图标,以允许诸如打开主窗口之类的操作表单,显示菜单等,..The answer isn't to hide your main form, but not to show it / load it in the first place.
One way is to create a custom
ApplicationContext
:You can then attach handlers to your notification icon prior to the
Application.Run(context)
line to allow for things like opening your main form, showing a menu, etc,..