# How to hide the taskbar with Win32 API on resize?

This topic is 1346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

I have a windowed app on Windows 7. I double click the title bar to make the window max the entire screen. The taskbar remains visible on the bottom, but this is undesired. I did some research, and this is what I came up with. However, the task bar is still showing. Any thoughts would be helpful. Thanks.

Edit: To clarify, this is for a fullscreen-windowed game that covers the taskbar, and not actually trying to kill the user's taskbar.

                    ShowWindow(g_hWnd, SW_HIDE);

LONG lStyle = GetWindowLong(g_hWnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_SYSMENU);
SetWindowLong(g_hWnd, GWL_STYLE, lStyle);

LONG lExStyle = GetWindowLong(g_hWnd, GWL_EXSTYLE);
lExStyle &= WS_EX_APPWINDOW | WS_EX_TOPMOST;
SetWindowLong(g_hWnd, GWL_EXSTYLE, lExStyle);

SetWindowPos(g_hWnd, HWND_TOPMOST, 0,0,0,0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
ShowWindow(g_hWnd, SW_SHOW);

Edited by shinypixel

#### Share this post

##### Share on other sites

Look up the MSDN documentation for SWP_NOZORDER and SWP_NOOWNERZORDER.

#### Share this post

##### Share on other sites

Thanks, but even removing the two flags still show the taskbar, and oddly enough the task bar is somewhat cut off near the top.

#### Share this post

##### Share on other sites

this is undesired.

Why is it undesired?

A couple comments: if you're the only one using the app, you can set autohide for the taskbar; if you're working on an app for distribution, you should respect the user's desktop settings.

EDIT: If your app is intended for distribution, it may also be that the user has dual monitors, maximizes your app in the second monitor and the status of the taskbar is immaterial.

Edited by Buckeye

#### Share this post

##### Share on other sites

Well, if you played Angry Birds on the Mac, a full screen game is actually a window. It covers the taskbar on the bottom. I'm trying the same for Windows.

I did auto-hide the taskbar, and the window dimensions were long enough.

So, I'm not trying to get rid of the taskbar, but trying to do a fullscreen-window feature that will cover the taskbar.

So far, the window is only partially above the top of the taskbar.

Edited by shinypixel

#### Share this post

##### Share on other sites

trying to do a fullscreen-window feature that will cover the taskbar.

"Full-screen" is different than "maximized." In Windows, setting full-screen mode results in the Window client area covering the entire monitor screen (no taskbar), and the window has no title-bar, no frame and no menu bar. Is that what you're trying to do?

EDIT:

So far, the window is only partially above the top of the task bar.

That's the auto-hide feature of the taskbar reserving a few pixels at the bottom of the screen to detect the mouse being moved down to bring up the taskbar. That's good!

Edited by Buckeye

#### Share this post

##### Share on other sites

Yes. The issue is OpenGL won't render as a single buffer in fullscreen mode due to Aero, I believe. It does work when it's in windowed mode. So If I double click the title bar (or send a message to call WM_SIZE), I can get single buffering working as if it's full screen for the project's needs. If I auto-hide the taskbar, the window's dimensions cover the entire monitor, and the single buffer works. So, now I'm trying to cover the entire taskbar with the window when it's not in auto-hide.

#### Share this post

##### Share on other sites

Someone suggested just making and drawing to an FBO (frame buffer object) and send that buffer to the back buffer, which gives the same feel as a single buffer. I haven't studied that far into OpenGL, so perhaps this is a better solution down the road than black magic with window manipulation. I was just thinking short-term with a window reaching the monitor's dimensions, but I can always just auto-hide the taskbar as I study until that point. Thanks for the idea on auto-hiding the taskbar as I study.

Edit: This ended up covering the taskbar for a full-screen window effect with single buffering, despite Aero, though I don't recommend it for real projects:

        LONG lStyle = GetWindowLong(win_getHandle(), GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_SYSMENU);
SetWindowLong(win_getHandle(), GWL_STYLE, lStyle);

SetWindowPos(win_getHandle(), 0, 0, 0,     win.SystemInfo.DesktopResolution.right-1,
win.SystemInfo.DesktopResolution.bottom-1, SWP_SHOWWINDOW);
MoveWindow(win_getHandle(), 0, 0, win.SystemInfo.DesktopResolution.right+1,
win.SystemInfo.DesktopResolution.bottom+1, TRUE);
Edited by shinypixel

#### Share this post

##### Share on other sites

This might be interesting: http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05/414910.aspx

Basically the task bar has some code behind it to notice if it should hide itself or stay visible, if you follow the blog entry you should find how to do it right.

#### Share this post

##### Share on other sites

Try something like this:

CreateWindowEx(WS_EX_TOPMOST,
"ClassName",
"Caption",
WS_VISIBLE | WS_POPUP
0, 0,    // the starting x and y positions should be 0
SCREEN_WIDTH, SCREEN_HEIGHT,
NULL,
NULL,
GetModuleHandle(NULL),
NULL);
Edited by Eliad Moshe

#### Share this post

##### Share on other sites

You could have a look at my game window class in my 3d engine, that's how i do it. My guess is that you forgot the

CDS_FULLSCREEN

at line 110 in my code, in the ChangeDisplaySettings() function.

You don't need (or want) to hide the taskbar... with this code, the taskbar will be covered by the fullscreen window automagically.

I also agree that using a fbo for multiple resolutions is the way to go. It may cause stretching though, for example, when resizing the window in windowed mode.

Edited by Vortez