Paint line after line on a canvas

  • Hello,

    I'm in need to print line after line (not a whole page) on a canvas. Is this possible? The function Draw() seems to be a good starting point, but each line can have a different height, so I don't know how to set the offset.

    Any idea would be appreciated.
    Regards,
    Björn

  • Hello,

    could you please tell me why this code isn't working?

    Code
    PosY:=0;
    StartY:=0;
    while PosY<Image.ClientRect.Bottom do
    begin
      DrawRect:=Rect(Image.ClientRect.Left,Image.ClientRect.Top+PosY,
                     Image.ClientRect.Right,
                     Image.ClientRect.Top+PosY+80);
      StartY:=RichText.Draw(Image.Canvas,DrawRect,0,StartY);
      Inc(PosY,80);
    end;

    It just draws a white background.
    Regards,
    Björn

  • I figured that it was a problem with the margins and the resolution. The Draw function doesn't draw clipped, only whole lines are drawn and if the rectangle isn't big enough to draw one line it draws nothing and the starty parameter doesn't change.

    Is there a way to let the draw function draw clipped? There is a property Memo._NoClipping, but it doesn't change anything.

    The problem is, that we need to draw the text into a grid control and we have the restriction that we need to draw it in 20 pixel portions. Without clipping this is not directly possible. We would need to draw the text on another canvas and then copy each part to the canvas of the grid.

    To draw the text to another canvas, we would need to have the total height of the complete text, because the canvas needs to have the exact bounds of the text to read it in 20 pixel portions. Is this Memo.PageTextHeightPix? We always have only one page of text.

    This is a pretty complicated matter, but it decides whether we can use WPTools throughout our application.
    Any help would be appreciated,
    Björn