1. In the StdAfx.h file, add # include <afxext.h>
#include <gdiplus.h> //Add GDI + header files to the project #pragma comment (lib, "Gdiplus.lib")//Add GDI + lib files to the project using namespace Gdiplus;
2. defined in class C**app:public CWinApp
protected:ulong_ptr m_gdiplustoken;public:virtual int exitinstance (); Heavy Duty ExitInstance
3. Add code in the BOOL c**app::initinstance () function
Gdiplus::gdiplusstartupinput Gdiplusstartupinput; Gdiplus::gdiplusstartup (&m_gdiplustoken, &gdiplusstartupinput, NULL);
4. Add function Implementation ExitInstance ()
int c**app::exitinstance () {//Todo:add your specialized code here and/or call the base class//gdi+ termination, must be Called before GDI + is unloaded. (This interface must be called before uninstalling GDI +)//must not being called from DllMain, it calls cause deadlock. (cannot be called in DllMain, will result in deadlock)//gdi+ API May is called after Gdiplusshutdown, pay careful attention to GDI + object destructors. Gdiplusshutdown (M_gdiplustoken); Close GDI +return cwinapp::exitinstance ();}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MFC Initializes GDI +