-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsoletext.cpp
More file actions
97 lines (79 loc) · 2.03 KB
/
consoletext.cpp
File metadata and controls
97 lines (79 loc) · 2.03 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "consoletext.h"
#include <conio.h>
#include <Windows.h>
void SetWindowSize(SHORT width, SHORT height)
{
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SMALL_RECT WindowSize;
WindowSize.Top = 0;
WindowSize.Left = 0;
WindowSize.Right = width;
WindowSize.Bottom = height;
SetConsoleWindowInfo(hStdout, 1, &WindowSize);
}
void SetScreenBufferSize(SHORT width, SHORT height)
{
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
COORD NewSize;
NewSize.X = width;
NewSize.Y = height;
SetConsoleScreenBufferSize(hStdout, NewSize);
}
void DisableResizeWindow()
{
HWND hWnd = GetConsoleWindow();
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_SIZEBOX);
}
void DisableCtrButton(bool Close, bool Min, bool Max)
{
HWND hWnd = GetConsoleWindow();
HMENU hMenu = GetSystemMenu(hWnd, false);
if (Close == 1)
{
DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
}
if (Min == 1)
{
DeleteMenu(hMenu, SC_MINIMIZE, MF_BYCOMMAND);
}
if (Max == 1)
{
DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND);
}
}
void SetBGColor(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
color <<= 4;
wAttributes &= 0xff0f;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}
void clrscr(void)
{
system("cls");
}
void gotoxy(short x,short y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = {x, y};
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput , Cursor_an_Pos);
}
void SetColor(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
wAttributes &= 0xfff0;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}