program Test;
{$APPTYPE CONSOLE}
uses Windows, SysUtils;
var
ConHandle : THandle; //
Handle to console window
Coord : TCoord; // To store/set screen position
MaxX, MaxY : Word; // To store max window size
NOAW : LongInt;
//-----------------------------------------
// Get
handle to console output
//-----------------------------------------
function GetConOutputHandle : THandle;
begin
Result := GetStdHandle(STD_OUTPUT_HANDLE)
end;
//-----------------------------------------
// Position cursor to X, Y
//-----------------------------------------
procedure GotoXY(X, Y : Word);
begin
Coord.X := X; Coord.Y := Y;
SetConsoleCursorPosition(ConHandle, Coord);
end;
{
procedure
Cls;
begin
Coord.X := 0; Coord.Y := 0;
FillConsoleOutputCharacter(ConHandle, ' ', MaxX * MaxY, Coord, NOAW);
GotoXY(0, 0);
end
}
procedure Init;
begin
// Get console output
handle
ConHandle := GetConOutputHandle;
// Get max window size
Coord := GetLargestConsoleWindowSize(ConHandle);
MaxX := Coord.X;
MaxY := Coord.Y;
end;
var i: byte;
begin
// Initialize global variables
Init;
//
Cls;
Coord.X := 0; Coord.Y := 0;
// Console Code Page
API is not supported under Win95 - only GetConsoleCP
Writeln('Console Code Page = ', GetConsoleCP);
Writeln('Max X=', MaxX,' Max Y=', MaxY);
Writeln('----------------------------------------------------');
writeln;
write('Teste... ');
for i:=1 to 100 do
begin
gotoxy(12,4);
write(i, ' %');
sleep(100);
end;
writeln;
writeln('press ENTER to close Prg.')
Readln;
end.