将'System :: Drawing :: PointF *转换为'System :: Drawing :: PointF错误

时间:2012-05-17 14:13:33

标签: .net visual-studio managed-c++

我正在编写一个涉及Visual Studio 2010中的表单的C ++ .NET 4.0程序。我正在向Form添加一个GraphicsPath。这是我的代码的一部分:

GraphicsPath^ gp=gcnew GraphicsPath();
gp->AddString("Hello world!", gcnew FontFamily("Arial"), (int) FontStyle::Italic, 26, (new PointF(100,100)), StringFormat::GenericDefault);

编译,我收到错误

 void System::Drawing::Drawing2D::GraphicsPath::AddString(System::String ^,System::Drawing::FontFamily ^,int,float,System::Drawing::PointF,System::Drawing::StringFormat ^)' : cannot convert parameter 5 from 'System::Drawing::PointF *' to 'System::Drawing::PointF'

所以我把它改成

 GraphicsPath^ gp=gcnew GraphicsPath();
gp->AddString("Hello world!", gcnew FontFamily("Arial"), (int) FontStyle::Italic, 26, *(new PointF(100,100)), StringFormat::GenericDefault);

并获得更多错误

  

1> LINK:错误LNK2034:元数据与COFF符号表不一致:符号'?? 3 @ $$ FYAXPAX @ Z'(060000A7)元数据不一致   与(0A00001A)在MSVCURTD.lib(delete2.obj)中       1> LINK:错误LNK2034:与COFF符号表不一致的元数据:符号'?? 3 @ $$ FYAXPAX @ Z'(060000A7)具有不一致的元数据   在MSVCURTD.lib(ti_inst.obj)中使用(0A000029)
      1> MSVCURTD.lib(delete2.obj):错误LNK2020:未解析的令牌(0A00001A)“void __cdecl operator delete(void *)”(?? 3 @ $$ FYAXPAX @ Z)
  1> MSVCURTD.lib(ti_inst.obj):错误LNK2020:未解析的令牌   (0A000029)“void __cdecl operator delete(void *)”(?? 3 @ $$ FYAXPAX @ Z)
      1> D:\ Projects \ SmartProjector \ scratch \ VS \ Debug \ CPPHelloWorld.exe:致命错误LNK1120:2个未解析的外部

它应该很简单,只需将指针转换为它实际指向的PointF,但由于某些我不知道的原因,事情变得复杂。

你能告诉我使用System :: Drawing :: Drawing2D :: GraphicsPath :: AddString()函数的正确方法吗?记住我使用的是C ++,而不是C#

1 个答案:

答案 0 :(得分:2)

你试过了吗?

gp->AddString("Hello world!", gcnew FontFamily("Arial"), (int) FontStyle::Italic, 26,  PointF(100,100), StringFormat::GenericDefault);

这至少是正确的方法签名