Created
March 20, 2019 08:57
-
-
Save iamandrewluca/5ebd201dfb557844e92e7b59631244ba to your computer and use it in GitHub Desktop.
Citeva functii din conio.h create cu ajutorul bibliotecii windows.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
// ShowCursor(true) afiseaza cursorul | |
// ShowCursor(false) nu afiseaza cursorul | |
void ShowCursor(bool show) | |
{ | |
HANDLE hConsoleOutput; | |
CONSOLE_CURSOR_INFO structCursorInfo; | |
hConsoleOutput = GetStdHandle( STD_OUTPUT_HANDLE ); | |
GetConsoleCursorInfo( hConsoleOutput, &structCursorInfo ); | |
structCursorInfo.bVisible = show; | |
SetConsoleCursorInfo( hConsoleOutput, &structCursorInfo ); | |
} | |
// clrscr() curata ecranul | |
void clrscr() | |
{ | |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
COORD coord = {0, 0}; | |
DWORD count; | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(hStdOut, &csbi); | |
FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count); | |
SetConsoleCursorPosition(hStdOut, coord); | |
} | |
// gotoxy(x, y) muta cursorul la coordonatele x, y | |
void gotoxy (int x, int y) | |
{ | |
COORD coord; | |
coord.X = x; coord.Y = y; | |
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); | |
} | |
// textcolor(color) schimba culoarea textului | |
void textcolor (int text) | |
{ | |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(hStdOut, &csbi); | |
WORD bg = csbi.wAttributes & 0xF0; | |
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), text | bg); | |
} | |
// textbackground(color) schimba culoarea backgroundului | |
void textbackground (int back) | |
{ | |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(hStdOut, &csbi); | |
WORD fg = csbi.wAttributes & 0x0F; | |
SetConsoleTextAttribute(hStdOut, (back << 4) | fg); | |
} | |
// wherex() returneaza pozitia x a cursorului | |
int wherex() | |
{ | |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(hStdOut, &csbi); | |
return csbi.dwCursorPosition.X; | |
} | |
// wherey() returneaza pozitia y a cursorului | |
int wherey() | |
{ | |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
GetConsoleScreenBufferInfo(hStdOut, &csbi); | |
return csbi.dwCursorPosition.Y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment