Create a resizable window

10

Hello, I've been able to create a console window that does not show the scroll bars:

CONSOLE_SCREEN_BUFFER_INFO csbi;
int columns, rows;
COORD size;
COORD BufSize;

while(TRUE) {
    size = GetLargestConsoleWindowSize(GetStdHandle(STD_OUTPUT_HANDLE));
    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
    columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
    rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;

    BufSize.X = columns;
    BufSize.Y = rows;
    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), BufSize);
    sleep(5);
}

However, the console created by this code does not allow us to increase the size of the console, we can only reduce the size. For this I have changed the following lines of code:

columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;

To:

columns = csbi.srWindow.Right - csbi.srWindow.Left + 2;
rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 2;

In this way, with some effort, you can increase the size of the console. However, in this way the scrollbars reappear as well, something they wish they did not show up. Does anyone know of any solution how I would adapt the above code so that scrollbars would not appear, keeping the console window fully resizable?

    
asked by anonymous 17.07.2018 / 13:22

0 answers