LCL: delay autosizing when form is minimized

git-svn-id: trunk@33145 -
This commit is contained in:
mattias 2011-10-29 07:28:02 +00:00
parent 6f369dbff1
commit 2cd66811f0
5 changed files with 37 additions and 13 deletions

View File

@ -1302,7 +1302,7 @@ type
procedure AdjustSize; virtual;// smart calling DoAutoSize
function AutoSizePhases: TControlAutoSizePhases; virtual;
function AutoSizeDelayed: boolean; virtual;
function AutoSizeCheckParent: Boolean; virtual;
function AutoSizeDelayedHandle: Boolean; virtual;
procedure AnchorToNeighbour(Side: TAnchorKind; Space: integer;
Sibling: TControl);
procedure AnchorParallel(Side: TAnchorKind; Space: integer;
@ -1954,7 +1954,7 @@ type
// size, position, bounds
function AutoSizePhases: TControlAutoSizePhases; override;
function AutoSizeDelayed: boolean; override;
function AutoSizeCheckParent: Boolean; override;
function AutoSizeDelayedHandle: Boolean; override;
procedure BeginUpdateBounds; // disable SetBounds
procedure EndUpdateBounds; // enable SetBounds
procedure LockRealizeBounds; // disable sending bounds to widgetset

View File

@ -594,7 +594,7 @@ type
procedure IntfHelp(AComponent: TComponent);
function IsShortcut(var Message: TLMKey): boolean; virtual;
procedure MakeFullyVisible(AMonitor: TMonitor = nil; UseWorkarea: Boolean = False);
function AutoSizeCheckParent: Boolean; override;
function AutoSizeDelayedHandle: Boolean; override;
procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer;
Raw: boolean = false;
WithThemeSpace: boolean = true); override;

View File

@ -2585,8 +2585,8 @@ begin
// no autosize for invisible controls
or (not IsControlVisible)
// if there is no parent, then this control is not visible
// (TCustomForm will override this)
or not AutoSizeCheckParent
// (TWinControl and TCustomForm override this)
or AutoSizeDelayedHandle
// if there is a parent, ask it
or ((Parent<>nil) and Parent.AutoSizeDelayed);
{$IFDEF VerboseCanAutoSize}
@ -2597,20 +2597,26 @@ begin
else if csDestroying in ComponentState then debugln('csDestroying')
else if cfLoading in FControlFlags then debugln('cfLoading')
else if not IsControlVisible then debugln('not IsControlVisible')
else if not AutoSizeCheckParent then debugln('not AutoSizeCheckParent')
else if AutoSizeDelayedHandle then debugln('AutoSizeDelayedHandle')
else if ((Parent<>nil) and Parent.AutoSizeDelayed) then debugln('Parent.AutoSizeDelayed')
else debugln('?');
end;
{$ENDIF}
end;
function TControl.AutoSizeCheckParent: Boolean;
{------------------------------------------------------------------------------
TControl AutoSizeDelayedHandle
Returns true if AutoSize should be skipped / delayed because of its handle.
A TControl does not have a handle, so it needs a parent.
------------------------------------------------------------------------------}
function TControl.AutoSizeDelayedHandle: Boolean;
begin
Result := Parent <> nil;
Result := Parent = nil;
end;
{------------------------------------------------------------------------------
TControl SetBoundsRect
TControl SetBoundsRect
------------------------------------------------------------------------------}
procedure TControl.SetBoundsRect(const ARect: TRect);
begin

View File

@ -2128,9 +2128,21 @@ begin
//DebugLn(['TCustomForm.ShowOnTop ',Name,':',ClassName,' ',Visible,' ',HandleAllocated,' ',csDesigning in ComponentState]);
end;
function TCustomForm.AutoSizeCheckParent: Boolean;
{------------------------------------------------------------------------------
TCustomForm AutoSizeDelayedHandle
Returns true if AutoSize should be skipped / delayed because of its handle.
------------------------------------------------------------------------------}
function TCustomForm.AutoSizeDelayedHandle: Boolean;
begin
Result := True;
if WindowState=wsMinimized then
exit(true);
if (Parent<>nil) or (ParentWindow<>0) then
// this form is inlined / embedded it works like a normal TWinControl
Result:=inherited AutoSizeDelayedHandle
else
// this form is on a screen => no delay
Result:=false;
end;
{------------------------------------------------------------------------------}

View File

@ -2387,9 +2387,15 @@ begin
{$ENDIF}
end;
function TWinControl.AutoSizeCheckParent: Boolean;
{------------------------------------------------------------------------------
TWinControl AutoSizeDelayedHandle
Returns true if AutoSize should be skipped / delayed because of its handle.
A TWinControl needs a parent handle.
------------------------------------------------------------------------------}
function TWinControl.AutoSizeDelayedHandle: Boolean;
begin
Result := (Parent <> nil) or (ParentWindow <> 0);
Result := (Parent = nil) and (ParentWindow = 0);
end;
{------------------------------------------------------------------------------