如何在MFC项目中打开GDI + 1.1而不是1.0? [英] How to turn on GDI+ 1.1 instead of 1.0 in MFC project?

查看:293
本文介绍了如何在MFC项目中打开GDI + 1.1而不是1.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在VS2012 MFC C ++项目(在Win7上)中使用GDI + 1.1类.图像,位图,图形类工作正常,但是当我尝试声明Blur类(或其他v1.1类)的对象时,我得到了error C2065: ‘Blur’: undeclared identifier.我试图这样定义GDIPVER(在stdafx.h中)

#define GDIPVER 0x0110 //also I get the warning C4005: 'GDIPVER' : macro redefinition
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")

但它不起作用.

如何打开GDI + 1.1(而不是1.0)?

解决方案

在一个项目上,我曾遇到过类似的问题.对我来说,我的预编译头文件具有以下内容:

#define GDIPVER     0x0110  // Use more advanced GDI+ features

,但预编译的头文件不#include"gdiplus.h".这仅在实际进行GDI +调用的.cpp文件中发生.我为具有GDI +对象指针作为成员的标头声明GDI +类.正如Hans和其他评论所指出的,在设置GDIPVER之前,可能还有另一个标头,包括gdiplus.h.要弄清楚其中包含的位置,请尝试转到项目的C/C ++>命令行设置,然后添加/showIncludes,然后进行完整的构建,并在构建日志中查找gdiplus.h,并追溯到包含该名称的第一个标头. /p>

一旦清除了这一障碍,我还发现除非清单也进行了更新,否则我的应用程序实际上不会使用1.1功能.因此,我的.cpp文件之一具有以下内容:

// Update Manifest
// cf: http://blogs.msdn.com/b/oldnewthing/archive/2007/05/31/2995284.aspx
//
// We use features from GDI+ v1.1 which is new as of Windows Vista. There is no redistributable for Windows XP.
// This adds information to the .exe manifest to force GDI+ 1.1 version of gdiplus.dll to be loaded on Vista
// without this, Vista defaults to loading version 1.0 and our application will fail to launch with missing entry points.
#if 64BIT_BUILD
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.GdiPlus' version='1.1.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.GdiPlus' version='1.1.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif

I unable to use GDI+ 1.1 classes in my VS2012 MFC C++ project (on Win7). Classes Image, Bitmap, Graphics works just fine but when I try to declare an object of Blur class (or other v1.1 classes) I am getting an error C2065: ‘Blur’: undeclared identifier. I tried to define GDIPVER (in stdafx.h) like this

#define GDIPVER 0x0110 //also I get the warning C4005: 'GDIPVER' : macro redefinition
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")

but it does not work.

How to turn on GDI+ 1.1 instead of 1.0?

解决方案

I fought with a similar issue for a while on one project. For me, my precompiled header has this:

#define GDIPVER     0x0110  // Use more advanced GDI+ features

but the precompiled header does not #include "gdiplus.h". That only occurs in the .cpp files which actually make GDI+ calls. I forward declare GDI+ classes for the headers which have GDI+ object pointers as members. As Hans and other comments noted, there's probably another header including gdiplus.h before the GDIPVER is set. To figure out where it's included try going to the C/C++ > Command Line settings for your project and add /showIncludes then do a full build and look in the build log for gdiplus.h and track back to the first header including it.

Once you clear that hurdle, I also discovered my application would not actually use the 1.1 features unless the manifest was also updated. So one of my .cpp files has this:

// Update Manifest
// cf: http://blogs.msdn.com/b/oldnewthing/archive/2007/05/31/2995284.aspx
//
// We use features from GDI+ v1.1 which is new as of Windows Vista. There is no redistributable for Windows XP.
// This adds information to the .exe manifest to force GDI+ 1.1 version of gdiplus.dll to be loaded on Vista
// without this, Vista defaults to loading version 1.0 and our application will fail to launch with missing entry points.
#if 64BIT_BUILD
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.GdiPlus' version='1.1.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.GdiPlus' version='1.1.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif

这篇关于如何在MFC项目中打开GDI + 1.1而不是1.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆