views:

706

answers:

3

Hello,

I have a window, which I SetWindowPos(window, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_FRAMECHANGED);

It covers the whole screen, ok, but it takes a while (0.5 sec) to cover the taskbar as well.

Is there a way to come over the taskbar immediately? I found that setting HWND_TOPMOST does it immediately, but it stays above all the other windows, even if I switch the app - this is something I don't want. Also, if I first hide the window and then show it, it somehow forces the window to redraw and covers the taskbar immediately, but it flickers (because of the hiding). Is there another way?

+2  A: 
  1. Right click on the taskbar
  2. choose Properties
  3. uncheck the checkbox that says "Keep the taskbar on top of other windows".

The taskbar belongs to the user, It's up to them to care about having it take 1/2 second to auto-hide when you app goes full screen. If they want to change that behavior then they can change it.

If you are working in an embedded system, then you may have a legitimate reason to hide the taskbar. But in that case, there's no reason not to simply configure the taskbar to not always be on top. You could also have a look at SystemParametersInfo if you want to change some of these settings in your code.

John Knoeller
A: 

I believe the taskbar will get out of the way when its shell hook tells it about a "rude app", this might take a little while.

What if you start out with the window HWND_TOPMOST and make it not top most after 1 second?

Anders
A: 
Warpspace
Thanks for the reply. I think the reason why it works is that you resize the window at least twice "SetWindowPos() and ShowWindow()" (I don't know that "ChangeDisplaySettings()"). The problem is, what happens if I'm already in "SW_MAXIMIZE" and what to go full-screen?
Lars Kanto
I read somewhere that there is kind of "cache" of the window manager. So I was hoping there is a way to force it to refresh or otherwise tell it that it should repaint the taskbar beneath.
Lars Kanto
In other words, it seems to me that "SW_MAXIMIZE" does something besides the resizing and I would like to know what...
Lars Kanto
Sorry for my late reply. As far as I know, "SW_MAXIMIZE" just tells windows that you want as much screen as possible (just like the button on the top-left of a window next to the close button). The code I provided relies on the combination of function calls I used, rather than just the setting in ShowWindow(). If you're already in "SW_MAXIMIZE", this code still works.
Warpspace
As for repainting the taskbar, that's considered a separate program, and you're not supposed to (can't?) handle it's repainting. If you're programming for Windows Mobile, however, you can find the "taskbar" and hide/move (I do both) it. Use "FindWindow(TEXT("HHTaskBar"), NULL);" to find it (it returns a window handle), and then call ShowWindow() or MoveWindow() to modify it (and remember to restore it on exit). I'm not sure if there's an equivalent for normal windows, though.
Warpspace