Some notes on using GDI+ from Visual C++ Version 6.

Install the latest Microsoft SDK. This will have the GDI+ header.
Add the following to your project's common header:
| #include <Gdiplus.h> using namespace Gdiplus; #pragma comment(lib, "gdiplus.lib") |
From the menu, tools, options add the highlighted path to the SDK include directory:

Download the latest gdiplus.dll. Look at the Platform SDK Redistributables here.
The safest place to put the DLL is in the same directory as your executable. May be you are strong enough to risk installing it into a system directory? I'm not.
Add GdiplusStartup() and GdiplusShutdown() to your application
| BOOL CGdiplustestApp::InitInstance() { GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. VERIFY(GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL) == Ok); CGdiplustestDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); GdiplusShutdown(gdiplusToken); return FALSE; } |
And finally some anti alias code!
| void CGdiplustestDlg::OnPaint() { CPaintDC dc(this); Graphics graphics(dc); { Pen pen1(Color(255, 255, 255), 400); graphics.DrawLine(&pen1, 200, 0, 200, 400); } { Pen pen1(Color(0, 0, 0), 10); graphics.DrawLine(&pen1, 133, 0, 137, 400); } graphics.SetSmoothingMode(SmoothingModeAntiAlias); { Pen pen1(Color(0, 0, 0), 10); graphics.DrawLine(&pen1, 266, 0, 270, 400); } } |

In section 3 above I set the search order to the windows SDK then the Visual C paths. This is all very good, and is what Bill told me to do, but.... windows.h in the sdk is slightly different: it doesn't include winsock2.h.
Not a problem if your not using sockets, but a complete pain if your are.
After a day spent changing various libraries to explicitly including winsock2.h, and getting the third party object space library to compile, I had errors compiling with a com header. ENOUGH!
Backtrack.
I now have removed the path to the SDK, undone changes to all these libraries.
I prepared a directory with all the gdiplus headers, taken from the SDK:
| Directory of C:\myproject\gdiplus 20/12/2001 10:31 <DIR> . 20/12/2001 10:31 <DIR> .. 20/12/2001 10:31 1,735 GdiPlus.h 20/12/2001 10:31 206,254 GdiPlus.lib 20/12/2001 10:31 833 GdiPlusBase.h 20/12/2001 10:31 20,833 GdiPlusBitmap.h 20/12/2001 10:31 27,446 GdiPlusBrush.h 20/12/2001 10:31 1,164 GdiPlusCachedBitmap.h 20/12/2001 10:31 9,791 GdiPlusColor.h 20/12/2001 10:31 1,641 GdiPlusColorMatrix.h 20/12/2001 10:31 47,936 GdiPlusEnums.h 20/12/2001 10:31 84,684 GdiPlusFlat.h 20/12/2001 10:31 5,804 GdiPlusFont.h 20/12/2001 10:31 2,982 GdiPlusFontCollection.h 20/12/2001 10:31 4,464 GdiPlusFontFamily.h 20/12/2001 10:31 2,715 GdiPlusGpStubs.h 20/12/2001 10:31 88,030 GdiPlusGraphics.h 20/12/2001 10:31 19,495 GdiPlusHeaders.h 20/12/2001 10:31 12,952 GdiPlusimageAttributes.h 20/12/2001 10:31 1,335 GdiPlusImageCodec.h 20/12/2001 10:31 23,354 GdiPlusImaging.h 20/12/2001 10:31 3,272 GdiPlusInit.h 20/12/2001 10:31 6,796 GdiPlusLineCaps.h 20/12/2001 10:31 9,201 GdiPlusMatrix.h 20/12/2001 10:31 788 GdiPlusMem.h 20/12/2001 10:31 12,264 GdiPlusMetaFile.h 20/12/2001 10:31 7,948 GdiPlusMetaHeader.h 20/12/2001 10:31 47,254 GdiPlusPath.h 20/12/2001 10:31 13,207 GdiPlusPen.h 20/12/2001 10:31 3,940 GdiPlusPixelFormats.h 20/12/2001 10:31 14,896 GdiPlusRegion.h 20/12/2001 10:31 8,192 GdiPlusStringFormat.h 20/12/2001 10:31 16,467 GdiPlusTypes.h 20/12/2001 10:31 62 OurGdiPlus.h 20/12/2001 10:31 544 vssver.scc 33 File(s) 708,279 bytes 2 Dir(s) 8,706,719,744 bytes free |
All these files are unchanged. In my VC++ project I #include "ourgdiplus.h", a modest little file that contains:
| #define ULONG_PTR DWORD #include "GdiPlus.h" |
I can now use GDI+ without having to break stable libraries....