the console have 2 types of size, right?
i belive that is the window size and the container size. the window size i can do it, but how can i change the container(i think that you call it buffer or something) size?
Printable View
the console have 2 types of size, right?
i belive that is the window size and the container size. the window size i can do it, but how can i change the container(i think that you call it buffer or something) size?
There are 2 sizes associated with a console. The size of the window and the size of the buffer. The buffer can be greater than the size of the window, but the window cannot be greater than the buffer. Basically you write to the buffer and the window displays that portion of the buffer over which it is placed.
To set buffer size, use SetConsoleScreenBufferSize(...)
To get buffer size, use something like
To get windows size, you need something like thisCode:DWORD GetBufferSize(HANDLE sout, COORD& size)
{
CONSOLE_SCREEN_BUFFER_INFO info;
if (!GetConsoleScreenBufferInfo(sout, &info)) {
return (GetLastError());
}
size.X = info.dwSize.X;
size.Y = info.dwSize.Y;
return (0);
}
Code:DWORD GetConsoleSize(HANDLE sout, COORD& size)
{
CONSOLE_FONT_INFO cfinfo;
COORD fsize;
WINDOWINFO winfo;
if (!GetCurrentConsoleFont(sout, FALSE, &cfinfo)) {
return (GetLastError());
}
fsize = GetConsoleFontSize(sout, cfinfo.nFont);
if (!fsize.X && !fsize.Y) {
return (GetLastError());
}
winfo.cbSize = sizeof(WINDOWINFO);
if (!GetWindowInfo(GetConsoleWindow(), &winfo)) {
return (GetLastError());
}
size.Y = (SHORT)((winfo.rcClient.bottom - winfo.rcClient.top) / fsize.Y);
size.X = (SHORT)((winfo.rcClient.right - winfo.rcClient.left) / fsize.X);
return (0);
}
To set window size use something like this
Code:DWORD SetConSize(HANDLE sout, COORD size)
{
CONSOLE_SCREEN_BUFFER_INFO info;
if (!GetConsoleScreenBufferInfo(sout, &info)) {
return (GetLastError());
}
info.srWindow.Top = 0;
info.srWindow.Bottom = size.Y - 1;
info.srWindow.Left = 0;
info.srWindow.Right = size.X - 1;
return (!SetConsoleWindowInfo(sout, TRUE, &info.srWindow) ? GetLastError() : 0);
}
Yes, the window just shows a part of the buffer if the size of the buffer is greater than the size of the window. Depending upon how the sizes of the buffer and window have been set, you can get a horizontal scrollbar as well. If you don't want scroll bars then set the window size and the buffer size to be the same.
Note when setting buffer sizes that the rules apply! You cannot set a window greater than the buffer size and then set the buffer! The buffer needs to be set first and then the window size. Also if you are reducing the buffer size to be less than the current window size, then reduce the window size first and then the buffer size.
why the scrollbar isn't hided?
seems that these code is ignored:(Code:CONSOLE_SCREEN_BUFFER_INFO info;
RECT WindowRect;
GetWindowRect(ConsoleHandle,&WindowRect);
info.srWindow.Top =WindowRect.top;
info.srWindow.Left= WindowRect.left;
info.srWindow.Bottom = WindowRect.bottom;
info.srWindow.Right = WindowRect.right ;
SetConsoleWindowInfo(ConsoleDC, TRUE, &info.srWindow);
What does this GetWindowRect return? TRUE or FALSE?
The same question - about GetWindowRect.
sorry about that.. you shared. but if the windows and buffer sizes are the same, why the scrollbar stills there?