Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
829 views
in Technique[技术] by (71.8m points)

console - How do I hide a scrollbar in fullscreen C++ window while being still able to scroll up/down with computer mouse?

I was creating a C++ game like console program where you can input lots of different commands and it will preform an action but I want it to be full screen and without scrollbar but still being possible to scroll up and down because some outputs are too long. So basically all I'm asking is to remove scrollbar on the right but keep the functionality.

Here's a simplified code:

#include <iostream>
#include <Windows.h>

using namespace std;

string a;

// i coppied this part from stack overflow don't dgudge me im new to this.
void remove_scrollbar(){    
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO info;
    GetConsoleScreenBufferInfo(handle, &info);
    COORD new_size = 
    {
        info.srWindow.Right - info.srWindow.Left + 1,
        info.srWindow.Bottom - info.srWindow.Top + 1
    };
    SetConsoleScreenBufferSize(handle, new_size);
}

int main(){
    remove_scrollbar();
    cout << "Input Command : ";
    cin >> a;
    cout << endl;
    if (a=="1"){
        for (int i=1; i < 31; i++){
            cout << "a lot of stuff that dont fit in one screen" << endl;
        }
    cout << "i want to scroll up now but i can't!" << endl;
    system("pause");
    }
    return 0;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...