From 8ec9a4e5d4de4ba64e366643b19a0a5963f9eb16 Mon Sep 17 00:00:00 2001 From: maxim Date: Fri, 21 Sep 2018 22:45:48 +0000 Subject: [PATCH] Merged revision(s) 59031 #daee51d966, 59048-59050 #a62fcc7e69-#a62fcc7e69, 59083 #406ae30f3b from trunk: TFindDialog: fix setting Top/Left. Issue #0033528. ........ TFindDialog: slight improvement on r59031 #daee51d966. ........ TFindDialog: use Position := poMainFormCenter in CalcPosition instead of trying to calculate that by ourselves. Patch by Serge Anvarov. ........ TFindDialog: save FFindForm position upon close. ........ TFindDialog/TReplaceDialog: show dialog poScreenCenter in IDE; fix erratic behaviour of TReplaceDialog in IDE (wrong parent). Issue #0034297. ........ git-svn-id: branches/fixes_1_8@59122 - --- lcl/include/finddialog.inc | 35 +++++++++++++++++++++-------------- lcl/include/replacedialog.inc | 7 +++++-- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lcl/include/finddialog.inc b/lcl/include/finddialog.inc index be9f0167f5..994dbec043 100644 --- a/lcl/include/finddialog.inc +++ b/lcl/include/finddialog.inc @@ -81,7 +81,7 @@ begin BorderIcons := [biSystemMenu, biHelp]; Caption := 'Find'; //OnCreate := @FormCreate; - Position := poMainFormCenter; + //Position := poMainFormCenter; LCLVersion := '1.3'; @@ -407,6 +407,8 @@ end; procedure TFindDialog.DoCloseForm(Sender: TObject; var CloseAction: TCloseAction); begin if csDesigning in ComponentState then exit; + FFormTop := FFindForm.Top; + FFormLeft := FFindForm.Left; if Assigned(OnClose) then OnClose(Self); end; @@ -498,10 +500,9 @@ begin end; function TFindDialog.CreateForm: TForm; -Var - StrTmp : String; begin // do not use Self as Owner, otherwise as desgntime this will not work + //debugln(['TFindDialog.CreateForm: Left=',Left,', Top=',Top,', Position=',dbgs(position),', FFormLeft=',FFormLeft,', FFormTop=',FFormTop]); Result := TFindDialogForm.CreateNew(nil,Options); with TFindDialogForm(Result) do begin @@ -520,9 +521,9 @@ begin HelpButton.OnClick := @HelpClick; CancelButton.OnClick := @CancelClick; PopupMode := pmAuto; - // Init local property with defaut value - FFormTop := top; - FFormLeft := Left; + // Init local property with default value + Result.Top := FFormTop; + Result.Left := FFormLeft; end; end; @@ -576,15 +577,19 @@ begin end; procedure TFindDialog.CalcPosition(aForm:Tform); -Var - MfBound : Trect; - begin - MfBound := Application.MainForm.BoundsRect; - FFormTop := MfBound.Top + (((MfBound.Bottom - MfBound.Top) - aForm.Height) Div 2); - FFormLeft := MfBound.Left + (((MfBound.Right - MfBound.Left) - aForm.Width) Div 2); - aForm.Top := FFormTop; - aForm.Left := FFormLeft; + //debugln(['TFindDialog.CalcPosition: Left=',Left,', Top=',Top,', Position=',dbgs(position),', FFormLeft=',FFormLeft,', FFormTop=',FFormTop]); + if (csDesigning in ComponentState) then + begin + aForm.Position := poScreenCenter; + Exit; + end; + if (FFormLeft < 0) and (FFormTop < 0) then + begin + aForm.Position := poMainFormCenter; + FFormTop := aForm.Top; + FFormLeft := aForm.Left; + end; end; @@ -592,6 +597,8 @@ constructor TFindDialog.Create(AOwner: TComponent); begin inherited Create(AOwner); FOptions:=[frDown]; + FFormLeft := -1; + FFormTop := -1; end; destructor TFindDialog.Destroy; diff --git a/lcl/include/replacedialog.inc b/lcl/include/replacedialog.inc index 9aa567e115..a1031f0509 100644 --- a/lcl/include/replacedialog.inc +++ b/lcl/include/replacedialog.inc @@ -73,7 +73,7 @@ begin AutoSize := True; BorderIcons := [biSystemMenu, biHelp]; Caption := 'Replace Text'; - Position := poMainFormCenter; + //Position := poMainFormCenter; LCLVersion := '1.3'; TextLabel := TLabel.Create(Self); @@ -516,7 +516,7 @@ end; function TReplaceDialog.CreateForm: TForm; begin - Result := TReplaceDialogForm.CreateNew(Self,Options); + Result := TReplaceDialogForm.CreateNew(nil,Options); with TReplaceDialogForm(Result) do begin FindMoreButton.Caption := rsFindMore; @@ -541,6 +541,9 @@ begin CancelButton.OnClick := @CancelClick; HelpButton.OnClick := @HelpClick; PopupMode := pmAuto; + // Init local property with default value + Result.Top := FFormTop; + Result.Left := FFormLeft; end; end;