Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a window with title less border? when the window is maximized it should not cover the task bar

Tags:

windows

winapi

I want to create a window using win32 without title bar. The border should resize the window. But when I maximize the window it covers the task bar also and I don't want to cover task bar. How can I achieve that?

Thank you.

like image 689
sindhu Avatar asked Jan 23 '26 13:01

sindhu


1 Answers

I think if a window is in MAXIMIZED state, it doesn't cover the standard taskbar - however, you can force your window fullscreen without it being maximized. To demonstrate:

// Force window to cover the taskbar...
case WM_SIZE:
  if( wParam == SIZE_MAXIMIZED )
  {
    ShowWindow( hWnd, SW_RESTORE ); // not MAXIMIZED any more

    // show on top at 1920x1080 size
    SetWindowPos( hWnd, HWND_TOPMOST,0,0,1920,1080,SWP_SHOWWINDOW );
  }
  break;

Note that this does have all the problems associated with a window being TOPMOST!

Alternatively... If you have a window without menubar which covers the taskbar when maximized and you want the taskbar to still be visible then resize the window to the screen work area:

HMONITOR hmon= MonitorFromWindow(hDlg, MONITOR_DEFAULTTONEAREST );
MONITORINFO moninfo;
moninfo.cbSize= sizeof(moninfo);
GetMonitorInfo(hmon, &moninfo);

SetWindowPos(hWnd,0, moninfo.rcWork.left, moninfo.rcWork.top,
                     moninfo.rcWork.right,moninfo.rcWork.bottom, SWP_NOZORDER );

Note: you do not want to set such a window to MAXIMIZED, just use the above to resize it to fullscreen minus taskbar (if the window does not have a title bar/system menu then it cannot be moved by the user, so it works like being maximized).

like image 102
TonyWilk Avatar answered Jan 27 '26 00:01

TonyWilk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!