Author: Maarten de Haan How to draw a line in a RichEdit (just like in the Delphi editor) Answer: procedure DrawLine; 1 var 2 aCanvas: Tcanvas; 3 X1, X2, Y1: Integer; 4 byLineLength: BYTE; 5 6 begin 7 byLineLength := 80; // Draw the line after 80 chars on the RichEdit 8 aCanvas := TCanvas.Create; 9 Y1 := RichEdit1.Height; 10 try 11 aCanvas.Handle := GetDC(RichEdit1.Handle); 12 aCanvas.Font := RichEdit1.Font; 13 X1 := aCanvas.TextWidth('W'); 14 X2 := aCanvas.TextWidth('i'); 15 aCanvas.Pen.color := clSilver; // Color of line 16 if X1 = X2 then // Check for fixed or variable font 17 begin 18 aCanvas.MoveTo(byLineLength * X1, 0); 19 aCanvas.LineTo(byLineLength * X1, Y1); 20 end; 21 finally 22 ReleaseDC(RichEdit1.Handle, aCanvas.Handle); 23 aCanvas.Free; 24 end; 25 end;