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=

随便看看

oracle的序列号(sequence)

Oracle的自动递增列应使用序列号。在初始化阶段,需要手动创建序列,然后在插入序列时手动读取分配给相关字段(如ID)的序列的nextval。这很麻烦。但是,这对于SQL Server来说不是问题,可以获得。oracle的序列号也有缓存。默认情况下,一次生成20个。如果没有用完,它们可能会丢失,这可能会导致ID不一致。此外,有时这可能会引起误解。例如,我有一...

jquery跨域请求数据

Jquery跨域请求数据Jquery跨请求数据。事实上,这很容易。请遵循以下步骤:首先,编写js,通过get获取远程数据。请注意,回调参数应添加在链接之后,这意味着将回调函数地址传输到远程页面。',{params},函数cb{alert;alert;},'json');第二:编写处理程序。publicvoidProcessRequest{context.Re...

js学习-es6实现枚举

最近,我大部分时间都在写dart,突然使用了js。我发现js不能直接声明枚举。目录枚举功能对象冻结()符号实现反映了不可更改值的唯一性。请注意,枚举特性枚举值不能重复,也不能修改。Switchcase可以直接判断对象。冻结()对象。方法可以冻结对象。无法更改实现constEnumSex=Object。冷冻枚举性别。人=1;安慰日志;//符号(男性)表示值co...

Google Drive 里的文件下载的方法

Google Drive不提供创建直接下载链接的选项,但您可以通过更改链接形式在本地保存共享内容。例如,通过Google Drive共享的文件链接是:https://drive.google.com/file/d/FILE_ID/edit?usp=sharing如果您将其更改为以下修改版本,然后通过浏览器打开,则将直接下载该文件:https://drive....

Makefile系列之三 : 变量

第二个语法是针对于make命令行带入的变量,或是系统环境变量。...

文件(夹)对比利器WinMerge

IDE中自带的svn功能较弱,还好有winMerge弥补了它的缺陷,它可以对比文件、文件夹,使用起来还是较为方便,界面也是中文。“开始”菜单,弹出对话框中选择需要进行对比的文件夹或文件然后选择一个过滤器,它自带就可以过滤掉svn目录,如需要过滤其它一些指定的目录,则需要自己修改过滤器的规则了,也很简单。...