Sunday, April 6, 2008

Using GDI+ in MFC Applications

1. In Visual C++ 2005 go to Project->Properties, Type gdiplus.lib into the Configuration Properties/Linker/Input/Additional Dependencies.
2. Add the following line to stdafx.h:
#include <gdiplus.h>

using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")
3. Intialize the GDI+ resources. Add this to your CWinApp derived class as member:
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
At InitInstance(), add:
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

// note: GdiplusStartup() should be added before the
// following sentence:
CWinApp::InitInstance();
4. Your application is ready to consume GDI+ now.
5. Upon exit, release GDI+ resources. Add the following line to ExitInstance():
GdiplusShutdown(gdiplusToken);

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.