我正在使用 SetConsoleTextAttribute API(具体来说是 Delphi),无论如何我在任何地方都找不到可用颜色的列表?谁能帮我吗
2 回答
There a 4 Bits used for the foreground color
FOREGROUND_BLUE; //1
FOREGROUND_GREEN; //2
FOREGROUND_RED; //4
FOREGROUND_INTENSITY; //8
which will give 16 possible colors. (0-15)
The next 4 bits are used for background color with the same scheme
See this. Colors are formed by ORing different constants. For instance:
An application can combine the foreground and background constants to achieve different colors. For example, the following combination results in bright cyan text on a blue background.
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY | BACKGROUND_BLUE
For more Turbo/Borland Pascal CRTish implementations of such, see this. The colors available in the Windows console via SetConsoleTextAttribute work out roughly to be the same ones as the CRT unit, so any more relevant details can be found there.