Reputation: 934
I'm using window.h in my C program and want to be able to prevent the user from resizing the console window.
Is it possible to remove the scroll bars and "drag to resize" functions (shown in image) of the console window in using C?
Upvotes: 0
Views: 382
Reputation: 34583
You can remove the scroll bars by setting the console text buffer size to the same size as the viewport (tested with Windows 7).
#include <stdio.h>
#include <windows.h>
int main(void)
{
CONSOLE_SCREEN_BUFFER_INFO info;
HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleScreenBufferInfo(hConsoleOutput, &info)) {
COORD coord;
coord.X = info.srWindow.Right - info.srWindow.Left + 1;
coord.Y = info.srWindow.Bottom - info.srWindow.Top + 1;
SetConsoleScreenBufferSize(hConsoleOutput, coord);
}
getchar();
}
Upvotes: 1