C#WinForms和任务栏图标 [英] C# WinForms and Taskbar Icons

查看:113
本文介绍了C#WinForms和任务栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

每次我的应用程序打开新表单时,Windows任务栏上都会创建一个新图标.通常,Windows应用程序仅在任务栏上显示应用程序图标.不是每个表单的图标.我从未见过这样的事情.我该如何解决?

我正在使用VS2010.

谢谢...

Hi Guys,

Every time my application opens a new form, a new icon is created on the Windows taskbar. Normally, a Windows application only shows the application icon on the taskbar; not an icon for each form. I''ve never seen anything like this. How do I fix it?

I''m using VS 2010.

Thanks...

推荐答案

您是正确的,为每种形式的应用程序显示新图标是错误的.您需要使用
You are right, showing new icons for each form of application is wrong. You need to use
Form newForm = //...
newForm.ShowInTaskbar = false; //this is what you are asking about

//bonus:
newForm.Owner = myMainForm;
//if this is done in the class of main form, will be:
//newForm.Owner = this;



奖励:所有者/拥有的表单是另一个重要的关系,与表单的显示有关-激活;它将支持应用程序完整性.您应将ShowInTaskbar = true用于您的主要形式,仅用于此形式.激活此表单时,其他表单也将位于Z顺序的顶部,因此,其他应用程序的任何形式都不能放置在它们之间.

设置所有权的另一种方法是Form.AddOwnedForm.

请参阅 http://msdn.microsoft.com/en-us/library/system .windows.forms.form.aspx [ ^ ].

-SA



Bonus: owner/owned form is another important relationship which is related to showing of the form — its activation; it will support application integrity. You should use ShowInTaskbar = true for you main form, only for this one. When you activate this form, other forms will also go on top of Z-order, so no form of other application can be placed in between.

Another way of setting up ownership is Form.AddOwnedForm.

See http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].

—SA


您应创建一个 ^ ]作为主窗口.所有其他表单都应作为该MDI父级的子级打开.
这样一来,您只会在任务栏中看到您的MDI,而不会看到其他所有窗体.
You should create an MDI Main Form[^] as main window. All other Forms should be opened as a child of this MDI parent.
That way you''ll only see your MDI in the taskbar and not all other Forms.
MyForm frm = new MyForm();
frm.MdiParent = this; // If you are opening it from you main form.
frm.Show(); // Will now open as mdi child without creating a taskbar item.


希望对您有所帮助:)


Hope it helps :)


这篇关于C#WinForms和任务栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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