LCL: THintWindow: clean up

git-svn-id: trunk@29338 -
This commit is contained in:
mattias 2011-02-02 22:05:23 +00:00
parent c0b344ba6b
commit 247a494741
2 changed files with 11 additions and 15 deletions

View File

@ -815,7 +815,7 @@ type
FActivating: Boolean; FActivating: Boolean;
FAlignment: TAlignment; FAlignment: TAlignment;
FAutoHide: Boolean; FAutoHide: Boolean;
FAutoHideTimer: TComponent; FAutoHideTimer: TCustomTimer;
FHideInterval: Integer; FHideInterval: Integer;
function GetDrawTextFlags: Cardinal; function GetDrawTextFlags: Cardinal;
procedure SetAutoHide(Value : Boolean); procedure SetAutoHide(Value : Boolean);

View File

@ -26,8 +26,6 @@
const HintBorderWidth=2; const HintBorderWidth=2;
constructor THintWindow.Create(AOwner: TComponent); constructor THintWindow.Create(AOwner: TComponent);
var
TheTimer: TCustomTimer;
begin begin
// THintWindow has no resource => must be constructed using CreateNew // THintWindow has no resource => must be constructed using CreateNew
inherited CreateNew(AOwner, 1); inherited CreateNew(AOwner, 1);
@ -42,17 +40,15 @@ begin
with GetControlClassDefaultSize do with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY); SetInitialBounds(0, 0, CX, CY);
FHideInterval := 3000; FHideInterval := 3000;
TheTimer := TCustomTimer.Create(self); FAutoHideTimer := TCustomTimer.Create(self);
FAutoHideTimer := TheTimer; FAutoHideTimer.Interval := HideInterval;
TheTimer.Interval := HideInterval; FAutoHideTimer.Enabled := False;
TheTimer.Enabled := False; FAutoHideTimer.OnTimer := @AutoHideHint;
TheTimer.OnTimer := @AutoHideHint;
end; end;
destructor THintWindow.Destroy; destructor THintWindow.Destroy;
begin begin
fAutoHideTimer.Free; FreeAndNil(FAutoHideTimer);
fAutoHideTimer:=nil;
inherited Destroy; inherited Destroy;
end; end;
@ -60,7 +56,7 @@ procedure THintWindow.SetHideInterval(Value : Integer);
Begin Begin
FHideInterval := Value; FHideInterval := Value;
if FAutoHideTimer<>nil then if FAutoHideTimer<>nil then
TCustomTimer(FAutoHideTimer).Interval := FHideInterval; FAutoHideTimer.Interval := FHideInterval;
end; end;
class procedure THintWindow.WSRegisterClass; class procedure THintWindow.WSRegisterClass;
@ -110,14 +106,14 @@ procedure THintWindow.SetAutoHide(Value : Boolean);
Begin Begin
FAutoHide := Value; FAutoHide := Value;
if not (value) and (FAutoHideTimer<>nil) then if not (value) and (FAutoHideTimer<>nil) then
TCustomTimer(FAutoHideTimer).Enabled := False; FAutoHideTimer.Enabled := False;
end; end;
procedure THintWindow.AutoHideHint(Sender : TObject); procedure THintWindow.AutoHideHint(Sender : TObject);
begin begin
if FAutoHideTimer <> nil then if FAutoHideTimer <> nil then
TCustomTimer(FAutoHideTimer).Enabled := False; FAutoHideTimer.Enabled := False;
if Visible then if Visible then
Visible := False; Visible := False;
end; end;
@ -192,8 +188,8 @@ begin
SetBounds(ARect.Left, ARect.Top, SetBounds(ARect.Left, ARect.Top,
ARect.Right - ARect.Left, ARect.Bottom - ARect.Top); ARect.Right - ARect.Left, ARect.Bottom - ARect.Top);
Visible := True; Visible := True;
TCustomTimer(FAutoHideTimer).Enabled := False; FAutoHideTimer.Enabled := False;
TCustomTimer(FAutoHideTimer).Enabled := FAutoHide; FAutoHideTimer.Enabled := FAutoHide;
if InvalidateNeeded then Invalidate; if InvalidateNeeded then Invalidate;
finally finally
FActivating := False; FActivating := False;