请教GDI+ 开发高手,麻烦帮看一下这个程序加了GDI+环境编译报错??谢谢

vc8fans 2018-03-09 06:34:30
http://www.newxing.com/Code/VC/TXCL/3542.html
这个资源对我来将很不错,研究了<基于GDI技术的VC++公交线路查询系统> 源代码
原本没有GDI+ 库开发 包 ,下载一个后附加进

#ifndef ULONG_PTR
#define ULONG_PTR unsigned long*
#endif

//#include <Gdiplus.h> //GDI++
#include "GdiPlus\\Gdiplus.h"
using namespace Gdiplus;

提示GDI+ 有一些错误

错误如下:
Compiling...
stdafx.cpp
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(291) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(294) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(297) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(301) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(305) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(309) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(313) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(317) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(320) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(323) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(326) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(329) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(332) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(336) : error C2955: 'iterator' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\utility(71) : see declaration of 'iterator'
C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\GdiPlus\\GdiplusFlat.h(1478) : error C2955: 'map' : use of class template requires template argument list
D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\map(140) : see declaration of 'map'
Error executing cl.exe.

Neobus.exe - 15 error(s), 0 warning(s)
//===================================================
GDI+ 怎会出错呢??
GpStatus WINGDIPAPI
GdipCreatePathIter(GpPathIterator **iterator, GpPath* path);
...全文
689 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2018-03-13
  • 打赏
  • 举报
回复
XSpot XTube 里的 g-> 根本没有调用 !
vc8fans 2018-03-13
  • 打赏
  • 举报
回复
所以 ,那个 作者给了一个比较好的演示,给的例子代码根本没有图,我们都上当了!
schlafenhamster 2018-03-12
  • 打赏
  • 举报
回复

int XTube::DrawSpots (Graphics* g, map<CString, PointF>* spotMap)
{
	delete defFont;
	WCHAR wTxt[1024];
	int wlen;
	wlen=MultiByteToWideChar(CP_ACP,0,defFontFace,defFontFace.GetLength(),wTxt,0);
	defFont = new Font (wTxt, defFontHeight, defFontStyle);
//
	for (size_t i = 0; i < spots.size (); i ++)
		spots[i].Draw (g, spotMap);

	return 0;
}
WCHAR wTxt[1024]; int wlen; wlen=MultiByteToWideChar(CP_ACP,0,defFontFace,defFontFace.GetLength(),wTxt,0); defFont = new Font (wTxt, defFontHeight, defFontStyle);
schlafenhamster 2018-03-12
  • 打赏
  • 举报
回复
'CStringW' 没定义 ,要 用 MultiByteToWideChar
schlafenhamster 2018-03-12
  • 打赏
  • 举报
回复
'i' : redefinition; multiple initialization vc6 只能 定义 一次 i, 下面会 出这个错误 for(int i=0;i<10;i++) {} // 再用 for(int i=0;i<10;i++) {} i 会 redefinition; 把 i 方 for 外 定义 int i; for(i=0;i<10;i++) {} for(i=0;i<10;i++) {}
cbzjzsb123 2018-03-12
  • 打赏
  • 举报
回复
引用 14 楼 vc8fans 的回复:
非常感谢 schlafenhamster , 1)用上述方法解决GDI+编译出错问题, 2)在需要的 地方using namespace std; 解决了第二个问题, 非常些 高手们的 帮助, 接下来还有 13个编译问题:能再麻烦点时间看一下吗 ,整了一个晚上 C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(183) : error C2374: 'i' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(171) : see declaration of 'i' C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(202) : error C2374: 'k' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(194) : see declaration of 'k' XNeobus.cpp D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(525) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(521) : while compiling class-template member function 'void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int)' XPath.cpp C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XPath.cpp(276) : warning C4305: '*=' : truncation from 'const double' to 'float' D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(525) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(521) : while compiling class-template member function 'void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int)' XSpot.cpp C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(269) : error C2065: 'CStringW' : undeclared identifier C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(269) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(273) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(273) : error C2228: left of '.GetLength' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(300) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(300) : error C2228: left of '.GetLength' must have class/struct/union type XTube.cpp C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(65) : error C2065: 'CStringW' : undeclared identifier C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(65) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(141) : error C2374: 'i' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(102) : see declaration of 'i' C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(250) : error C2374: 'i' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(102) : see declaration of 'i' C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(416) : error C2228: left of '.GetBuffer' must have class/struct/union type Generating Code... Error executing cl.exe. Neobus.exe - 13 error(s), 6 warning(s) //================================ //2, 经过一个中转站 for (size_t i = 0; i < pStation1->lines.size (); i ++) 出错这里??? 水平太有限 您 编译通过能 给我一个吗? pc8mcu@126.com 或能抽点空我发我编译的情况给您吗?您能给个您的邮箱吗? 总之非常感谢,我学习过长,不能忘记曾经帮助的兄弟!!
i重复定义了这样的问题你要上来问?
schlafenhamster 2018-03-12
  • 打赏
  • 举报
回复
这是一个 未完成 的项目。
vc8fans 2018-03-12
  • 打赏
  • 举报
回复
谢谢了,编译完还有很多问题,看来作者是故意留下一个套
schlafenhamster 2018-03-11
  • 打赏
  • 举报
回复
stdafx.h 改为:

//Download by http://www.NewXing.com
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once
#pragma warning(disable : 4786)

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif						

#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400	// Change this to the appropriate value to target IE 5.0 or later.
#endif

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS	// some CString constructors will be explicit

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include "markup.h"
#include <algorithm>

typedef unsigned long ULONG_PTR, *PULONG_PTR;
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment(lib,"gdiplus.lib")

schlafenhamster 2018-03-11
  • 打赏
  • 举报
回复
VC6 编译通过
vc8fans 2018-03-11
  • 打赏
  • 举报
回复
非常感谢 schlafenhamster , 1)用上述方法解决GDI+编译出错问题, 2)在需要的 地方using namespace std; 解决了第二个问题, 非常些 高手们的 帮助, 接下来还有 13个编译问题:能再麻烦点时间看一下吗 ,整了一个晚上 C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(183) : error C2374: 'i' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(171) : see declaration of 'i' C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(202) : error C2374: 'k' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XLines.cpp(194) : see declaration of 'k' XNeobus.cpp D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(525) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(521) : while compiling class-template member function 'void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int)' XPath.cpp C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XPath.cpp(276) : warning C4305: '*=' : truncation from 'const double' to 'float' D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(525) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX D:\Soft\Microsoft Visual Studio\VC98\INCLUDE\xstring(521) : while compiling class-template member function 'void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned int)' XSpot.cpp C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(269) : error C2065: 'CStringW' : undeclared identifier C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(269) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(273) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(273) : error C2228: left of '.GetLength' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(300) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XSpot.cpp(300) : error C2228: left of '.GetLength' must have class/struct/union type XTube.cpp C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(65) : error C2065: 'CStringW' : undeclared identifier C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(65) : error C2228: left of '.GetBuffer' must have class/struct/union type C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(141) : error C2374: 'i' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(102) : see declaration of 'i' C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(250) : error C2374: 'i' : redefinition; multiple initialization C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(102) : see declaration of 'i' C:\Users\Administrator\Desktop\www.NewXing.com\Neobus0.1-2\XTube.cpp(416) : error C2228: left of '.GetBuffer' must have class/struct/union type Generating Code... Error executing cl.exe. Neobus.exe - 13 error(s), 6 warning(s) //================================ //2, 经过一个中转站 for (size_t i = 0; i < pStation1->lines.size (); i ++) 出错这里??? 水平太有限 您 编译通过能 给我一个吗? pc8mcu@126.com 或能抽点空我发我编译的情况给您吗?您能给个您的邮箱吗? 总之非常感谢,我学习过长,不能忘记曾经帮助的兄弟!!
schlafenhamster 2018-03-11
  • 打赏
  • 举报
回复
"试了还是不行"?什么不行? stdafx.h 里不要 using namespace std; 然后 只 编译 stdafx.cpp 就应该没有 C2955 错误了! 其实 vector 可以 直接用 std::vector 不需要 使用 using namespace std; (或者 std::map) 我用 VC6 !
schlafenhamster 2018-03-10
  • 打赏
  • 举报
回复
GpPathIterator **iterator 这个 iterator 参数名 有问题 ? 改 iterator_ 试试
vc8fans 2018-03-10
  • 打赏
  • 举报
回复
非常感谢大家热心帮助, 试了还是不行,,到底啥回事???我是在VC6 编译环境 下的,这个程序是2005网上的, 作者是编译出来了,放在演示包中 ,,源代码 删除了 GDI+ 环境,,或许是卖个关子,,,那位热心 高手能帮下忙? 类似问题 搜 过 CSDN 10年前也有人提出,至今没解决也没有结帖??难道又是无终而果了,,,有点不甘心!!
zgl7903 2018-03-10
  • 打赏
  • 举报
回复
VS的版本 与 GDI+ 的版本需要留意下, 版本太高的GDI+中的某些定义 不能被低版本的VS识别
vc8fans 2018-03-10
  • 打赏
  • 举报
回复
typedef unsigned long ULONG_PTR, *PULONG_PTR; 光 加这个不行,哪位再帮看一下 资源在这里:哪位高手能抽空 下个看看 http://www.newxing.com/Code/VC/TXCL/3542.html 这个资源对我来将很不错,研究了<基于GDI技术的VC++公交线路查询系统> 源代码
schlafenhamster 2018-03-10
  • 打赏
  • 举报
回复
好像 是 using namespace std; 的 问题 把 using namespace std; 把它放到那个 需要他的文件 h 里 如 class XTube 不要在 stdafx.h 里
schlafenhamster 2018-03-10
  • 打赏
  • 举报
回复
c:\test\gdiplus\include\gdiplusflat.h(291) : error C2955: 'iterator' : use of class template requires template argument list c:\program files (x86)\microsoft visual studio\vc98\include\utility(71) : see declaration of 'iterator' 与 utility 中的 重名了 ?
houjiahong 2018-03-10
  • 打赏
  • 举报
回复
等待楼主的解决方案,学习一下!
vc8fans 2018-03-10
  • 打赏
  • 举报
回复
按楼上该,越改问题越多,,查了百度,CSDN,,这个问题2005年 都有网友提出,都没有结帖?这个难道没有解了?
加载更多回复(2)

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧