Rich - criando uma linha estilo editor do Delphi |
Top Previous Next |
|
This code creates a line in a TRichEdit similar to the line in the Delphi editor, to indicate the fact that you have reached a certain amount of characters on that line.
//-------------------------------------------------------------------- Procedure TForm1.RichEdit1Change(Sender : TObject);
Var aCanvas : Tcanvas; X1,X2,Y : Integer;
Begin aCanvas := TCanvas.Create; Y := RichEdit1.Height; Try aCanvas.Handle := GetDC(RichEdit1.Handle); With aCanvas do Begin Font := RichEdit1.Font; X1 := TextWidth('W'); X2 := TextWidth('i'); Pen.color := clSilver; If X1 = X2 then // Simple way of testing for fixed font type Begin MoveTo(79 * X1,0); // Draw line after 80 characters LineTo(79 * X1,Y); End; End; Finally ReleaseDC(RichEdit1.Handle,aCanvas.Handle); aCanvas.Free; End; End; |