• Status: Solved
• Priority: Medium
• Security: Public
• Views: 761

# 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
• 2
1 Solution

Commented:
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

Commented:
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

Commented:
>>>> 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

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