Other Software > Developer's Corner
Programmatically effecting console font colors and size in Delphi console app
kyrathaba:
I've Googled this quite a bit and just can't find what I'm looking for; I'm seeking a way to programmatically alter the font color and size in a Delphi console mode application. I've changed these settings manually on my computer by right-clicking the titlebar of a running Delphi console app, then changing these from the context menu that pops up. In .NET, it's pretty easy to alter foreground color, background color, etc. But I'm just not finding any similar code snippets for Delphi. Can anyone help?
mouser:
no idea, sorry.
app103:
For colors, try this:
--- Code: Delphi ---// This will cause text to be red: SetConsoleTextAttribute(GetStdHandle( STD_OUTPUT_HANDLE), FOREGROUND_RED or FOREGROUND_INTENSITY); // This sets it to white: SetConsoleTextAttribute(GetStdHandle( STD_OUTPUT_HANDLE), FOREGROUND_RED or FOREGROUND_GREEN or FOREGROUND_BLUE);
Example:
http://coding.derkeiler.com/Archive/Delphi/alt.comp.lang.borland-delphi/2003-12/0303.html
kyrathaba:
Thanks, app, that worked well. Now if I can just find something to programmatically effect the console font size, I'm in business. Looks like WinAPI is the place to search...
app103:
You could change the font used in the whole console window with SetCurrentConsoleFontEx, but it only works on Vista, Server 2008, and Win7.
I haven't found anything about changing text size, unfortunately.
Navigation
[0] Message Index
[#] Next page
Go to full version