![]() |
|
||||||||||||||
| | 网站首页 | 数据库教程 | web编程 | 服务器 | 程序设计 | | ||
|
||
|
||||||
| Windows API一日一练(23)SetTextColor函数 | ||||||
作者:佚名 文章来源:不详 点击数: 更新时间:2007-9-12 ![]() |
||||||
|
世界是多姿多彩的,色彩是不可以缺少的。
函数SetTextColor声明如下: WINGDIAPI COLORREF WINAPI SetTextColor(__in HDC hdc, __in COLORREF color); hdc是当前设备的句柄。 color是设置当前设备字符输出颜色。 调用这个函数的例子如下: #001 // #002 //界面显示输出. #003 // #004 //蔡军生 2007/08/13 QQ:9073204 深圳 #005 // #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行恢复原来的颜色,这个一定要记得做,否则后面显示会出错。
本文来源:http://blog.csdn.net/caimouse/archive/2007/08/26/1759828.aspx
|
||||||
| 文章录入:admin 责任编辑:admin | ||||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | ||||||
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 网站地图 | 管理登录 | | |||
|