Click here to Skip to main content
13,140,231 members (44,618 online)
Click here to Skip to main content
Add your own
alternative version


49 bookmarked
Posted 8 Dec 2002

Macro to initialize GDI+ in VC6.0 MFC projects

, 20 Apr 2003
Rate this:
Please Sign up or sign in to vote.
A simple macro that adds all the code necessary to initialize the GDI+ libraries in an MFC 6.0 application


I have started to use GDI+ with MFC in VC++ 6.0 and got tired of always having to remember to add the GDI+ startup code and header and library files to my project. So I decided to write a simple VS macro that would do all this for me.

What's added?

In stdafx.h file the following lines are added:

// GdiPlus -- Added by the GdiPlus macro
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "Gdiplus.lib")

In the <AppName>.h header file the following lines are added:

// GdiPlus -- Added by the GdiPlus macro
    ULONG_PTR m_gdiplustoken;

And if the application's ExitInstance() function is not already declared, a declaration is also added in the virtual functions section.

// GdiPlus -- Added by the GdiPlus macro
virtual int ExitInstance();

In the <AppName>.cpp source file, the following lines are added to the InitInstance() function.

// GdiPlus -- Added by the GdiPlus macro
GdiplusStartupInput gdiplusstartupinput;
GdiplusStartup (&m_gdiplusToken, &gdiplusstartupinput, NULL);

And, in the ExitInstance() function, which is added if it is not already present, the following lines are added:

// GdiPlus -- Added by the GdiPlus macro

How to install

Simply save the GdiPlus.dsm file in your <Visual Studio>/Common/MSDev98/Macros/ folder. Then, in Dev Studio, select the Tools menu, Macro dialog. On the Macro dialog click the Options button to show an extra four buttons. Click the Loaded Files button to bring up another dialog. Scroll down the list of macro files until you find GdiPlus. Select the check box for GdiPlus and Bob's your uncle.

That's it! I hope someone finds this useful because I sure do!


  • April 21, 2003 - Minor bug fix. Thanks to Larry Desonier


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

PJ Arends
Canada Canada
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralGDIplus.dll Pin
vimalk5-Feb-04 20:32
membervimalk5-Feb-04 20:32 
GeneralRe: GDIplus.dll Pin
PJ Arends6-Feb-04 6:48
memberPJ Arends6-Feb-04 6:48 
GeneralRe: GDIplus.dll Pin
waelahmed27-Mar-04 23:15
memberwaelahmed27-Mar-04 23:15 
GeneralRe: GDIplus.dll Pin
PJ Arends28-Mar-04 16:20
memberPJ Arends28-Mar-04 16:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 21 Apr 2003
Article Copyright 2002 by PJ Arends
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid