Click here to Skip to main content
Licence CPOL
First Posted 8 Dec 2002
Views 111,182
Bookmarked 47 times

Macro to initialize GDI+ in VC6.0 MFC projects

By | 20 Apr 2003 | Article
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)

About the Author

PJ Arends



Canada Canada

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralLicensing for commercial application Pinmemberwill62625:09 19 Oct '10  
GeneralRe: Licensing for commercial application PinmemberPJ Arends7:09 20 Oct '10  
GeneralRe: Licensing for commercial application Pinmemberwill62625:13 16 Nov '10  
GeneralDownload GDI+ version 1.1 Pinsusspubba17:52 23 May '04  
GeneralRe: Download GDI+ version 1.1 PinmemberRYU^^19:47 27 Sep '05  
GeneralRe: Download GDI+ version 1.1 PinmemberJIANG, Sheng[MVP]6:54 6 Apr '07  
GeneralUnknown error Pinmembershiggity s15:48 28 Mar '04  
GeneralRe: Unknown error PinmemberPJ Arends16:16 28 Mar '04  
GeneralGDIplus.dll Pinmembervimalk20:32 5 Feb '04  
GeneralRe: GDIplus.dll PinmemberPJ Arends6:48 6 Feb '04  
GeneralRe: GDIplus.dll Pinmemberwaelahmed23:15 27 Mar '04  
GeneralRe: GDIplus.dll PinmemberPJ Arends16:20 28 Mar '04  
GeneralUsing makro inside a dll Pinsussjung-kreidler21:31 8 Oct '03  
GeneralI get some errors Pinmemberstealth kid4:00 19 Jun '03  
GeneralRe: I get some errors PinmemberPJ Arends10:24 19 Jun '03  
GeneralRe: I get some errors Pinmembernastanet22:05 19 Apr '04  
GeneralRe: I get some errors PinmemberPJ Arends22:16 19 Apr '04  
GeneralRe: I get some errors PinmemberEinst19:33 16 Oct '05  
GeneralWhy not use a simple smart type PinmemberRama Krishna11:15 15 Jan '03  
GeneralRe: Why not use a simple smart type Pinsusswangwanxin1@163.net23:47 17 Jan '05  
GeneralYep... PinmemberJ.G. Hattingh7:51 23 Dec '02  
GeneralWhere Can I found more GDI+ materials PinmemberNing Cao20:11 22 Dec '02  
GeneralRe: Where Can I found more GDI+ materials PinmemberPJ Arends9:49 23 Dec '02  
GeneralRe: Where Can I found more GDI+ materials Pinmemberptfoof15:30 1 May '04  
GeneralGraphics hardware acceleration with GDI+ PinmemberGiles3:04 10 Dec '02  

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.

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