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 -
This commit is contained in:
maxim 2018-09-21 22:45:48 +00:00
parent a62dfe4241
commit 8ec9a4e5d4
2 changed files with 26 additions and 16 deletions

View File

@ -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;

View File

@ -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;