1、需要包含头文件如下:
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <gdiplus.h>
#include <Commctrl.h>
using namespace Gdiplus;
#pragma comment( lib, "gdiplus.lib" )
2、定义全局变量
public:
ULONG_PTR m_gdiplusToken;
3、打开gdi
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
4、退出程序时需要关闭gdi
Gdiplus::GdiplusShutdown( m_gdiplusToken );