Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Citeva functii din conio.h create cu ajutorul bibliotecii windows.h
#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
You can’t perform that action at this time.