This repository was archived by the owner on Feb 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyconio.cpp
More file actions
65 lines (60 loc) · 1.75 KB
/
myconio.cpp
File metadata and controls
65 lines (60 loc) · 1.75 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
#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include "myconio.h"
COORD coord={0,0}; // this is global variable
//center of axis is set to the top left cornor of the screen
void gotoxy(int x,int y)
{
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void setColor(int ForgC)
{
WORD wColor;
//We will need this handle to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
//We use csbi for the wAttributes word.
if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
{
//Mask out all but the background attribute, and add in the forgournd color
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
return;
}
void setColorAndBackground(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
return;
}
void setWindow(int topx, int topy, int bottomx, int bottomy, int forgc, int backc){
int x,y;
gotoxy(topx,topy);
setColorAndBackground(forgc,backc);
printf("É");
for(x=topx+1;x<bottomx;x++)
printf("Í");
printf("»");
for(y=topy+1;y<bottomy;y++){
gotoxy(topx,y);
printf("º");
for(x=topx+1;x<bottomx;x++){
gotoxy(x,y);
printf(" ");
//setColor(8);
//printf("°");
//setColor(forgc);
}
gotoxy(bottomx,y);
printf("º");
}
gotoxy(topx,bottomy);
printf("È");
for(x=topx+1;x<bottomx;x++)
printf("Í");
printf("¼");
}