Question

All, I am over half way through a MDI WinForm application and have started testing what we have so far on several different machines and I have found the following error on all machines (running Windows 7/Vista). The error is to do with the TaskBar and the visably active state of the application within it. This will be easier with images:

A. I hover over the Task Bar ready to launch.

Hovering over the application icon (mouse not displayed)

B. I click on the application and it launches no problem and shows in the Task Bar - all good so far.

Launches with no problem

C. Wait for perhaps three seconds and the icon fades away to not being active, so that when I click on it, it launches another instance of my application instead of restoring the one I have just opened!? Once I click on the form and minimise and then restore the form this problem goes away!?

Active icon on the Task Bar dies a death

This is strange and I have no idea how to go about fixing it. This also manifests itself when using the .exe file to launch the application, where the task bar does not show at all until you click on the applications main form. I am truly stumped. If anyone has any idea about what could be happening here, it would be most appreciated? Thanks for your time.

Note. I have narrowed the problem down to the form being launched behind other open forms. I have used the relevent options this.TopLevel = true; in the forms Shown event etc. but nothing seems to work...

Was it helpful?

Solution 2

All,

This was solved by adding

this.Activate();

in the finally block of the main form's (the MDI parent form's) Shown event.

Thanks for your time and help.

OTHER TIPS

I saw a similar issue where an application would not take focus when it was first launched and would not show in the windows 7 taskbar until you clicked on it to activate the main form.

I was never able to track down the real cause but moving the setting of the form's Text property from an OnLoad override to the constructor made the issue go away. Very strange and it still bugs me that I don't know why it was happening.

Not sure if this is applicable to you, but I would be very interested to know if you are also setting Text outside of the constructor.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top