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

Macro to initialize GDI+ in VC6.0 MFC projects

By , 20 Apr 2003
 

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
President
Canada Canada
Member
No Biography provided

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.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralDownload GDI+ version 1.1susspubba23 May '04 - 17:52 
Hi,
I want to apply Bitmap::ConvertFormat () method for my project. But above method is not in the GDI+ version 1.0 .So I have to download GDI+ version 1.1. From where can I download it? I search it .But I didn't get suitable URL for that. please helpFrown | :(
Is there other way to do this?.
GeneralRe: Download GDI+ version 1.1 PinmemberRYU^^27 Sep '05 - 19:47 
Yeah, I need to use Bitmap::ConvertFormat(). Anyone know how to include GDI+ version 1.1?
GeneralRe: Download GDI+ version 1.1 PinmemberJIANG, Sheng[MVP]6 Apr '07 - 6:54 
If I remember correctly GDI+ version 1.1 is part of Office 2003 and can not be redistributed freely.
 
Regards
 
Microsoft MVP in Visual C++
 
www.jiangsheng.net

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

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