winApi一日一练之 SetTextColor (和Textout)函数

来源:互联网 发布:网络推广人员工资高吗 编辑:程序博客网 时间:2024/05/01 01:33
记得先要#include <iostream>////声明字符串std::wstring strShow(_T("Test String"));hdc = BeginPaint(hWnd, &ps);TextOut(hdc,10,30,strShow.c_str(),(int)strShow.length());SetTextColor(hdc,RGB(0,255,0));TextOut(hdc,10,60,strShow.c_str(),(int)strShow.length());SetTextColor(hdc,RGB(12,56,89));TextOut(hdc,10,80,strShow.c_str(),(int)strShow.length());// TODO: 在此添加任意绘图代码...EndPaint(hWnd, &ps);



drawText 调用示例:

////声明字符串std::wstring strShow(_T("Test String"));////声明一个矩形RECT rcText;rcText.left = 10;rcText.right=100;rcText.top = 20;hdc = BeginPaint(hWnd, &ps);DrawText(hdc,strShow.c_str(),(int)strShow.length(),&rcText,DT_LEFT|DT_SINGLELINE|DT_END_ELLIPSIS);SetTextColor(hdc,RGB(0,255,0));rcText.left = 10;rcText.top = 40;DrawText(hdc,strShow.c_str(),(int)strShow.length(),&rcText,DT_LEFT|DT_SINGLELINE|DT_END_ELLIPSIS);rcText.left = 10;rcText.top = 60;SetTextColor(hdc,RGB(12,56,89));DrawText(hdc,strShow.c_str(),(int)strShow.length(),&rcText,DT_LEFT|DT_SINGLELINE|DT_END_ELLIPSIS);// TODO: 在此添加任意绘图代码...EndPaint(hWnd, &ps);


原创粉丝点击