隐藏在发射形式 [英] Hide form at launch

查看:151
本文介绍了隐藏在发射形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个计划,只需要一个NotifyIcon的按预期工作。所以我一直试图让主要形式的程序启动时隐藏。



在frmMain_Load,我都试过

  this.Hide(); 
THIS.VISIBLE = FALSE;



没有成功。



他们的工作。其他的方法,如在NotifyIcon_MouseClick法,但我想它隐藏在负载



我在另一个问题,看到这里那么,马蒂亚斯建议这样的:

 的BeginInvoke(新MethodInvoker(代表
{
隐藏();
}));

这工作的,但是当我启动该程序,我可以看到的形式闪烁实快。这比没有好,但我不知道是否有更好的解决了这一点。



感谢。


解决方案

  //你的Program.cs转换这
静态无效的主要()
{
Application.EnableVisualStyles() ;
Application.SetCompatibleTextRenderingDefault(假);
Application.Run(新Form1中());
}

//为了这个
静态无效的主要()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(假);
Form1中TheForm =新Form1的();
Application.Run();
}

//调用Application.Exit()从任何地方停止Application.Run()消息泵和退出应用程序


I have a program which only needs a NotifyIcon to work as intended. So I've been trying to get the main form to hide when the program starts.

In frmMain_Load, I tried both

this.Hide();
this.Visible = false;

without success.

They work in other methods, like in the NotifyIcon_MouseClick-method, but I want it to hide at Load.

I saw in another question here at SO where Matias suggested this:

BeginInvoke(new MethodInvoker(delegate
{
    Hide();
}));

This works, but when I launch the program I can see the form flashing real fast. It's better than nothing, but I wonder if there is any better solution to this.

Thanks.

解决方案

// In Your Program.cs Convert This
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}

// To This
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Form1 TheForm = new Form1();
    Application.Run();
}

// Call Application.Exit() From Anywhere To Stop Application.Run() Message Pump and Exit Application

这篇关于隐藏在发射形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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