Thread: Canvas.lineto

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Canvas.lineto


    Hello!

    in my forms onactivate I have the following code;

    var x,y : integer;
    begin
    x:=100; y:=50;
    canvas.moveto(x,y);
    canvas.pen.color:=clblack;
    canvas.lineto(x+50,y+50);
    end;

    but this line is not showing on the form, because I have a big tshape rectangel over that position, and want the line to appear in the front of that, but it looks like it lays in the back. Anybody know how I can get the line in front??

    TIA
    Regards
    Kåre!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    3
    but this line is not showing on the form, because I have a big tshape rectangel over that position, and want the line to appear in the front of that, but it looks like it lays in the back. Anybody know how I can get the line in front??
    You can't, for two reasons.

    • TShape drawing will always be done after your draw. So, your line will always be overwritten.
    • The rest of the line (which did not get overwritten by the TShape) will be erased the next time the form refresh itself (i.e. handling WM_PAINT, WM_ERASEBKGND, and similar windows messages).


    The quickest workaround would be to draw directly on the screen/desktop. But you need to synchronize both the time to draw (and erase the drawing should it needed) and location (because now you draw to the desktop, not on your form).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0
    Is there any other way of drawing lines from the onactivate procedure??

    Kåre!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    3
    The main problem is that your drawing will not persisted. It will be gone the next time the form refresh its display. I can't see why you need to do the drawing in OnActivate. You can just set a flag there and do the drawing in OnPaint event of the form (i.e. your drawing only to be done when the flag was set).

    Btw, OnPaint will not be triggered unless previously OnActivated was fired. So actually you don't need to do the drawing in OnActivate or using flag.

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo