print rich text or memo to canvas

I am begginer and i need detailed answer on this question
I need to draw a bitmap on canvas (taht part is ok)
but on that bitamp i need to print content of the rich text box (document contain text and pictures) so that i can have effect of text and pics over background image (like background in html)
Also i must be able to print only a part of rich text box content (let's say 200 pixels or (xx lines))
(i need this beacouse i wont to simulate scrolling effects (let's say i have button and per each clikc i will restore background and display other part of rich document so that i can have effects of scrolling document))
Who is Participating?
kretzschmarConnect With a Mentor Commented:
hi xtvca,

a sample from my paq
paints a specific line (can contain various fonts and colors) from a richedit to a specific position of a bitmap

 Procedure CopyLineFromRichEditToBitmap(R : TRichEdit;
                                        Line : Integer;
                                        B : TBitMap;
                                        AtPos : TPoint);
   I, C, MH, H, W : Integer;  //Counter, CharPos, MaxHeight, CharHeight, CharWidth
   TB, TB2 : TBitmap;         //Temporary Bitmaps
   TB := TBitmap.Create;      //Create Temporary
   TB2 := TBitmap.Create;
   MH := 0;                   //Initialize
   H := 0;
   TB.Height := 100;
   TB.Width := 5;
   C := R.Perform(EM_LINEINDEX,Line,0);
   for I := 0 to Length(R.Lines[Line]) do  //Paint Line
     R.Selstart := C+I;
     R.SelLength := 1;
     TB.Canvas.Font.Assign(R.SelAttributes);  //Assign CharAttributes
     W := TB.Canvas.TextWidth(R.SelText);
     TB.Width := TB.Width + W;                //Expand Bitmap
     H := TB.Canvas.TextHeight(R.SelText);
     if MH < H then                           // MaxHeight
       MH := H;
     TB.Canvas.TextOut(TB.Width-W,50-h,R.SelText);  //Paint a Char
   TB2.Width := TB.Width - 5;  //adjust Painting Rect
   Tb2.Height := MH;

   TB2.Transparent := True;   //Prepare
   TB2.TransparentMode := tmFixed;
   TB2.TransparentColor := clWhite;
   B.Canvas.Draw(AtPos.x,AtPos.Y,TB2);  //Paint to Original
   TB2.Free;  //Free Memory

Sounds like the scrolling memo problem a few weeks ago. Did anyone ever get that to work?
the only solution is to scroll to the beginning, then copy that portion that is visible, then scroll one whole page, copy that portion to the end of the previous and so on 'till you're done with the doc...

good luck

xtvcaAuthor Commented:
Thanks kretzschmar
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.