0
votes

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 ?

1
Try SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);. - 500 - Internal Server Error
@500-InternalServerError: hey, that's becoming better and close to my need ! Strangely, a scroll bar appears on the right, and clearing the WS_VSCROLL bit in the window style does not work :-( - Yves Daoust
@500-InternalServerError: now done (I needed to reduce the buffer size of the console). If you want you can enter your suggestion as an answer. Otherwise I'll do it. - Yves Daoust
No, you go ahead. - 500 - Internal Server Error
Same as ShowWindow(hWnd, SW_MAXIMIZE);, but you may want to check Console Virtual Terminal Sequences (SetConsoleMode + ENABLE_VIRTUAL_TERMINAL_PROCESSING enables VT100 compatible mode, the suggested behavior - cross-platform compat). - Jimi

1 Answers

1
votes

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 .