MFC Initializes GDI +

Source: Internet
Author: User



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 +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.