CBrush,CFont,CPen

摘要:
一.CBrush创建方法1.CreateSysColorBrushCreatesabrushthatisthedefaultsystemcolor.CBrushbrush;brush.CreateSysColorBrush(COLOR_BTNFACE);2.CreateSolidBrushInitializesabrushwiththespecifiedsolidcolor.CBrushbrush
一.CBrush创建方法

1.CreateSysColorBrush

Creates a brush that is the default system color.

CBrush brush;
brush.CreateSysColorBrush(COLOR_BTNFACE);

2.CreateSolidBrush
Initializes a brush with the specified solid color.

CBrush brush;
brush.CreateSolidBrush(RGB(255,0,0));

3.CreatePatternBrush(ImageBrush)
Initializes a brush with a pattern specified by a bitmap.

WORD HatchBits[8] = { 0x11, 0x22, 0x44, 0x88, 0x11,
   0x22, 0x44, 0x88 };

// Use the bit pattern to create a bitmap.

CBitmap bm;
bm.CreateBitmap(8,8,1,1, HatchBits);

// Create a pattern brush from the bitmap.

CBrush brush;
brush.CreatePatternBrush(&bm);

4.CreateHatchBrush(阴影图案)
Initializes a brush with the specified hatched pattern and color.

CBrush brush;
brush.CreateHatchBrush(HS_BDIAGONAL, RGB(255, 0, 0));

image

5.CreateBrushIndirect(传入一个结构体)

LOGBRUSH logBrush;
logBrush.lbStyle = BS_HATCHED;
logBrush.lbColor = RGB(0, 192, 192);
logBrush.lbHatch = HS_CROSS;

// Declare an uninitialized CBrush ...

CBrush brush;
// ... and initialize it with the LOGBRUSH.

brush.CreateBrushIndirect(&logBrush);
二.CFont创建方法

1.CreatePointFont

This function provides a simple way to create a font of a specified typeface and point size.

m_pCFont = new CFont();
m_pCFont->CreatePointFont(90,_T("Tahoma"));

2.CreateFontIndirect

Initializes a CFont object with the characteristics given in a LOGFONT structure.

m_pCFont = new CFont();
m_pCFont->CreatePointFont(90,_T("Tahoma"));

// Initialize font
LOGFONT    LogFont;
m_pCFont->GetLogFont(&LogFont);
LogFont.lfWeight = FW_HEAVY;
m_pCFont->DeleteObject();
m_pCFont->CreateFontIndirect(&LogFont);
三.CPen使用方法

1.CreatePen

CPen myPen1, myPen2;

// Create a solid red pen of width 2.

myPen1.CreatePen(PS_SOLID, 2, RGB(255,0,0));

// Create a geometric pen.

LOGBRUSH logBrush;
logBrush.lbStyle = BS_SOLID;
logBrush.lbColor = RGB(0,255,0);
myPen2.CreatePen(PS_DOT|PS_GEOMETRIC|PS_ENDCAP_ROUND, 2, &logBrush);  

2.CreatePenIndirect

LOGPEN logpen;
CPen   cMyPen;

// Get the LOGPEN of an existing pen.

penExisting.GetLogPen(&logpen);

// Change the color to red and the width to 2.

logpen.lopnWidth.x = 2;
logpen.lopnColor = RGB(255, 0, 0);

// Create my pen using the new settings.

cMyPen.CreatePenIndirect(&logpen);

免责声明:文章转载自《CBrush,CFont,CPen》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇词语相似度计算【ZZ】Visual C++ 6.0 精简安装版(支持VA、ICC 等等安装)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

Uncaught (in promise) Error: Network Error at createError(axios跨域问题)

axios请求到了数据但then返回不到数据,这是由于vue前端访问地址出现的跨域问题。...

Ansible入门

自动操作和维护常识操作和维护工作系统安装物理机、虚拟机包安装、配置、服务启动批处理操作程序发布监控操作和维护级别OS配置物理机PXE、,Cobbler(选择多版本操作系统)虚拟机ImageTemplates配置木偶(ruby)saltstack(python)检查cfengine...

uniapp中组件属性设置不生效的解决方案

例如,每次将滚动视图组件的滚动顶部属性值设置为0时,只能第一次成功返回顶部。组件中滚动顶部的实际值更改后,其绑定属性不会同时更改。...

mini.DataGrid使用说明

√√√ ajaxOptionsObjectajax配置对象。√√√ idFieldString是行数据的唯一字段。设置为“client”之后,客户端将排序√√√√ totalCountNumber记录总数√√√ defaultColumnWidthNumber默认列宽100√√√√ showColumnsBoolean显示标头true√√√√ showPag...

解决Maven无法下载fastdfs-client-java依赖,Dependency 'org.csource:fastdfs-client-java:1.27-SNAPSHOT' not found.

然后,您成功地将fastdfs客户端java打包到本地Maven仓库,更新项目Maven,pom.xml文件将不会找不到fastdfs客户机java依赖项。...

Delete from join 用法

delete(别名)fromtblA(别名)leftjointblb(别名)on。。。...