How to remove scrollbars in c ++ console windows

I looked through some Rogue like games (Larn, Rogue, etc.) that are written in C and C ++, and I noticed that they do not have scrollbars to the right of the console window.

How can I perform the same function?

+7
c ++ command-line windows console scrollbar
source share
2 answers

These guys show how to do this:

#include <windows.h> #include <iostream> using namespace std; int main() { HANDLE hOut; CONSOLE_SCREEN_BUFFER_INFO SBInfo; COORD NewSBSize; int Status; hOut = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hOut, &SBInfo); NewSBSize.X = SBInfo.dwSize.X - 2; NewSBSize.Y = SBInfo.dwSize.Y; Status = SetConsoleScreenBufferSize(hOut, NewSBSize); if (Status == 0) { Status = GetLastError(); cout << "SetConsoleScreenBufferSize() failed! Reason : " << Status << endl; exit(Status); } GetConsoleScreenBufferInfo(hOut, &SBInfo); cout << "Screen Buffer Size : "; cout << SBInfo.dwSize.X << " x "; cout << SBInfo.dwSize.Y << endl; return 0; } 
+6
source share

You need to make the console screen buffer the same as the console window. Get the window size using GetConsoleScreenBufferInfo, a member of srWindow. Set the buffer size using SetConsoleScreenBufferSize ().

+3
source share

All Articles