GDI 使用步骤
来源:互联网 发布:手机淘宝怎么选择客服 编辑:程序博客网 时间:2024/06/04 05:39
使用GDI+一般遵循下列步骤:
(1)、在应用程序中添加GDI+的包含文件gdiplus.h以及附加的类库gdiplus.lib。通常gdiplus.h包含文件添加在应用程序的stdafx.h文件中,而gdiplus.lib可用两种进行添加:第一种是直接在stdafx.h文件中添加下列语句:
#pragma comment( lib, "gdiplus.lib" )
另一种方法是:选择"项目->属性"菜单命令,在弹出的对话框中选中左侧的"链接器->输入"选项,在右侧的"附加依赖项"框中键入gdiplus.lib,
(2)、在应用程序项目的应用类中,添加一个成员变量,如下列代码:
ULONG_PTR m_gdiplusToken;
其中,ULONG_PTR是一个DWORD数据类型,该成员变量用来保存GDI+被初始化后在应用程序中的GDI+标识,以便能在应用程序退出后,引用该标识来调用Gdiplus:: GdiplusShutdown来关闭GDI+。
(3)、在应用类中添加ExitInstance的重载,并添加下列代码用来关闭GDI+:
int CGDIPlusApp::ExitInstance()
{
Gdiplus::GdiplusShutdown(m_gdiplusToken);
return CWinApp::ExitInstance();
}
(4)、在应用类的InitInstance函数中添加GDI+的初始化代码:
BOOL CGDIPlusApp::InitInstance()
{
CWinApp::InitInstance();
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
...
}
(5)、在需要绘图的窗口或视图类中添加GDI+的绘制代码:
void CGDIPlusView::onDraw(CDC *pDC)
{
Graphics graphics( pDC->m_hDC );
GraphicsPath path; // 构造一个路径
path.AddEllipse(50, 50, 200, 100);
// 使用路径构造一个画刷
PathGradientBrush pthGrBrush(&path);
// 将路径中心颜色设为蓝色
pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));
// 设置路径周围的颜色为蓝芭,但alpha值为0
Color colors[] = {Color(0, 0, 0, 255)};
INT count = 1;
pthGrBrush.SetSurroundColors(colors, &count);
graphics.FillRectangle(&pthGrBrush, 50, 50, 200, 100);
LinearGradientBrush linGrBrush(
Point(300, 50),
Point(500, 150),
Color(255, 255, 0, 0), // 红色
Color(255, 0, 0, 255)); // 蓝色
graphics.FillRectangle(&linGrBrush, 300, 50, 200, 100);
}
- GDI 使用步骤
- GDI+使用步骤
- GDI+使用步骤
- 在VC中使用GDI+步骤
- 在程序中使用GDI+的步骤
- VC++ gdi+的使用步骤(使用版本2010)
- VS2008使用MFC进行GDI+程序建立步骤
- GDI绘图步骤
- GDI绘图步骤 .
- gdi画图基本步骤
- 使用 GDI+
- 使用GDI+
- GDI+ 使用
- 使用GDI+
- 使用GDI
- gdi使用
- GDI绘图基本步骤总结
- GDI+在VC6中的配置步骤
- Android笔记-hardwareAccelerated 硬件加速详解
- Python内建函数(D)
- Python内建函数(E)
- poj 1037 A decorative fence
- ListView的onTouch动作
- GDI 使用步骤
- HRPlugin For Xcode发布(附源码地址)
- Python内建函数(F)
- 大数,高精度计算---百位大数
- xcode插件
- 实时错误'91'----对象变量或wih块变量未设置
- NFC高级
- Python内建函数(G)
- windows adb