我该如何推出.NET Windows窗体有没有可见窗口的应用程序? [英] How do I launch .net windows forms application with no visible windows?

查看:222
本文介绍了我该如何推出.NET Windows窗体有没有可见窗口的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET Windows窗体应用程序,需要直接打开的通知图标(系统盘),没有可见窗口。我知道我可以在onshown事件或类似的东西做到这一点。但是,如果我这样做,我得到一个闪光的窗口。我怎样才能避免闪光?我试图改变我的的Program.cs 文件看起来是这样的:

I have a .net windows forms application that needs to open directly to the notify icon (system tray) with no visible windows. I realize that I can do this in the onshown event or something like it. But if I do that I get a flash of the window. How can I avoid that flash? I have tried modifying my Program.cs file to look like this:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

MainForm frm = new MainForm();
frm.Visible = false;
Application.Run(frm);

不过,这也不行,因为 Application.Run()使看得见的形式。我是pretty的肯定有一个简单的答案,我很想念。任何帮助是极大的AP preciated。

However this doesn't work either because Application.Run() makes the form visible. I am pretty sure there is an easy answer that I am missing. Any help is greatly appreciated.

推荐答案

有一个过载 Application.Run()这需要在没有任何参数,因此不会立即显示在应用程序启动的形式。当然,你必须管理是什么原因导致应用程序终止自己因为没有初始或主的形式为它进行监控。因此,例如,它会是您的通知图标,这一点我敢肯定,你就可以处理。

There's an overload for Application.Run() that takes in no parameters, and thus doesn't immediately show a form on application launch. Of course, you'll have to manage what causes the application to terminate yourself since there's no initial or 'main' form for it to monitor. So for example it'd be your notification icon, which I'm sure you'll be able to handle.

这篇关于我该如何推出.NET Windows窗体有没有可见窗口的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆