-
Notifications
You must be signed in to change notification settings - Fork 1
/
Graphics_Console.cpp
68 lines (54 loc) · 2.15 KB
/
Graphics_Console.cpp
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
#include "Graphics_Console.h"
void GotoXY(int x,int y,HANDLE screen)
{
COORD position = { x, y };
SetConsoleCursorPosition(screen,position);
}
//===================================================================================
// NAME: TextColor
//===================================================================================
// DESCRIPTION: Function to change text and backgorund colors of DOS console.
//===================================================================================
void TextColor(int frontcolor,int backgroundcolor,HANDLE screen)
{
unsigned short color_attribute;
color_attribute = backgroundcolor;
color_attribute = _rotl(color_attribute,4) | frontcolor;
SetConsoleTextAttribute(screen,color_attribute);
}
//===================================================================================
// NAME: SetScreenSize
//===================================================================================
// DESCRIPTION: Fix conosle dimensions.
//===================================================================================
void SetScreenSize(HANDLE hConsole)
{
//HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SMALL_RECT myWindow;
CONSOLE_SCREEN_BUFFER_INFO screenBufferInformation;
int err=1;
COORD c;
GetConsoleScreenBufferInfo(hConsole,&screenBufferInformation);
myWindow.Left = 0;
myWindow.Top = 0;
//myWindow.Right=((screenBufferInformation.dwMaximumWindowSize.X)/2)-1;
//myWindow.Bottom=((screenBufferInformation.dwMaximumWindowSize.Y)/2)-1;
myWindow.Right=DX-1;
myWindow.Bottom=DY-1;
err=SetConsoleWindowInfo(hConsole,TRUE,&myWindow);
c.X=DX;
c.Y=DY;
// c.X=((screenBufferInformation.dwMaximumWindowSize.X)/2);
// c.Y=((screenBufferInformation.dwMaximumWindowSize.Y)/2);
err=SetConsoleScreenBufferSize(hConsole,c);
}
void InitScreen(HANDLE hConsole)
{
CONSOLE_CURSOR_INFO ConCurInf;
SetScreenSize(hConsole);
// ------------------------------------------------------------------------------
//Hide the mouse
ConCurInf.dwSize = 10;
ConCurInf.bVisible = FALSE;
SetConsoleCursorInfo(hConsole,&ConCurInf);
}