Simple analysis of the function SetTextColor () Setting method

Source: Internet
Author: User
Tags textout

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.