C# WinForm如何初始化的时候就自动最小化到右下角的状态栏内。 5
3个回答
展开全部
public MainFrm()
{
InitializeComponent();
Thread th = new Thread(delegate()
{
try
{
this.Invoke(new MethodInvoker(delegate()
{
this.FormBorderStyle = FormBorderStyle.None;
notifyIcon1.Visible = true;
this.Hide();
this.FormBorderStyle = FormBorderStyle.Sizable;
}));
}
catch
{
try
{
this.Invoke(new MethodInvoker(delegate()
{
this.FormBorderStyle = FormBorderStyle.None;
notifyIcon1.Visible = true;
this.Hide();
this.FormBorderStyle = FormBorderStyle.Sizable;
}));
}
catch
{ }
}
});
th.Start();
}
}
试试这个 try 和Catch 你可以适当的去掉 其实就是为了怕有时候窗口句柄创建过慢
{
InitializeComponent();
Thread th = new Thread(delegate()
{
try
{
this.Invoke(new MethodInvoker(delegate()
{
this.FormBorderStyle = FormBorderStyle.None;
notifyIcon1.Visible = true;
this.Hide();
this.FormBorderStyle = FormBorderStyle.Sizable;
}));
}
catch
{
try
{
this.Invoke(new MethodInvoker(delegate()
{
this.FormBorderStyle = FormBorderStyle.None;
notifyIcon1.Visible = true;
this.Hide();
this.FormBorderStyle = FormBorderStyle.Sizable;
}));
}
catch
{ }
}
});
th.Start();
}
}
试试这个 try 和Catch 你可以适当的去掉 其实就是为了怕有时候窗口句柄创建过慢
2014-03-15
展开全部
NotifyIcon 通知栏图标 = new NotifyIcon();
void 通知栏图标_MouseClick(object sender, MouseEventArgs e)
{
this.ShowInTaskbar = true; this.Show();
}
private void 记事历_Deactivate(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized) this.ShowInTaskbar = false;
}
private void 记事历_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized) this.ShowInTaskbar = false;
}
void 通知栏图标_MouseClick(object sender, MouseEventArgs e)
{
this.ShowInTaskbar = true; this.Show();
}
private void 记事历_Deactivate(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized) this.ShowInTaskbar = false;
}
private void 记事历_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized) this.ShowInTaskbar = false;
}
更多追问追答
追问
??????????????
追答
private void 记事历_Load(object sender, EventArgs e)
{
this.Icon = 通知栏图标.Icon = 资源文件.中国国旗;
通知栏图标.MouseClick += 通知栏图标_MouseClick;
通知栏图标.Text = this.Text;
通知栏图标.Visible = true;
this.ShowInTaskbar = false;
this.Hide();
}
private void 记事历_FormClosing(object sender, FormClosingEventArgs e)
{
通知栏图标.Visible = false; 通知栏图标.Dispose();
}
以上补充.
什么意思?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
右下角,那叫托盘 会使用到 notifyIcon
追问
要不您直接教我怎么在我的代码上面改就好了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询