Solved

# tagPoint and GDIPlus Point

Posted on 2006-05-29
607 Views
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
Question by:iphone

LVL 48

Expert Comment

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

LVL 48

Accepted Solution

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

LVL 39

Expert Comment

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why tâ€¦
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilationâ€¦
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.