Windowed mode goes under windows taskbar

Hello,
My game is set to windowed mode 1920*1080.
When the game loads, it loads on all of the screen at the bottom part is under the taskbar.
Once I press the maximize button or double click the top part of my game, the game resizes to full screen but takes in consideration Windows taskbar.
Is there a way to set this by default?
or is the a way to tell my application to execute the windows maximize window command?

You could send WM_SYSCOMMAND/SC_RESTORE win32 message to the app window by P/Invoking into PostMessage API.

Thank for replying, could you please explain how I can send the message or where I can read about sending a windows message?

Yeah, you’d call PostMessageW windows API:

[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
static extern bool PostMessageW(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

const uint WM_SYSCOMMAND = 0x0112;
const uint SC_MAXIMIZE = 0xF030;

void Awake()
{
    PostMessageW(GetActiveWindow(), WM_SYSCOMMAND, new IntPtr(SC_MAXIMIZE), IntPtr.Zero);
}
1 Like

Excuse me, how to achieve the same task under the Apple system?
** @Tautvydas-Zilys **

Unfortunately, I’m not very familiar with macOS windowing APIs, but I suspect you’d have to do something similar.

1 Like

Fantastic! Exactly what I wanted, thank you very much.