diff --git a/components/ideintf/lazideintf.pas b/components/ideintf/lazideintf.pas index 8558e183a3..0fa0c44263 100644 --- a/components/ideintf/lazideintf.pas +++ b/components/ideintf/lazideintf.pas @@ -570,6 +570,7 @@ type function GetTabDisplayState: TTabDisplayState; virtual; abstract; function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract; public + function AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; virtual; abstract; procedure ToggleFormUnit; virtual; abstract; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract; diff --git a/components/sparta/dockedformeditor/source/sparta_mainide.pas b/components/sparta/dockedformeditor/source/sparta_mainide.pas index 34c6b7a993..486c307bd6 100644 --- a/components/sparta/dockedformeditor/source/sparta_mainide.pas +++ b/components/sparta/dockedformeditor/source/sparta_mainide.pas @@ -21,7 +21,7 @@ uses {$IFDEF USE_GENERICS_COLLECTIONS} Generics.Collections, Generics.Defaults, {$ELSE} - ghashmap, sparta_HashUtils, gvector, + ghashmap, sparta_HashUtils, gvector, contnrs, {$ENDIF} // LCL LCLIntf, LCLType, LMessages, ComCtrls, Controls, Forms, ExtCtrls, Graphics, @@ -121,10 +121,16 @@ type { TDTXTabMaster } TDTXTabMaster = class(TIDETabMaster) + private + FAutoSizeFormList: TObjectList; protected function GetTabDisplayState: TTabDisplayState; override; function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; override; public + constructor Create; + destructor Destroy; override; + function AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; override; + procedure EnableAutoSizing(AForm: TCustomForm); procedure ToggleFormUnit; override; procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); override; @@ -787,6 +793,36 @@ begin end; end; +constructor TDTXTabMaster.Create; +begin + FAutoSizeFormList := TObjectList.Create(False); +end; + +destructor TDTXTabMaster.Destroy; +begin + FAutoSizeFormList.Free; + inherited Destroy; +end; + +function TDTXTabMaster.AutoSizeInShowDesigner(AForm: TCustomForm): Boolean; +begin + FAutoSizeFormList.Add(AForm); + Result := True; +end; + +procedure TDTXTabMaster.EnableAutoSizing(AForm: TCustomForm); +var + AIndex: Integer; +begin + AIndex := FAutoSizeFormList.IndexOf(AForm); + if Assigned(AForm) and (AIndex >= 0) and IsFormDesign(AForm) + and (not (AForm is TNonControlProxyDesignerForm)) and (not (AForm is TFrameProxyDesignerForm)) then + begin + FAutoSizeFormList.Delete(AIndex); + AForm.EnableAutoSizing; + end; +end; + procedure TDTXTabMaster.ToggleFormUnit; begin case TabDisplayState of @@ -816,6 +852,8 @@ end; procedure TDTXTabMaster.ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer); var LPageCtrl: TModulePageControl; + Designer: TIDesigner; + Form: TCustomForm; begin if ASourceEditor = nil then Exit; @@ -1439,6 +1477,8 @@ begin end; LSourceWndData.ActiveDesignFormData := LFormData; + // enable autosizing after creating a new form, see issue #32207 + TDTXTabMaster(IDETabMaster).EnableAutoSizing(LFormData.Form.Form); // to handle windows with different size LPageCtrl.BoundToDesignTabSheet; end; diff --git a/ide/main.pp b/ide/main.pp index 151420444d..b136d73355 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -3551,9 +3551,12 @@ begin AForm.WindowState := wsMinimized; exit; end; - // do not call 'AForm.Show', because it will set Visible to true - AForm.BringToFront; - LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL); + if IDETabMaster = nil then + begin + // do not call 'AForm.Show', because it will set Visible to true + AForm.BringToFront; + LCLIntf.ShowWindow(AForm.Handle,SW_SHOWNORMAL); + end; end; procedure TMainIDE.DoViewAnchorEditor(State: TIWGetFormState); diff --git a/ide/sourcefilemanager.pas b/ide/sourcefilemanager.pas index 64eb6bf5b6..8e8313fe64 100644 --- a/ide/sourcefilemanager.pas +++ b/ide/sourcefilemanager.pas @@ -2077,6 +2077,7 @@ var Src: String; i: Integer; LFindDesignerBaseClassByName: Boolean = True; + PreventAutoSize: Boolean; begin //debugln('TLazSourceFileManager.NewFile A NewFilename=',NewFilename); // empty NewFilename is ok, it will be auto generated @@ -2291,7 +2292,15 @@ begin DisableAutoSize); if DisableAutoSize and (NewUnitInfo.Component<>nil) and (NewUnitInfo.Component is TControl) then - TControl(NewUnitInfo.Component).EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF}; + begin + // disable autosizing for docked form editor forms, see issue #32207 + PreventAutoSize := (IDETabMaster <> nil) + and (NewUnitInfo.Component is TCustomForm) + and (IsFormDesign(NewUnitInfo.Component as TCustomForm)) + and IDETabMaster.AutoSizeInShowDesigner(NewUnitInfo.Component as TCustomForm); + if not PreventAutoSize then + TControl(NewUnitInfo.Component).EnableAutoSizing{$IFDEF DebugDisableAutoSizing}('TAnchorDockMaster Delayed'){$ENDIF}; + end; end; if Result<>mrOk then begin