How to remove scrollbars in console windows C++

后端 未结 2 1684
我寻月下人不归
我寻月下人不归 2020-12-30 12:10

I have been checking out some Rogue like games (Larn, Rogue, etc) that are written in C and C++, and I have noticed that they do not have the scrollbars to the right of the

2条回答
  •  半阙折子戏
    2020-12-30 12:55

    These guys show how to do it:

    #include 
    #include 
    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;
    }
    

提交回复
热议问题