From 910a46ff7d02da270cdec024237b15b4446190fe Mon Sep 17 00:00:00 2001 From: zeljko Date: Fri, 8 Jul 2011 08:01:08 +0000 Subject: [PATCH] TCustomTrayIcon: added InternalShow() private proc, so it triggers TCustomTrayIcon.Show when component is loaded. Fixes problem when popupmenu isn't shown.See issue #19693 git-svn-id: trunk@31600 - --- lcl/extctrls.pp | 3 +++ lcl/include/customtrayicon.inc | 45 ++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index 629a1aa39b..4ac0eed1eb 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -1028,6 +1028,7 @@ type TCustomTrayIcon = class(TLCLComponent) private + FDelayedShowing: Boolean; FAnimate: Boolean; FAnimateTimer: TTimer; FCurAnimationStep: Integer; @@ -1047,6 +1048,7 @@ type FOnMouseMove: TMouseMoveEvent; function GetAnimateInterval: Cardinal; function GetCanvas: TCanvas; + function InternalShow: Boolean; procedure SetAnimate(const AValue: Boolean); procedure SetAnimateInterval(const AValue: Cardinal); procedure SetHint(const AValue: string); @@ -1061,6 +1063,7 @@ type protected class procedure WSRegisterClass; override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure Loaded; override; public Handle: HWND; constructor Create(TheOwner: TComponent); override; diff --git a/lcl/include/customtrayicon.inc b/lcl/include/customtrayicon.inc index 0d528425c7..b6f63c06a2 100644 --- a/lcl/include/customtrayicon.inc +++ b/lcl/include/customtrayicon.inc @@ -37,6 +37,7 @@ constructor TCustomTrayIcon.Create(TheOwner : TComponent); begin inherited Create(TheOwner); + FDelayedShowing := False; { Default property values } FBalloonTimeout := 3000; @@ -101,7 +102,9 @@ begin if not(csDesigning in ComponentState) then begin - Result := TWSCustomTrayIconClass(WidgetSetClass).Hide(Self); + Result := not (csLoading in ComponentState); + if Result then + Result := TWSCustomTrayIconClass(WidgetSetClass).Hide(Self); FVisible := not Result; FAnimateTimer.Enabled := False; end @@ -109,6 +112,27 @@ begin Result := false; end; +{******************************************************************* +* TCustomTrayIcon.InternalShow() +* +* DESCRIPTION: Called when component is loaded, if Show() is called during +* loading. +* +* PARAMETERS: None +* +* RETURNS: If successfull +* +*******************************************************************} +function TCustomTrayIcon.InternalShow: Boolean; +begin + FDelayedShowing := csLoading in ComponentState; + if FDelayedShowing then + exit(False); + Result := TWSCustomTrayIconClass(WidgetSetClass).Show(Self); + FVisible := Result; + FAnimateTimer.Enabled := FAnimate; +end; + {******************************************************************* * TCustomTrayIcon.Show () * @@ -126,13 +150,9 @@ begin FVisible := True; if not(csDesigning in ComponentState) then - begin - Result := TWSCustomTrayIconClass(WidgetSetClass).Show(Self); - FVisible := Result; - FAnimateTimer.Enabled := FAnimate; - end + Result := InternalShow else - Result := false; + Result := False; end; {******************************************************************* @@ -212,6 +232,13 @@ begin PopupMenu := nil; end; +procedure TCustomTrayIcon.Loaded; +begin + inherited Loaded; + if FDelayedShowing then + InternalShow; +end; + {******************************************************************* * TCustomTrayIcon.InternalUpdate () * @@ -232,7 +259,8 @@ end; *******************************************************************} procedure TCustomTrayIcon.InternalUpdate; begin - TWSCustomTrayIconClass(WidgetSetClass).InternalUpdate(Self); + if not (csLoading in ComponentState) then + TWSCustomTrayIconClass(WidgetSetClass).InternalUpdate(Self); end; {******************************************************************* @@ -352,3 +380,4 @@ begin end; // included by extctrls.pp +