functionSetTextColorThe statement reads as follows:wingdiapi colorref WINAPI settextcolor (__in hdc hdc, __in COLORREF color);
HDCis a handle to the current device.
Coloris to set the current device character output color. An example of calling this function is as follows:#001//#002//Interface Display Output.#006 void Ccaiwinmsg::ondraw (hdc hdc)#007 {#008//#009 std::wstring strshow (_t ("C + +implementation of the window class, 2007-08-13 "));#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}Section -line sets the color of the character to red. Section -line sets the color of the character to green. Section +line sets the color of the character to Blue. Section atline to restore the original color, this must remember to do, or the subsequent display will be wrong.
Simple analysis of the function SetTextColor () Setting method