Setting text-color with RGB i a Win32 Console Application

Hi there,

I'm trying to adjust the text-color in a Win32 Console Application. I need to set the text-color with RGB, to adjust it to more than two different nuances.

I've googled a bit and found a CDC-class from the afxwin.h library, but it won't compile.

1
2
3
CDC testColor;

testColor.SetTextColor(RGB(0,0,255));


I get this error, when I compile the code:
Error 1 error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d] c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\afx.h 24


Am I doing something wrong or is there another way to do this?
Last edited on
CDC is an MFC class and is useless outside of a Windows GUI program

You are writing a console program.
You need the SetConsoleTextAttribute function
Ah, that explains it.

Is it possible to set RGB-colors with the SetConsoleTextAttribute function or am I stuck with the pre-defined colors?
stuck with predefined colours
Topic archived. No new replies allowed.