Click here to Skip to main content
Click here to Skip to main content

Macro to initialize GDI+ in VC6.0 MFC projects

, 20 Apr 2003 CPOL
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

Introduction

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
protected:
    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
public:
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
GdiplusShutdown(m_gdiplusToken);

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!

Updates

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

License

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

Share

About the Author

PJ Arends
President
Canada Canada
No Biography provided

Comments and Discussions

 
GeneralLicensing for commercial application Pinmemberwill626219-Oct-10 6:09 
GeneralRe: Licensing for commercial application PinmemberPJ Arends20-Oct-10 8:09 
GeneralRe: Licensing for commercial application Pinmemberwill626216-Nov-10 6:13 
Thanks. Appreciate it!
GeneralDownload GDI+ version 1.1 Pinsusspubba23-May-04 18:52 
GeneralRe: Download GDI+ version 1.1 PinmemberRYU^^27-Sep-05 20:47 
GeneralRe: Download GDI+ version 1.1 PinmemberJIANG, Sheng[MVP]6-Apr-07 7:54 
GeneralUnknown error Pinmembershiggity s28-Mar-04 16:48 
GeneralRe: Unknown error PinmemberPJ Arends28-Mar-04 17:16 
GeneralGDIplus.dll Pinmembervimalk5-Feb-04 21:32 
GeneralRe: GDIplus.dll PinmemberPJ Arends6-Feb-04 7:48 
GeneralRe: GDIplus.dll Pinmemberwaelahmed28-Mar-04 0:15 
GeneralRe: GDIplus.dll PinmemberPJ Arends28-Mar-04 17:20 
GeneralUsing makro inside a dll Pinsussjung-kreidler8-Oct-03 22:31 
GeneralI get some errors Pinmemberstealth kid19-Jun-03 5:00 
GeneralRe: I get some errors PinmemberPJ Arends19-Jun-03 11:24 
GeneralRe: I get some errors Pinmembernastanet19-Apr-04 23:05 
GeneralRe: I get some errors PinmemberPJ Arends19-Apr-04 23:16 
GeneralRe: I get some errors PinmemberEinst16-Oct-05 20:33 
GeneralWhy not use a simple smart type PinmemberRama Krishna15-Jan-03 12:15 
GeneralRe: Why not use a simple smart type Pinsusswangwanxin1@163.net18-Jan-05 0:47 
GeneralYep... PinmemberJ.G. Hattingh23-Dec-02 8:51 
GeneralWhere Can I found more GDI+ materials PinmemberNing Cao22-Dec-02 21:11 
GeneralRe: Where Can I found more GDI+ materials PinmemberPJ Arends23-Dec-02 10:49 
GeneralRe: Where Can I found more GDI+ materials Pinmemberptfoof1-May-04 16:30 
GeneralGraphics hardware acceleration with GDI+ PinmemberGiles10-Dec-02 4:04 

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

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

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