19,468
社区成员
发帖
与我相关
我的任务
分享
CBrush( int nIndex, COLORREF crColor ); // 创建风格由nIndex指定且颜色为crColor的条纹(hatch,孵化/影线)刷,其中nIndex可取条纹风格(Hatch Styles)值见表8-5和图8-4。
表8-5 条纹风格nIndex值
符号常量 数值 风格
HS_HORIZONTAL 0 水平线
HS_VERTICAL 1 垂直线
HS_FDIAGONAL 2 正斜线
HS_BDIAGONAL 3 反斜线
HS_CROSS 4 十字线(正网格)
HS_DIAGCROSS 5 斜十字线(斜网格)
CDC *pDC = pView->GetDC();
// 定义一个画图对象
Gdiplus::Graphics graphics(pDC->m_hDC);
// 获取视图客户区大小
CRect rt;
pView->GetClientRect(&rt);
// 定义一个线性渐变画刷,按红黄蓝绿的顺序四种颜色渐变
LinearGradientBrush linGrBrush(Point(100,0),Point(100,rt.Height()/2),Color(255,255,0,0),Color(255,0,0,255));
Color colors[] = {
Color(255, 255, 0, 0), // red
Color(255, 255, 255, 0), //yellow
Color(255, 0, 0, 255), // blue
Color(255, 0, 255, 0)}; // green
REAL positions[] = {
0.0f,
0.33f,
0.66f,
1.0f};
linGrBrush.SetInterpolationColors(colors, positions,4);
// 填充指定区域矩形
graphics.FillRectangle(&linGrBrush,rt.Width()/2,0,80,rt.Height()/2);
CDC *pDC = pView->GetDC();
// 定义一个画图对象
Gdiplus::Graphics graphics(pDC->m_hDC);
// 获取视图客户区大小
CRect rt;
pView->GetClientRect(&rt);
// 定义一个线性渐变画刷,按红黄蓝绿的顺序四种颜色渐变
LinearGradientBrush linGrBrush(Point(100,0),Point(100,rt.Height()/2),Color(255,255,0,0),Color(255,0,0,255));
Color colors[] = {
Color(255, 255, 0, 0), // red
Color(255, 255, 255, 0), //yellow
Color(255, 0, 0, 255), // blue
Color(255, 0, 255, 0)}; // green
REAL positions[] = {
0.0f,
0.33f,
0.66f,
1.0f};
linGrBrush.SetInterpolationColors(colors, positions,4);
// 填充指定区域矩形
graphics.FillRectangle(&linGrBrush,rt.Width()/2,0,80,rt.Height()/2);