How to copy text from a TRichEdit to the canvas of a TImage (Views: 29)
Problem/Question/Abstract: How to copy text from a TRichEdit to the canvas of a TImage Answer: uses Richedit; var imagecanvas: TCanvas; fmt: TFormatRange; begin imagecanvas := image1.canvas; with fmt do begin hdc := imagecanvas.handle; hdcTarget := hdc; rc := Rect(0, 0, imagecanvas.cliprect.right * 1440 div pixelsperinch, imagecanvas.cliprect.bottom * 1440 div pixelsperinch); rcPage := rc; chrg.cpMin := 0; chrg.cpMax := richedit1.GetTextLen; end; { SetBkMode( imagecanvas.Handle, TRANSPARENT ); } richedit1.perform(EM_FORMATRANGE, 1, integer(@fmt)); richedit1.perform(EM_FORMATRANGE, 0, 0); image1.refresh; end; |