Dynamically highlight textbox

Top  Previous  Next

The event BeforePaintLayer can be used to show a special background while a text box is beeing edited.

 

procedure TForm1.WPRichText1BeforePaintLayer(Sender: TObject;

 Editor: TWPRTFEnginePaint; RTFData: TWPRTFDataBlock; Canvas: TCanvas;

 R: TRect; InEditor, IsEditing: Boolean);

begin

    if InEditor and IsEditing and (RTFData.Kind = wpIsOwnerSelected) then

      begin

         Canvas.Brush.Style := bsSolid;

         Canvas.Brush.Color := $eaefea;

         InflateRect(r,-5,-5);

         Canvas.FillRect( r );

      end;

end;