开发者

Windows Application not showing in taskbar on vista

开发者 https://www.devze.com 2022-12-21 22:01 出处:网络
We have a C# application that works fine on windows XP and windows vista BUT does not sho开发者_如何转开发w the taskbar (in Vista only). In windows vista the application does not have an icon in the b

We have a C# application that works fine on windows XP and windows vista BUT does not sho开发者_如何转开发w 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,


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));


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消