[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

tagPoint and GDIPlus Point

Hi,

I really wonder how can i solve this problem.

POINT pst = Point(x,y);

This statement gave me error above:

cannot convert from 'class Gdiplus::Point' to 'struct tagPOINT'

This is the exact syntax where i see from most of the question in here, i spend whole days to search for the answer but hopeless.

i wonder is it because im including gdiplus.h and the Point in gdiplus is not convertable to tagPoint?

URGENT!

Thanks

Regards
0
iphone
Asked:
iphone
  • 2
1 Solution
 
AlexFMCommented:
POINT pst(x,y);

If you want to create POINT from GDI+ point, you can write:

Point p(10, 20);    // GDI+
...
POINT pst(p.X, p.Y);   // GDI
0
 
AlexFMCommented:
GDI+ Point class doesn't have any functions and conversion operators between Point and GDI POINT. In any case, you can use class members to do this:

POINT pst;
Point p;
...

// POINT = Point
p.X = pst.x;
p.Y = pst.y;

// Point = POINT
pst.x = p.X;
pst.Y = p.Y;
0
 
itsmeandnobodyelseCommented:
>>>> POINT pst(x,y);

That doesn't work as struct tagPOINT doesn't have a constructor.

You could initialize a POINT (what is a typedef of tagPOINT) by

  POINT pt = { 10, 20 };

or

  POINT pt = { ptgdi.X, ptgdi.Y };

provided ptgdi is of type Gdiplus::Point and X, Y are members of Gdiplus::Point.


You also could write a little helper function like that:

POINT Pg2Pt(const Point& pg)
{
   POINT pt = { pg.X, pg.Y };
   return pt;
}

and use it like that

  Point pg(10, 20);
  POINT p = Pg2Pt(pg);


Regards, Alex
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now