Hi Ralf, Well, by creating an decedent component I don't have to write the OnMouseEnter/Leave event handlers - this is the only benefit and I believe it's the benefit of OOP. Below is my derived component, I added two properties: HotColor Hot. Source: unit MyHtmlLabel; interface uses SysUtils, Classes, Controls, DIHtmlLabel, Messages, Graphics, Math; type TMyHtmlLabel = class(TDIHtmlLabel) strict private FHot: Boolean; FHotColor: TColor; procedure SetHot(const Value: Boolean); procedure SetHotColor(const Value: TColor); private procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; { Private declarations } protected procedure Paint; override; public constructor Create(AOwner: TComponent); published property Hot: Boolean read FHot write SetHot default False; property HotColor: TColor read FHotColor write SetHotColor default clSkyBlue; end; procedure Register; implementation procedure Register; begin RegisterComponents('Edwin', [TMyHtmlLabel]); end; constructor TMyHtmlLabel.Create(AOwner: TComponent); begin inherited Create(AOwner); HotColor := $00FFF2F2; end; procedure TMyHtmlLabel.CMMouseEnter(var Msg: TMessage); begin inherited; Hot := True; // if Assigned(FOnMouseEnter) then // FOnMouseEnter(self); end; procedure TMyHtmlLabel.CMMouseLeave(var Msg: TMessage); begin inherited; Hot := False; // if Assigned(FOnMouseLeave) then // FOnMouseLeave(self); end; procedure TMyHtmlLabel.Paint; begin // no calling inherited here. the following code is modified based on TDiHtmlLabel.Paint. if Assigned(FNodeTree) then begin with Canvas do begin if Hot then begin Brush.Color := Self.HotColor; Brush.Style := bsSolid; FillRect(ClientRect); end else if not Transparent then begin Brush.Color := Self.Color; Brush.Style := bsSolid; FillRect(ClientRect); end else Brush.Style := bsClear; end; Canvas.Font := Font; Renderer.RenderTree(Canvas, FRect, FNodeTree); if AutoHeight and (Align in [alNone, alTop, alBottom]) then ClientHeight := Renderer.TextHeight + MarginHeight; end; if Assigned(OnAfterPaint) then OnAfterPaint(Self); end; procedure TMyHtmlLabel.SetHot(const Value: Boolean); begin if FHot <> Value then begin FHot := Value; Invalidate; end; end; procedure TMyHtmlLabel.SetHotColor(const Value: TColor); begin if FHotColor <> Value then begin FHotColor := Value; end; end; end. On Mon, Feb 20, 2012 at 7:01 AM, Delphi Inspiration <delphi@xxxxxxxx> wrote: > On 19.02.2012 14:56, Edwin Yip wrote: > > > Yes, when drawing the background to indicate the 'hot' status of the > > label, I use ClientRect, but since in my overridden Paint() method I > > can't call inherited, instead I have to copy and modify the method body > > of TDiHtmlLabel which needs to access the FRect field in order to paint > > the html tags. > > > > Precisely, it's the following code: > > Renderer.RenderTree(Canvas, FRect, FNodeTree); > > I still do not understand why you want to go the extra way. Attached is > a project which demonstrates my concept. The archive also contains the > updated DIHtmlLabel.pas unit which you must install into the Delphi IDE > to open the form in design-view. A simple compile should work without > installation. > > If your solution has benefits over my approach, I'd be interested if you > could share your code. > > Ralf > -- Best Regards, Edwin Yip Mind Mapping is as Effortless as Typing http://www.InnovationGear.com