Mega Code Archive

 
Categories / Delphi / Examples
 

How to Use a Console in non console Applications

Title: How to Use a Console in non-console Applications procedure TForm1.Button1Click(Sender: TObject); var s: string; begin AllocConsole; try // Change color attributes SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_BLUE OR FOREGROUND_GREEN or BACKGROUND_RED ); Write('Type here your words and press ENTER: '); Readln(s); ShowMessage(Format('You typed: "%s"', [s])); finally FreeConsole; end; end;