tagPoint and GDIPlus Point

Posted on 2006-05-29
Last Modified: 2008-01-16

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?



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


      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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

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

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now