To successfully build a Visual C++ .NET project that uses GDI+, follow these steps:
1 Make sure that the current Platform SDK is installed. The current Platform SDK is the version of the Platform SDK from which your GDI+ headers and libraries are taken.
2 Make sure that your installation of Microsoft Visual Studio .NET is configured to read from the Platform SDK include directories and library directories before it reads from its own directories.
3 Follow these steps to create a new Visual C++ Win32 project:
Start Visual Studio .NET.
On the File menu, point to New, and then click Project.
Click Visual C++ Projects under Project Types, and then click Win32 Project under Templates.
4 In the StdAfx.h file, verify the following:
Make sure that WIN32_LEAN_AND_MEAN is not defined.
Make sure that the Windows.h file is included (even for console applications).
Make sure that the Gdiplus.h file is included after Windows.h.
5 In your .cpp file, add the follow code after the include directives:
using namespace Gdiplus;
6 In WinMain, make sure that the following code is one of the first items to be executed:
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL );
7 In WinMain, add the following code to each exit path:
GdiplusShutdown(gdiplusToken);
8 In the project settings, add the Gdiplus.lib file to the input library list.
1 Make sure that the current Platform SDK is installed. The current Platform SDK is the version of the Platform SDK from which your GDI+ headers and libraries are taken.
2 Make sure that your installation of Microsoft Visual Studio .NET is configured to read from the Platform SDK include directories and library directories before it reads from its own directories.
3 Follow these steps to create a new Visual C++ Win32 project:
Start Visual Studio .NET.
On the File menu, point to New, and then click Project.
Click Visual C++ Projects under Project Types, and then click Win32 Project under Templates.
4 In the StdAfx.h file, verify the following:
Make sure that WIN32_LEAN_AND_MEAN is not defined.
Make sure that the Windows.h file is included (even for console applications).
Make sure that the Gdiplus.h file is included after Windows.h.
5 In your .cpp file, add the follow code after the include directives:
using namespace Gdiplus;
6 In WinMain, make sure that the following code is one of the first items to be executed:
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL );
7 In WinMain, add the following code to each exit path:
GdiplusShutdown(gdiplusToken);
8 In the project settings, add the Gdiplus.lib file to the input library list.
本文由VS软件圈(vssoft.net)发布,不代表VS软件圈立场,转载联系作者并注明出处:https://vssoft.net/vsazwt/VS2005anzhuangwenti/2020/0721/325.html