views:

145

answers:

2

Hi,

We have a C# application that works fine on windows XP and windows vista BUT does not show the taskbar (in Vista only). In windows vista the application does not have an icon in the bottom toolbar i.e. if I have the application open and then I go to another application the only way I can get back to the app is by alt+tab through, I cannot click an icon at the bottom.

Other functions of the app work the same in XP & Vista. Please advise how to bring this back on Vista?

Regards,

+1  A: 

Windows uses the extended style bits decide whether a window should have a taskbar icon, These styles aren't directly accessible in C#, but should be set correctly when your form is a normal application form.

The flag that controls this is the WS_EX_APPWINDOW set in the extended styles of your top level form window. From the CreateWindowEx documentation

WS_EX_APPWINDOW Forces a top-level window onto the taskbar when the window is visible.

You can use Spy++ to see whether that flag is set for your window or not. The only way I know for sure to set it is to use interop.

[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);

[DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);

const int GWL_EXSTYLE = -20;
const int WS_EX_APPWINDOW = 0x00040000;

int ExStyle = GetWindowLong(form.Handle, GWL_EXSTYLE);
SetWindowLong(form.Handle, GWL_EXSTYLE, new IntPtr(ExStyle | WS_EX_APPWINDOW));
John Knoeller
+1  A: 

We fixed it by setting the form property showintaskbar property to true.

Weird that all windows os's dont run apps in the same way!

ToughPal