Programming C# C++ (7) Delphi (617) .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280) Java (8) JavaScript (31) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
New related comments Number of comments in the last 48 hoursThe meaning of Runtime Error 217 1 new comments
|
Clearing a console window screen
2 comments. Current rating: (1 votes). Leave comments and/ or rate it.
Question:
How do I clear a console screen?
Answer:
Call the function ClearConsoleScreen as shown below.
 | |  | | function ClearConsoleScreen: boolean;
const
BUFSIZE = 80*25;
var
Han,Dummy: LongWord;
buf: string;
coord: TCoord;
begin
Result := false;
Han := GetStdHandle(STD_OUTPUT_HANDLE);
if Han <> INVALID_HANDLE_VALUE then
begin
if SetConsoleTextAttribute(han, FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_BLUE) then
begin
SetLength(buf,BUFSIZE);
FillChar(buf, length(buf),' ');
if WriteConsole(han,PChar(buf),BUFSIZE,Dummy,nil) then
begin
coord.X := 0;
coord.Y := 0;
if SetConsoleCursorPosition(han,coord) then
Result := true;
end;
end;
end;
end; | |  | |  |
Comments:
|
[hidden] from Germany
|
 |
|
|
Wich units I need for that solution?
|
|
dineshimed@gmail.com from India
|
|
|
|
I have used this function to clear the console screen. But it is not working.
When i am calling this function it just terminating the application.So Please tell me how can i use this function successfully
|
|