How to hide the taskbar with Win32 API on resize?

Started by
11 comments, last by Vortez 9 years, 11 months ago

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

Look up the MSDN documentation for SWP_NOZORDER and SWP_NOOWNERZORDER.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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


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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Are your window dimensions actually large enough?

Also, I totally agree with Buckeye - apps that screw with my desktop settings are very, very annoying and likely to be uninstalled with extreme prejudice.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

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.


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!

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.

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);
Just for everyone's edification: "windowed fullscreen" (sometimes also called "borderless windowed" or s few other things) is a feature a lot of users prefer. It avoids some wonky behavior with alt-tab and lets the user interact with the rest of the desktop more easily, especially with multiple monitors (eg I can go into a menu and get out of relative mouselook mode, move my cursor out of the window onto a second monitor to interact with Netflix, and then go back to the game, all with minimal fuss or waiting). It looks just like any other full-screen window but is not implemented the same. Many newer games have three options: Windowed, Fullscreen, and this third option.

Sean Middleditch – Game Systems Engineer – Join my team!

This topic is closed to new replies.

Advertisement