user1196549
user1196549

Reputation:

Setting a window to full screen programmatically

I am trying to resize a console window to full screen in a non-.NET C++ application that runs under Windows 10.

I am able to get rid of the window frame and resize, using one of SetWindowPos or MoveWindow from the WinAPI.

But the window origin (top-left corner) does not move to the top-left corner of the screen and stays in its initial position, which is random. In fact, the X, Y arguments of these functions seem to be just ignored.

Any suggestion ?

Upvotes: 0

Views: 1387

Answers (1)

user1196549
user1196549

Reputation:

That did it:

HWND hWnd = GetConsoleWindow();
DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
SetWindowLong(hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);

Adjust the buffer and window sizes of the console to avoid scrollbars.

Credit to 500 - Internal Server Error .

Upvotes: 1

Related Questions