LCL: OnResize and OnChangeBounds are now suspended after OnCreate

git-svn-id: trunk@10360 -
This commit is contained in:
mattias 2006-12-30 11:48:48 +00:00
parent 2d42b48ed2
commit 3f4887140f
6 changed files with 49 additions and 8 deletions

View File

@ -561,9 +561,9 @@ type
TPersistentPropertyEditor = class(TPropertyEditor) TPersistentPropertyEditor = class(TPropertyEditor)
protected protected
function FilterFunc(const ATestEditor: TPropertyEditor{IProperty}): Boolean; function FilterFunc(const ATestEditor: TPropertyEditor): Boolean;
function GetPersistentReference: TPersistent; virtual; function GetPersistentReference: TPersistent; virtual;
function GetSelections: TPersistentSelectionList{IDesignerSelections}; virtual; function GetSelections: TPersistentSelectionList; virtual;
public public
function AllEqual: Boolean; override; function AllEqual: Boolean; override;
procedure Edit; override; procedure Edit; override;

View File

@ -739,7 +739,9 @@ type
cfClientHeightLoaded, cfClientHeightLoaded,
cfLastAlignedBoundsValid, cfLastAlignedBoundsValid,
cfBoundsRectForNewParentValid, cfBoundsRectForNewParentValid,
cfPreferredSizeValid cfPreferredSizeValid,
cfOnResizeNeeded,
cfOnChangeBoundsNeeded
); );
TControlFlags = set of TControlFlag; TControlFlags = set of TControlFlag;
@ -1025,6 +1027,7 @@ type
procedure Loaded; override; procedure Loaded; override;
procedure DefineProperties(Filer: TFiler); override; procedure DefineProperties(Filer: TFiler); override;
procedure AssignTo(Dest: TPersistent); override; procedure AssignTo(Dest: TPersistent); override;
procedure FormEndUpdated; virtual;
procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque: Boolean); procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque: Boolean);
procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque, IgnoreWinControls: Boolean); procedure InvalidateControl(CtrlIsVisible, CtrlIsOpaque, IgnoreWinControls: Boolean);
procedure FontChanged(Sender: TObject); virtual; procedure FontChanged(Sender: TObject); virtual;
@ -1164,6 +1167,7 @@ type
function GetTopParent: TControl; function GetTopParent: TControl;
function IsVisible: Boolean; virtual; function IsVisible: Boolean; virtual;
function IsControlVisible: Boolean; virtual; function IsControlVisible: Boolean; virtual;
function FormIsUpdating: boolean; virtual;
procedure Hide; procedure Hide;
procedure Refresh; procedure Refresh;
procedure Repaint; virtual; procedure Repaint; virtual;
@ -1636,6 +1640,7 @@ type
procedure FontChanged(Sender: TObject); override; procedure FontChanged(Sender: TObject); override;
procedure InitializeWnd; virtual; // gets called after the Handle is created and before the child handles are created procedure InitializeWnd; virtual; // gets called after the Handle is created and before the child handles are created
procedure Loaded; override; procedure Loaded; override;
procedure FormEndUpdated; override;
procedure MainWndProc(var Msg: TLMessage); procedure MainWndProc(var Msg: TLMessage);
procedure ParentFormHandleInitialized; override; procedure ParentFormHandleInitialized; override;
procedure ChildHandlesCreated; virtual;// called after childs handles are created procedure ChildHandlesCreated; virtual;// called after childs handles are created

View File

@ -423,7 +423,6 @@ type
protected protected
FFormBorderStyle: TFormBorderStyle; FFormBorderStyle: TFormBorderStyle;
FActionLists: TList; FActionLists: TList;
function FormUpdating: boolean;
procedure Activate; dynamic; procedure Activate; dynamic;
procedure ActiveChanged; dynamic; procedure ActiveChanged; dynamic;
procedure BeginFormUpdate; procedure BeginFormUpdate;
@ -448,6 +447,7 @@ type
procedure UpdateWindowState; procedure UpdateWindowState;
procedure VisibleChanging; override; procedure VisibleChanging; override;
procedure WndProc(var TheMessage : TLMessage); override; procedure WndProc(var TheMessage : TLMessage); override;
function FormIsUpdating: boolean; override;
function VisibleIsStored: boolean; function VisibleIsStored: boolean;
function ColorIsStored: boolean; override; function ColorIsStored: boolean; override;
procedure DoSendBoundsToInterface; override; procedure DoSendBoundsToInterface; override;

View File

@ -656,6 +656,11 @@ begin
and (not (csNoDesignVisible in ControlStyle)))); and (not (csNoDesignVisible in ControlStyle))));
end; end;
function TControl.FormIsUpdating: boolean;
begin
Result:=(Parent<>nil) and Parent.FormIsUpdating;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TControl.LMCaptureChanged TControl.LMCaptureChanged
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -823,6 +828,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.DoOnResize; procedure TControl.DoOnResize;
begin begin
Exclude(FControlFlags,cfOnResizeNeeded);
if Assigned(FOnResize) then FOnResize(Self); if Assigned(FOnResize) then FOnResize(Self);
DoCallNotifyHandler(chtOnResize); DoCallNotifyHandler(chtOnResize);
end; end;
@ -834,6 +840,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.DoOnChangeBounds; procedure TControl.DoOnChangeBounds;
begin begin
Exclude(FControlFlags,cfOnChangeBoundsNeeded);
if Assigned(FOnChangeBounds) then FOnChangeBounds(Self); if Assigned(FOnChangeBounds) then FOnChangeBounds(Self);
DoCallNotifyHandler(chtOnChangeBounds); DoCallNotifyHandler(chtOnChangeBounds);
end; end;
@ -848,6 +855,10 @@ begin
CurClientSize:=Point(ClientWidth,ClientHeight); CurClientSize:=Point(ClientWidth,ClientHeight);
if (not CompareRect(@FLastDoChangeBounds,@CurBounds)) if (not CompareRect(@FLastDoChangeBounds,@CurBounds))
or (ComparePoints(CurClientSize,FLastDoChangeClientSize)<>0) then begin or (ComparePoints(CurClientSize,FLastDoChangeClientSize)<>0) then begin
if FormIsUpdating then begin
Include(FControlFlags,cfOnChangeBoundsNeeded);
exit;
end;
FLastDoChangeBounds:=CurBounds; FLastDoChangeBounds:=CurBounds;
FLastDoChangeClientSize:=CurClientSize; FLastDoChangeClientSize:=CurClientSize;
DoOnChangeBounds; DoOnChangeBounds;
@ -2515,15 +2526,20 @@ end;
procedure TControl.Resize; procedure TControl.Resize;
begin begin
if ([csLoading,csDestroying]*ComponentState<>[]) then exit; if ([csLoading,csDestroying]*ComponentState<>[]) then exit;
if (FLastResizeWidth<>Width) or (FLastResizeHeight<>Height) if (FLastResizeWidth<>Width) or (FLastResizeHeight<>Height)
or (FLastResizeClientWidth<>ClientWidth) or (FLastResizeClientWidth<>ClientWidth)
or (FLastResizeClientHeight<>ClientHeight) then begin or (FLastResizeClientHeight<>ClientHeight) then begin
if FormIsUpdating then begin
Include(FControlFlags,cfOnResizeNeeded);
exit;
end;
//if AnsiCompareText('NOTEBOOK',Name)=0 then //if AnsiCompareText('NOTEBOOK',Name)=0 then
{DebugLn('[TControl.Resize] ',Name,':',ClassName, {DebugLn(['[TControl.Resize] ',Name,':',ClassName,
' Last=',FLastResizeWidth,',',FLastResizeHeight, ' Last=',FLastResizeWidth,',',FLastResizeHeight,
' LastClient=',FLastResizeClientWidth,',',FLastResizeClientHeight, ' LastClient=',FLastResizeClientWidth,',',FLastResizeClientHeight,
' New=',Width,',',Height, ' New=',Width,',',Height,
' NewClient=',ClientWidth,',',ClientHeight);} ' NewClient=',ClientWidth,',',ClientHeight]);}
FLastResizeWidth:=Width; FLastResizeWidth:=Width;
FLastResizeHeight:=Height; FLastResizeHeight:=Height;
FLastResizeClientWidth:=ClientWidth; FLastResizeClientWidth:=ClientWidth;
@ -2612,6 +2628,16 @@ begin
else inherited AssignTo(Dest); else inherited AssignTo(Dest);
end; end;
procedure TControl.FormEndUpdated;
// called when control is on a form and EndFormUpdate reached 0
// it is called recursively
begin
if cfOnResizeNeeded in FControlFlags then
Resize;
if cfOnChangeBoundsNeeded in FControlFlags then
CheckOnChangeBounds;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TControl SetBounds TControl SetBounds
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}

View File

@ -694,6 +694,7 @@ procedure TCustomForm.EndFormUpdate;
begin begin
dec(FFormUpdateCount); dec(FFormUpdateCount);
if FFormUpdateCount=0 then begin if FFormUpdateCount=0 then begin
FormEndUpdated;
Visible:=(fsVisible in FFormState); Visible:=(fsVisible in FFormState);
end; end;
end; end;
@ -720,9 +721,9 @@ begin
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TCustomForm.FormUpdating: boolean; function TCustomForm.FormIsUpdating: boolean;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TCustomForm.FormUpdating: boolean; function TCustomForm.FormIsUpdating: boolean;
begin begin
Result:=FFormUpdateCount>0; Result:=FFormUpdateCount>0;
end; end;

View File

@ -5405,6 +5405,15 @@ begin
ReAlign; ReAlign;
end; end;
procedure TWinControl.FormEndUpdated;
var
i: Integer;
begin
inherited FormEndUpdated;
for i:=0 to ControlCount-1 do
Controls[i].FormEndUpdated;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TWinControl.DestroyWnd Method: TWinControl.DestroyWnd
Params: None Params: None