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

tagPoint and GDIPlus Point


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?



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


  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
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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