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:
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "Gdiplus.lib")
In the <AppName>.h header file the following lines are added:
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.
public:
virtual int ExitInstance();
In the <AppName>.cpp source file, the following lines are added to the InitInstance()
function.
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:
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