What causes a window to not appear on the taskbar until Alt-Tabbed appears in Vista?

When our application starts programmatically (either through user actions in the MSI installer, or when starting a new instance) in Windows Vista (also happens in the beta version of Windows 7), it will not appear on the taskbar and will not be focused. Alt-tabbing to it will make it display correctly in the taskbar and remain there.

What causes this? I have already seen this in some other applications, but I don’t know why. Out is a .NET WinForms application. Never seen this happen in XP, only Vista and 7

Edit: Well, it seems that the only time this happens reproducibly is when it is started by the installer, I believe that in other cases this happens, but I can just be crazy. The startup code is a little complicated to publish, because we process various command line launch options, and it starts the waveform before starting the main application, etc.

Has anyone had to deal with this scenario before and worked?

+7
windows-vista winforms taskbar
source share
9 answers

Try checking your main application form "Property Form". If it is ToolWindow (Fixed or Sizable), try replacing it with FixedDialog, for example. This solved the problem in my case.

+3
source share

The usual reason for this is that there are no window styles in the main application window that let Windows recognize this main application window (not the tool window or dialog box). Therefore, Windows should guess based on how the application was launched, etc.

Use Spy ++ to complicate window styles (especially advanced styles) if your window is to the window of some other window that does not have this problem. Are you missing the WS_EX_APPWINDOW style? Are there any other styles / advanced styles different from other top-level windows?

+1
source share

G.So's answer made me find a solution to my problem, caused by the fact that I had my form from startup, but was installed borderless in an empty place.

If someone is interested in how I managed to switch the switch to borderless and it appears on the taskbar without any dirty hacks .. here it is ..

Create a new event from the form in the "Displayed" form of the event and place your line of code to go to the limitless area here. The problem is resolved :)

  private void Form1_Shown(object sender, EventArgs e) { this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; } and for the lazy ones ;) >>>> this.Shown += new EventHandler(Form1_Shown); 

Thanks again G.So for figuring out what might cause this in the first place.

+1
source share

I also braked this problem and found, as the previous commentator said, you cannot have anything in the form of Load () that will change the FormBorderStyle property. Move everything that changes it to the Shown () event.

+1
source share

Never watch this in XP, only Vista and 7

Maybe this is a bug in Vista ...?

What happens if you call SetForegroundWindow () (or the equivalent in .Net)?

Edit

Of course, I meant "BringWindowToTop ()".

Or both.

0
source share

Well, one solution is to use a hack such as this . It really is not for that.

Usually, the decision about whether the window will be on the taskbar or not is based on the border styles that it uses. The article in which I am linked provides a bit more detailed information. Commenting on the article about whether you have an owner or not, may well be very important for your problem, since the window may somehow get a different owner when launched by the installer.

This article is in VB, but it is all based on API calls, so the information it provides is pretty language-independent.

0
source share

We had the same problem and fixed it by setting the showintaskbar property property to true.

It is strange that all os windows do not launch applications the same way!

0
source share

In our situation, this was tracked before changing the property of the form text in the Load event.

By BeginInvoke this inside BeginInvoke , this strange behavior no longer occurs.

Hope this helps anyone.

Example

 private void Form_Load(object sender, EventArgs e) { ... ... ... // this needs to be inside a BeginInvoke otherwise it messes with the taskbar visibility this.BeginInvoke(new Action(() => { this.Text = "Something new"; })); ... ... ... } 
0
source share

We faced the same problem, also in Windows 8. Sometimes the form correctly got the focus, but it only said ~ 30% of the time.

We tried different solutions, but in fact the one that worked was as follows:

 private void OnFormShown(object sender, EventArgs e) { // Tell Windows that the Form is a main application window this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; // Even if true, enforce the fact that we will the application on the taskbar this.ShowInTaskbar = true; // Put the window to the front and than back this.BringToFront(); this.TopMost = true; this.TopMost = false; // 'Steal' the focus. this.Activate(); } 

In addition, we also do not set the form title during the Load event.

0
source share

All Articles