首页 > 其他 > 详细

函数SetTextColor()设置方法浅析

时间:2015-03-05 12:56:55      阅读:432      评论:0      收藏:0      [点我收藏+]
函数SetTextColor声明如下:
WINGDIAPI COLORREF WINAPI SetTextColor(__in HDC hdc, __in COLORREF color);
hdc是当前设备的句柄。
color是设置当前设备字符输出颜色。
 
调用这个函数的例子如下:
#001 //
#002 //界面显示输出.
#006 void CCaiWinMsg::OnDraw(HDC hDC)
#007 {
#008  //
#009  std::wstring strShow(_T("C++窗口类的实现,2007-08-13"));
#010  TextOut(hDC,10,10,strShow.c_str(),(int)strShow.length());    
#011 
#012  //设置输出字符串的颜色.
#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 }
 
13行设置字符的颜色为红色。
16行设置字符的颜色为绿色。
19行设置字符的颜色为蓝色。
23行恢复原来的颜色,这个一定要记得做,否则后面显示会出错。

 

技术分享

函数SetTextColor()设置方法浅析

原文:http://blog.csdn.net/ghevinn/article/details/44080527

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!