Removing Scroll Bar properly?

I decided to remove the scroll bar from the console, and I want to know if this is a safe way to remove the scroll bar without any conflicts. Although I know I do not get any errors when I debug this, but is this proper?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <Windows.h>

#ifdef max
#undef max
#endif

using std::cin;
using std::endl;
using std::cerr;

int main(){
	SetConsoleTitle(L"Serial Key");

	try{
		HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_SCREEN_BUFFER_INFO csbi;

		GetConsoleScreenBufferInfo(console, &csbi);
		COORD scrollbar = {
			csbi.srWindow.Right - csbi.srWindow.Left + 1,
			csbi.srWindow.Bottom - csbi.srWindow.Top + 1
		};

		if(console == 0){
			throw 0;
		}else{
			SetConsoleScreenBufferSize(console, scrollbar);
		}
	}catch(...){
		cerr<<"Error removing scrollbar"<<endl;
	}

	cin.sync(),
		cin.ignore(
		std::numeric_limits
		<std::streamsize>::max()
		);
	return 0;
}
Last edited on
Topic archived. No new replies allowed.