3
votes

I have a fairly standard C++ program where I create a fullscreen window (with two child windows). On my development computer with Windows 10 this window fills the entire screen and covers the taskbar.

On Windows 7 it does not cover the task-bar. After some experimenting it seems that if I turn off Aero the program will cover the taskbar!

I've also created a quick C#/WPF application and this application is able to cover the taskbar regardless of the state of Aero.

Am I missing a window message or creation option for the window?

Here is the code that positions and creates the Window

// Get a handle to the primary monitor, which by definition has its top
// left corner at (0, 0).
const POINT ptZero = { 0, 0 };
HMONITOR hmon = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY);
MONITORINFO mi = { sizeof(mi) };
GetMonitorInfo(hmon, &mi);

// Fill the entire screen
layout->left   = mi.rcMonitor.left;
layout->right  = mi.rcMonitor.right;
layout->top    = mi.rcMonitor.top;
layout->bottom = mi.rcMonitor.bottom; 

// Create a full screen window
m_hwnd = CreateWindowEx(
  WS_EX_TOPMOST,
  className,
  windowName,
  WS_POPUP | WS_VISIBLE,
  layout.left,
  layout.top,
  layout.right - layout.left,
  layout.bottom - layout.top,
  NULL,
  NULL,
  GetModuleHandle(NULL),
  this); // LPARAM is used in WM_CREATE to associate the class instance with the Window  

Here is the code that handles the Window messages

switch (uMsg)
{
case WM_PAINT:
    OnPaint(hwnd); // Draws a black background 
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
default:
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

Update: After some Googling I found that this issue might also be DPI related: http://forums.pcsx2.net/Thread-Fullscreen-Windows-7-Taskbar-does-not-auto-hide-w-aero https://productforums.google.com/forum/#!topic/chrome/5dMYLChXeWk

What works and doesn't work at this moment:

Areo + DPI @ 150%: taskbar not covered No Areo + DPI @ !150%: taskbar covered Areo + DPI @ 100%: taskbar covered No Area + DPI @ 100%: taskbar covered

This got me pretty baffled...

1
Get familiar with the Spy++ utility, you can see the style flags that the C# app uses. - Hans Passant
Have you tried adding WS_MAXIMIZE? And maybe WS_EX_TOPMOST will help as well. - Simon Kraemer
Thanks @HansPassant, I'll check it out. @SimonKraemer, I'm already using WS_EX_TOPMOST (though it shouldn't be needed). I'll try WS_MAXIMIZE as well. - Roy T.
I don't suppose I could summon @RaymondChen here? :). According to thim I shouldn't have to think so hard about this: blogs.msdn.microsoft.com/oldnewthing/20050505-04/?p=35703 - Roy T.

1 Answers

0
votes

After I found out that DPI has a role to play I stumbled upon the solution. We need to tell Windows that our application is DPI aware. If we do not do this Windows will try to rescale the UI elements of our application. I still do not know why this only causes problems when Aero is enabled but this work around fixes it:

Add a file called "manifest.xml" (name doesn't matter) to your project with the following contents:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

Then in the property pages change the following options for all configurations

  • Linker->Manifest File
    • Generate Manifest: Yes
  • Manifest Tool -> Input and Output
    • Additional Manifest Files: manifest.xml
    • Embed Manifest: Yes