Search code examples
.netvisual-studiomanaged-c++

Converting 'System::Drawing::PointF* to 'System::Drawing::PointF error


I'm writing a C++.NET 4.0 program that involves a form in Visual Studio 2010. I'm adding a GraphicsPath to a Form. Here's part of my code:

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

Compile and I get an error

 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'

So I change it to

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

and get more errors

1>LINK : error LNK2034: metadata inconsistent with COFF symbol table: symbol '??3@$$FYAXPAX@Z' (060000A7) has inconsistent metadata with (0A00001A) in MSVCURTD.lib(delete2.obj)
1>LINK : error LNK2034: metadata inconsistent with COFF symbol table: symbol '??3@$$FYAXPAX@Z' (060000A7) has inconsistent metadata with (0A000029) in MSVCURTD.lib(ti_inst.obj)
1>MSVCURTD.lib(delete2.obj) : error LNK2020: unresolved token (0A00001A) "void __cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
1>MSVCURTD.lib(ti_inst.obj) : error LNK2020: unresolved token (0A000029) "void __cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
1>D:\Projects\SmartProjector\scratch\VS\Debug\CPPHelloWorld.exe : fatal error LNK1120: 2 unresolved externals

It should be simple, just convert the pointer to the PointF it actually points to but things get complicated for some reason I don't know.

Could you tell me the correct way to use the System::Drawing::Drawing2D::GraphicsPath::AddString() function? Remember I'm using C++, not C#


Solution

  • Have you tried:

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

    this is at least the correct method signature