The world is colorful and colors are indispensable. In software development, different character colors are often used to differentiate different data types. For example, a serious warning means that red is used. Of course, this is the same principle as the traffic lights. The most fundamental reason is human choice of nature. After all, the human eyes make different choices for different colors. Because the red light wave has good penetration, it forms a red warning signal. It is also strange to say that no matter what color the human body is, the blood flowing must be red. In software development, the color of output characters must be in line with the current human habits. Do not deviate from it; otherwise, it is not a "people-oriented" scientific concept, if the software is not "people-oriented", it is not used by customers. In Windows, Microsoft chose a blue-based color scheme. Compared with Win2000, the dark blue XP interface makes people feel refreshed and attracts young people deeply. When we see anti-virus software in China, many of them use green as the tone. Green represents the Security choice. It can be seen that color is very important in the software field, and different colors should be selected for different customers. For example, SAP software is highlighted in yellow.
The settextcolor function declaration is as follows:
Wingdiapi colorref winapi settextcolor (_ in HDC, _ in colorref color );
HDCIs the handle of the current device.
ColorIs to set the current device character output color.
An example of calling this function is as follows:
#001 //
#002 // The output is displayed on the interface.
#003 //
#004 // Cai junsheng 2007/08/13 QQ: 9073204 Shenzhen
#005 //
#006 void ccaiwinmsg: ondraw (HDC)
#007 {
#008 //
#009 STD: wstring strshow (_ T ("Implementation of C ++ window class "));
#010 textout (HDC, 10, 10, strshow. c_str (), (INT) strshow. Length ());
#011
#012 // set the color of the output string.
#013 colorref crold = settextcolor (HDC, RGB (255, 0, 0 ));
#014 textout (HDC, 10, 30, strshow. c_str (), (INT) strshow. Length ());
#015
#016 settextcolor (HDC, RGB (0,255, 0 ));
#017 textout (HDC, 10, 50, strshow. c_str (), (INT) strshow. Length ());
#018
#019 settextcolor (HDC, RGB (0, 0, 255 ));
#020 textout (HDC, 10, 70, strshow. c_str (), (INT) strshow. Length ());
#021
#022 //
#023 settextcolor (HDC, crold );
#024}
Line 3 sets the Character Color to red.
Line 3 sets the Character Color to green.
Line 3 sets the Character Color to blue.
You must remember to restore the original color of the first line. Otherwise, an error will occur in the subsequent display.
Download(63.38 KB)