函数SetTextColor()设置方法浅析

前端之家收集整理的这篇文章主要介绍了函数SetTextColor()设置方法浅析前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
函数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⑴3"));
#010  TextOut(hDC,10,strShow.c_str(),(int)strShow.length());    
#011 
#012  //设置输出字符串的色彩.
#013  COLORREF crOld = SetTextColor(hDC,RGB(255,0));
#014  TextOut(hDC,30,(int)strShow.length());
#015 
#016  SetTextColor(hDC,RGB(0,255,51); font-family:Arial; font-size:14px; line-height:26px; margin:0cm 0cm 0pt 36pt"> #017  TextOut(hDC,50,51); font-family:Arial; font-size:14px; line-height:26px; margin:0cm 0cm 0pt 36pt"> #018 
#019  SetTextColor(hDC,255));
#020  TextOut(hDC,70,51); font-family:Arial; font-size:14px; line-height:26px; margin:0cm 0cm 0pt 36pt"> #021 
#022  //
#023  SetTextColor(hDC,crOld);
#024 }
13行设置字符的色彩为红色。
16行设置字符的色彩为绿色。
19行设置字符的色彩为蓝色。
23行恢复原来的色彩,这个1定要记得做,否则后面显示会出错。

 

猜你在找的PHP相关文章