locked
Why CDC::LineTo(pt) draw a line not include pt RRS feed

  • Question

  • By MSDN, that CDC::LineTo(pt) will draw a line to, but not include the specified "pt".

    Why is that? any special purpose?

    fitatc
    Thursday, December 10, 2009 5:04 AM

Answers

  • Hmmm....

    Well, at least this is documented.
    So I guess you will just have to live with MoveTo (0, 0); Line(4, 0);


    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by fitatc Monday, December 14, 2009 4:57 AM
    Thursday, December 10, 2009 5:45 AM

All replies

  • That is the way it is designed.
    Probably because coordinates are 0 based and not 1 based.

    «_Superman_»
    Microsoft MVP (Visual C++)
    Thursday, December 10, 2009 5:31 AM
  • thank you «_Superman_»

    If you are right about the coordinates, than
     1: "MoveTo(0,0); LineTo(3, 0);" will have the same pixel drawed to
     2: "MoveTo(3, 0); LineTo(0, 0);"

     which is not true..... this will turn out to be like :

    ■ ■ ■ 
       ■ ■ ■

    0 1 2 3
    fitatc
    Thursday, December 10, 2009 5:42 AM
  • Hmmm....

    Well, at least this is documented.
    So I guess you will just have to live with MoveTo (0, 0); Line(4, 0);


    «_Superman_»
    Microsoft MVP (Visual C++)
    • Marked as answer by fitatc Monday, December 14, 2009 4:57 AM
    Thursday, December 10, 2009 5:45 AM
  • Yeah, If all the line is that simple...

    Sorry I did not meantion before that I come to this question is because My drawing App makes a obviously different while the drawing dirction is changed.
    because of the LineTo problem.

    But as you said this is documented, it is my miss. I just confused about the reason.
    fitatc
    Thursday, December 10, 2009 5:53 AM
  • It's LineTo, not LineThrough...
    Thursday, December 10, 2009 6:17 AM
  • ildjarn
     thank you.

     but what's your point?  MoveTo should be MoveThrough too???


    fitatc
    Thursday, December 10, 2009 6:55 AM
  • I mean the semantics are right in the name, it shouldn't come as a surprise.
    Thursday, December 10, 2009 7:00 AM
  • Really?

    So what is the semantics of the LineTo?
    Do you mean that:
      When the word "to" combine with "Line", it should not include the specified point, Although if combine with "Move", it should.
      Or should I understand it as : move to a place you get there, but if you do drawing while moving, you donnot.

    This is normal?
    fitatc
    Thursday, December 10, 2009 7:39 AM
  • Hi Fitatc,

    CDC::LineTo draws a line from the current position up to, but not including, so you need to move current position to the position you want to draw line. As following code shows:

    dc.MoveTo(pointOld);
    dc.LineTo(pointNew);


    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, December 11, 2009 10:00 AM