2014-11-25 1 views
4

내 VS2012 MFC C++ 프로젝트 (Win7)에서 GDI + 1.1 클래스를 사용할 수 없습니다. 클래스 이미지, 비트 맵, 그래픽 잘 작동하지만 블러 클래스 (또는 다른 v1.1 클래스)의 객체를 선언하려고하면 error C2065: ‘Blur’: undeclared identifier이 발생합니다. 나는이MFC 프로젝트에서 1.0 대신 GDI + 1.1을 설정하는 방법은 무엇입니까?

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

처럼 (에 stdafx.h에서) GDIPVER을 정의하기 위해 시도했지만 작동하지 않습니다.

1.0 대신 GDI + 1.1을 설정하는 방법은 무엇입니까?

+1

경고가 잘못되었습니다. * 일부 코드는 gdiplus.h를 # 포함하기 전에 수행합니다. 가장 좋은 장소는 stdafx.h 파일입니다./showIncludes로 문제를 해결하십시오 –

+0

예, 이것은 내 stdafx.h에 있습니다. – Craftsmann

+0

아마도 이전에 뭔가도 포함되어 있습니다. – doctorlove

답변

2

한 프로젝트에서 잠시 동안 비슷한 문제로 싸웠습니다.

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

을하지만, 미리 컴파일 된 헤더는 "gdiplus.h을"#include를하지 않습니다 나를 위해, 내 미리 컴파일 된 헤더이 있습니다. 실제로 GDI + 호출을 수행하는 .cpp 파일에서만 발생합니다. GDI + 클래스는 GDI + 개체 포인터가있는 멤버로 선언합니다. 한스 (Hans)와 다른 의견에서 언급했듯이, GDIPVER가 설정되기 전에 gdiplus.h를 포함한 다른 헤더가있을 수 있습니다. 포함 된 위치를 찾으려면 프로젝트의 C/C++> 명령 줄 설정으로 가서/showIncludes를 추가 한 다음 전체 빌드를 수행하고 빌드 로그에서 gdiplus.h를보고 다시 포함하여 첫 번째 헤더까지 추적하십시오.

장애물을 제거하면 매니페스트가 업데이트되지 않는 한 내 응용 프로그램이 실제로 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 
+1

/showIncludes 옵션이 매우 유용합니다. 따라서 gdiplus.h가 이미 이전에 포함되었다는 것을 알았습니다. 나는'#include '과'#pragma comment (lib, "Gdiplus.lib")'를 삭제하고'#define GDIPVER 0x0110'을 stdafx.h의 시작 부분에 넣었다. 이제 작동합니다! – Craftsmann

+0

이전 질문을 일으켜서 미안하지만 'amd64'또는 'x86' 대신'*'를 사용 하시길 권해드릴 수 있습니까? 훨씬 더 간단합니다. – LHLaurini

+0

나는 그것을 시도했지만 그것이 실패했다는 것을 확신한다. 그러나 그것은 당신에게 효과가 있다면 좋은 방법이다. – jschroedl

관련 문제