Registriert seit: 21. Jan 2004
Ort: Bei Hamburg
308 Beiträge
Delphi XE2 Professional
|
Re: Console Maus und TextCursor ausblenden
21. Nov 2007, 01:18
Moin moin,
schau dir mal die funktionen GetConsoleCursorInfo und SetConsoleCursorInfo an...
Anbei mal zum testen:
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows;
const
FG_STANDARD = $0007;
FG_BLACK = $0000;
FG_DARKBLUE = $0001;
FG_DARKGREEN = $0002;
FG_WEIRDBLUE = $0003;
FG_RED = $0004;
FG_ROSA = $0005;
FG_BROWN = $0006;
FG_LITEGRAY = $0007;
FG_DARKGRAY = $0008;
FG_BLUE = $0009;
FG_GREEN = $000A;
FG_LITEBLUE = $000B;
FG_LITERED = $000C;
FG_LITEROSA = $000D;
FG_YELLOW = $000E;
FG_WHITE = $000F;
BG_STANDARD = $0000;
BG_BLACK = $0000;
BG_DARKBLUE = $0010;
BG_DKGREEN = $0020;
BG_WEIRDBLUE = $0030;
BG_RED = $0040;
BG_ROSA = $0050;
BG_BROWN = $0060;
BG_LITEGRAY = $0070;
BG_DARKGRAY = $0080;
BG_BLUE = $0090;
BG_GREEN = $00A0;
BG_LITEBLUE = $00B0;
BG_LITERED = $00C0;
BG_LITEROSA = $00D0;
BG_YELLOW = $00E0;
BG_WHITE = $00F0;
var
SOHandle : Cardinal;
szText, szZahl : PChar;
coord : TCoord;
lpNumberOfCharsWritten : Cardinal;
fgColor, bgColor: Word;
cci : TConsoleCursorInfo;
i: Integer;
InputRec: TInputRecord;
begin
{ TODO -oUser -cConsole Main : Hier Code einfügen }
SOHandle := GetStdHandle(STD_OUTPUT_HANDLE);
szText := ' Hello World...!';
fgColor := FG_STANDARD;
bgColor := BG_STANDARD;
coord.X := 25;
coord.Y := 0;
for i:=0 to 15 do begin
if i=0 then
fgColor := FG_STANDARD
else
fgColor := i;
bgColor := i*10;
WriteConsoleOutputCharacter(SOHandle, szText, length(szText), coord, lpNumberOfCharsWritten);
szZahl := PChar(IntToStr(i)+'.');
WriteConsoleOutputCharacter(SOHandle, szZahl, length(szZahl), coord, lpNumberOfCharsWritten);
FillConsoleOutputAttribute (SOHandle, fgColor or bgColor, length(szText), coord, lpNumberOfCharsWritten);
Inc(coord.Y);
Inc(coord.X);
end;
Inc(coord.Y);
// Cursor verstecken
GetConsoleCursorInfo(SOHandle, cci);
cci.bVisible:= False;
SetConsoleCursorInfo(SOHandle, cci);
readln;
end.
|
|
Zitat
|