From a188d432fd8729cbf585f9248897ed1138067488 Mon Sep 17 00:00:00 2001 From: lazarus Date: Sun, 8 Sep 2002 10:01:59 +0000 Subject: [PATCH] MG: fixed streaming visible=false git-svn-id: trunk@3299 - --- designer/jitforms.pp | 28 +++++++++++++++++++++------- lcl/forms.pp | 30 ++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/designer/jitforms.pp b/designer/jitforms.pp index c255bdb339..e810deb2d0 100644 --- a/designer/jitforms.pp +++ b/designer/jitforms.pp @@ -305,10 +305,29 @@ end; function TJITForms.AddJITFormFromStream(BinStream:TStream):integer; // returns new index // -1 = invalid stream + + procedure ApplyVisible; + var + i: integer; + AControl: TControl; + begin + // The LCL has as default Visible=false. But for Delphi compatbility + // loading control defaults to true. + for i:=0 to FCurReadForm.ComponentCount-1 do begin + AControl:=TControl(FCurReadForm.Components[i]); + if (AControl is TControl) then begin + if (not (csVisibleSetInLoading in AControl.ControlState)) then + AControl.Visible:=true + else + AControl.ControlState:= + AControl.ControlState-[csVisibleSetInLoading]; + end; + end; + end; + var Reader:TReader; NewClassName:shortstring; - a:integer; NewName: string; begin Result:=-1; @@ -361,12 +380,7 @@ begin {$IFDEF IDE_VERBOSE} writeln('[TJITForms.AddJITFormFromStream] 5'); {$ENDIF} - // MG: workaround til visible=true is default - for a:=0 to FCurReadForm.ComponentCount-1 do begin - if FCurReadForm.Components[a] is TControl then - TControl(FCurReadForm.Components[a]).Visible:=true; - end; - // MG: end of workaround + ApplyVisible; {$IFDEF IDE_VERBOSE} writeln('[TJITForms.AddJITFormFromStream] 6'); diff --git a/lcl/forms.pp b/lcl/forms.pp index f5d0a04f0f..c7671767f7 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -415,10 +415,30 @@ function InitResourceComponent(Instance: TComponent; RootAncestor: TClass):Boolean; function InitComponent(ClassType: TClass): Boolean; + + procedure ApplyVisible; + var + i: integer; + AControl: TControl; + begin + // The LCL has as default Visible=false. But for Delphi compatbility + // loading control defaults to true. + if Instance is TControl then + for i:=0 to Instance.ComponentCount-1 do begin + AControl:=TControl(Instance.Components[i]); + if (AControl is TControl) then begin + if (not (csVisibleSetInLoading in AControl.ControlState)) then + AControl.Visible:=true + else + AControl.ControlState:= + AControl.ControlState-[csVisibleSetInLoading]; + end; + end; + end; + var CompResource:TLResource; MemStream: TMemoryStream; - a:integer; begin //writeln('[InitComponent] ',ClassType.Classname,' ',Instance<>nil); Result:=false; @@ -444,13 +464,7 @@ function InitResourceComponent(Instance: TComponent; end; end; finally - // MG: workaround til Visible=true is default - if Instance is TControl then - for a:=0 to Instance.ComponentCount-1 do - if Instance.Components[a] is TControl then begin - TControl(Instance.Components[a]).Visible:=true; - end; - // MG end of workaround + ApplyVisible; MemStream.Free; end; Result:=true;