Let's say I'm writing a Windows Forms (.NET Framework 3.5) application which shows the first form in the usual way:
Application.Run(new Foo());
At this point the title and icon of this applicatio开发者_开发技巧n are correctly shown in the "Application" tab of the task manager and I'm happy.
Then somewhere in Foo I show a second form while hiding the first:Bar bar = new Bar();
try
{
Visible = false;
bar.ShowDialog();
}
finally
{
Visible = true;
bar.Dispose();
}
This works as expected, but as long as Foo is hidden, the entry in the "Applications" tab of the task manager for the application also disappears. Unfortunately some users and third party tools are terribly confused by this.
Is there a way to still display the icon and name of an application in the task manager if the "main form" of the application is not visible?
An Ancient smoke-and-mirrors trick I've done in the past... leave the form visible, but set its LOCATION to something like top = 0, left = -5000, so it won't be in the visible screen area
If bar is inherited from the windows form. Have you tried adding the same icon to that form?
This is by-design of Windows, if the main launched window is hidden, its entry in the Applications tab is hidden too.
I don't think you can do that, the opposite is doable though.
The reason behind that I guess, is that when you hide a window you're actually making it act or be used as a service/background application.
精彩评论