Playing around with the console functions to control the layout of a console program, and I cannot change its size.
Currently, what I can do is disable resizing, remove buttons and change the buffer size, but if I try to resize the window itself, all attempts fail; albeit, some functions do resize the window, but in pixels, so scale is drastically off.
What I've done so far (not a C++ person, just fiddling around, go easy on syntax-isms):
#include <iostream> #include <Windows.h> using namespace std; COORD conBufferSize = { 150, 40 }; SMALL_RECT conScreen = { 0, 0, 150, 40 }; CONSOLE_SCREEN_BUFFER_INFOEX csbie; int main() { // console opened for application HWND hwConsole = GetConsoleWindow(); // hide it ShowWindow(hwConsole, SW_HIDE); // get the style for it DWORD style = GetWindowLong(hwConsole, GWL_STYLE); // disable maximizing and minimizing and resizing style &= ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SIZEBOX); SetWindowLong(hwConsole, GWL_STYLE, style); HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); SetConsoleScreenBufferSize(hConsole, conBufferSize); // this does nothing to the window itself as best I can tell // if by "window" it means what portion of the display window you view "into" // commented out here for functionality // SetConsoleWindowInfo(hConsole, TRUE, &conScreen); SetConsoleActiveScreenBuffer(hConsole); // this sequence works, but seems by accident // surely there is another method? csbie.cbSize = sizeof(csbie); GetConsoleScreenBufferInfoEx(hConsole, &csbie); csbie.srWindow = conScreen; SetConsoleScreenBufferInfoEx(hConsole, &csbie); // required to update styles // using the cx/cy parameters sets size in pixels // that is much smaller than buffer size which accounts for font size // therefore this "doesn't" work SetWindowPos(hwConsole, HWND_TOP, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE| SWP_SHOWWINDOW); // to look at the console until close while (1) { } return 0; } Now from what I can reason, if I have a screen buffer that is 100 columns by 40 rows, that doesn't translate directly to the size of the window housing the buffer. So my next thought is that I need to determine how many pixels the current console font is using, then multiply the buffer dimensions by that to determine the pixel size and use SetWindowPos or the SetConsoleScreenBufferInfoEx methods.
One thing I am unsure about is why the srWindow attribute is able to modify the display window with a similar description to that of SetConsoleWindowInfo and yet that produces no discernable change.