CBrush,CFont,CPen
2011-04-20 21:19 Clingingboy 阅读(1453) 评论(0) 编辑 收藏 举报
一.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));
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);
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2007-04-20 .net3.5正统分页控件来了(ListView和DataPager)
2007-04-20 Visual Studio Code Name 'Orcas' Express Editions