1:在APP.h中添加
#pragma comment(lib,"gdiplus.lib")
#include <gdiplus.h>
using namespace Gdiplus;
2:在应用程序类中添加成员变量
ULONG_PTR m_gdiplusToken;
3:在应用程序初始化的时候添加GDI+初始化的代码
BOOL CGDIPlusDemoApp::InitInstance()
{AfxEnableControlContainer();
//GDI+的初始化
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&m_gdiplusToken,&gdiplusStartupInput,NULL);
。。。。
return FALSE;
}
4:利用类向导添加应用程序类函数virtual int ExitInstance()用以释放GDI+资源
int CGDIPlusDemoApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
GdiplusShutdown(m_gdiplusToken);
return CWinApp::ExitInstance();
}
5:Tools----->Options----->Directorys中Include Files和Library Files中加入GDI所用的.h文件和.lib文件
GDI+所需要的包从网上下载。
完成以上五步骤即可开始GDI+编程了。