Show maximized window without hit taskbar

Started by
3 comments, last by JariRG 3 years, 6 months ago

Hi everyone.

I apologize for asking such a stupid question. But I can't do anything about it.

I need to create a window without borders, buttons to close, minimize and all that surrounds it.

And the most important condition is that it maximized to the full screen, but without hit the taskbar.

I tried this:

HWND hwnd = CreateWindowExW(0, L"hello", L"hello", WS_POPUP, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

ShowWindow(hwnd, SW_SHOWMAXIMIZED);

But that damn window hit the taskbar.

That's what I need:

I don't need this:

Thanks!

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese, and a large soda.

Advertisement

maybe this:

// pseudo 
int getTaskbarHeight()
{

// see https://stackoverflow.com/questions/3644531/how-would-i-find-the-height-of-the-task-bar

}


int x = 0
int y = 0
int w = GetSystemMetrics(SM_CXSCREEN)
int h =  GetSystemMetrics(SM_CYSCREEN)

h -= getTaskbarHeight() 

HWND hwnd = CreateWindowExW(0, L"hello", L"hello", WS_POPUP, x, y, w, h, NULL, NULL, hInstance, NULL);

// ShowWindow(hwnd, SW_SHOWMAXIMIZED);

try this, but if u want a quick test, then u could make getTaskbarHeight( ) return 40, which is the default size of the taskbar unless your screen res is scaled (150% → then return 60, 200% → 80 px , etc…)

I leave it as an exercise for u to choose your path: Some people in the past have chosen the red pill and have followed the White Rabbit ?

That's it … all the best ?

I found a topic on the Microsoft website about this:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/fb4de52d-66d4-44da-907c-0357d6ba894c/swmaximize-is-same-as-fullscreen?forum=vcgeneral

I wonder what they were thinking when they did it?

The end result of that topic::

case WM_GETMINMAXINFO:
		{
			HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);

			MONITORINFO monitorInfo = {0};
			monitorInfo.cbSize = sizeof(MONITORINFO);
			GetMonitorInfo(hMonitor, &monitorInfo);

			MINMAXINFO* pMinMax = (MINMAXINFO*)lParam;
			pMinMax->ptMaxSize.x = monitorInfo.rcWork.right - monitorInfo.rcWork.left;
			pMinMax->ptMaxSize.y = monitorInfo.rcWork.bottom - monitorInfo.rcWork.top;
			pMinMax->ptMaxPosition.x = monitorInfo.rcWork.left - monitorInfo.rcMonitor.left;
			pMinMax->ptMaxPosition.y = monitorInfo.rcWork.top - monitorInfo.rcMonitor.top;
		}
		return 0;

Of course, it's not a good solution, but I don't even know what can be done better

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese, and a large soda.

You can specify your exact window position and size when you call CreateWindow, and before that you can get your work area (screen size minus the taskbar wherever it is) using GetMonitorInfo/MONITORINFO.rcWork or SystemParametersInfo/SPI_GETWORKAREA.

This topic is closed to new replies.

Advertisement