Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Farbiger Text in einer Konsolenanwendung (https://www.delphipraxis.net/63421-farbiger-text-einer-konsolenanwendung.html)

cruso 18. Feb 2006 16:18


Farbiger Text in einer Konsolenanwendung
 
Hi!

Wisst ihr wie man einzelne Textzeilen in einer Konsolenanwendung einfärben kann? Also die Textausgabe soll dann in einer bestimmten Farbe erfolgen (z.B. Rot oder Grün...).


MfG
Cruso

turboPASCAL 18. Feb 2006 17:21

Re: Farbiger Text in einer Konsolenanwendung
 
Delphi-Quellcode:
program Farbtest;

{$APPTYPE CONSOLE}

uses
  Windows;

var
  hConsoleInput,
  hConsoleOutput: THandle;

BEGIN
  hConsoleOutput := GetStdHandle(STD_OUTPUT_HANDLE);
  hConsoleInput := GetStdHandle(STD_INPUT_HANDLE);

 
  SetConsoleTextAttribute(hConsoleOutput, 5);
  Writeln('Hallo');
  SetConsoleTextAttribute(hConsoleOutput, 2);
  Writeln('Hallo nochmal');

  SetConsoleTextAttribute(hConsoleOutput, 15 + 5);
  writeln('Und noch mal hallo');

  SetConsoleTextAttribute(hConsoleOutput, 7);
  writeln('Entertaste zum beenden.');
  readln;
END.
Hier im Forum suchenSetConsoleTextAttribute Delphi-Referenz durchsuchenSetConsoleTextAttribute

//Edit: zwei mal 'en Semikolon vergessen...

Klaus01 18. Feb 2006 18:47

Re: Farbiger Text in einer Konsolenanwendung
 
Liste der Anhänge anzeigen (Anzahl: 1)
oder mit der crt32.pas

Grüße
Klaus


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:24 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz