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
| unit miniCrt;
{ delphi.developpez.com/faq/?page=applisconsole
logiterre.org/langages_de_programmation/pascal/faq-delphi-pascal.html
www.delphipraxis.net/705144-post2.html }
interface
procedure Title(const s: string);
procedure Color(const caractere, fond: byte);
procedure ClrScr;
procedure GotoXY(const x, y: integer);
procedure CursorOff;
procedure CursorOn;
{$I Couleurs.inc}
implementation
uses SysUtils, Windows;
procedure Title(const s: string);
begin
SetConsoleTitle(Pchar(s));
end;
procedure Color(const caractere, fond: byte);
begin
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), caractere + (fond * 16));
end;
procedure ClrScr;
var
pos: TCoord;
h: THandle;
info: TConsoleScreenBufferInfo;
nbr: LongWord;
nbr_ecrits: LongWord;
begin
pos.x := 0;
pos.y := 0;
h := GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(h, info);
nbr := info.dwSize.x * info.dwSize.y;
FillConsoleOutputCharacter(h, #32, nbr, pos, nbr_ecrits);
FillConsoleOutputAttribute(h, info.wAttributes, nbr, pos, nbr_ecrits);
SetConsoleCursorPosition(h, pos);
end;
procedure GotoXY(const x, y: integer);
var
pos: TCoord;
begin
pos.x := x - 1;
pos.y := y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
end;
procedure CursorOff;
var
cci : TConsoleCursorInfo;
begin
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), cci);
cci.bVisible := FALSE;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), cci);
end;
procedure CursorOn;
var
cci : TConsoleCursorInfo;
begin
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), cci);
cci.bVisible := TRUE;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), cci);
end;
end. |
Partager