POV-Ray : Newsgroups : povray.off-topic : Colour consoles : Re: Colour consoles Server Time
7 Sep 2024 09:24:09 EDT (-0400)
  Re: Colour consoles  
From: Mike Raiford
Date: 20 Aug 2008 13:42:18
Message: <48ac577a$1@news.povray.org>
Invisible wrote:

> I wonder... Is there some function call in the Win32 API that can 
> actually change the colour of the text in a console window? Or is that 
> impossible? Does anybody here know the Win32 API well enough to know the 
> answer?

Yes, there is:

#include "stdio.h"
#include "windows.h"

void main()
{
     HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
     SetConsoleTextAttribute(hCon, 0x0C);
     printf("Hello in red");
     SetConsoleTextAttribute(hCon, 0x09);
     printf(" and in blue\n");
     getchar();
}

Detailed here:
http://msdn.microsoft.com/en-us/library/ms686047.aspx


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.