Skip to content

Commit dab1cda

Browse files
committed
fix: form dimensions reset to default values each time, and wrong check for empty SynEdit
This disables the AutoSize property on most forms (except the about dialog).
1 parent 9300cbc commit dab1cda

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

source/column_selection.lfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ object frmColumnSelection: TfrmColumnSelection
33
Height = 304
44
Top = 0
55
Width = 250
6-
AutoSize = True
76
BorderStyle = bsSizeToolWin
87
Caption = 'Select columns'
98
ClientHeight = 304

source/copytable.lfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ object CopyTableForm: TCopyTableForm
33
Height = 380
44
Top = 115
55
Width = 455
6-
AutoSize = True
76
Caption = 'Copy Table...'
87
ClientHeight = 380
98
ClientWidth = 455

source/copytable.pas

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ implementation
7272

7373
procedure TCopyTableForm.FormCreate(Sender: TObject);
7474
begin
75+
Width := AppSettings.ReadInt(asCopyTableWindowWidth);
76+
Height := AppSettings.ReadInt(asCopyTableWindowHeight);
7577
MainForm.SetupSynEditors(Self);
7678
FixVT(TreeElements);
7779
end;
@@ -86,8 +88,6 @@ procedure TCopyTableForm.FormResize(Sender: TObject);
8688
// Give both dropdown and edit box the same width. See http://www.heidisql.com/forum.php?t=11039
8789
HalfWidth := (ClientWidth - (3*Space)) div 2;
8890
comboDatabase.Width := HalfWidth;
89-
editNewTablename.Width := HalfWidth;
90-
editNewTablename.Left := comboDatabase.Left + comboDatabase.Width + Space;
9191
end;
9292

9393

@@ -99,9 +99,6 @@ procedure TCopyTableForm.FormShow(Sender: TObject);
9999
Item: TMenuItem;
100100
Tree: TVirtualStringTree;
101101
begin
102-
// Todo: check if resizing a form here drags its controls with it
103-
//Width := AppSettings.ReadIntDpiAware(asCopyTableWindowWidth, Self);
104-
//Height := AppSettings.ReadIntDpiAware(asCopyTableWindowHeight, Self);
105102
if Mainform.DBtree.Focused then
106103
Tree := Mainform.DBtree
107104
else
@@ -175,7 +172,7 @@ procedure TCopyTableForm.FormClose(Sender: TObject; var Action: TCloseAction);
175172
Node := TreeElements.GetNextSibling(Node);
176173
end;
177174
// Store recent filters
178-
if MemoFilter.Enabled and (MemoFilter.GetTextLen > 0) then begin
175+
if MemoFilter.Enabled and (not MemoFilter.TextIsEmpty) then begin
179176
NewValues := TStringList.Create;
180177
NewValues.Add(MemoFilter.Text);
181178
for i:=1 to 20 do begin
@@ -482,7 +479,7 @@ procedure TCopyTableForm.btnOKClick(Sender: TObject);
482479
DataCols := Trim(DataCols);
483480
Delete(DataCols, Length(DataCols), 1);
484481
InsertCode := 'INSERT INTO '+TargetTable+' ('+DataCols+') SELECT ' + DataCols + ' FROM ' + FDBObj.QuotedName;
485-
if MemoFilter.GetTextLen > 0 then
482+
if not MemoFilter.TextIsEmpty then
486483
InsertCode := InsertCode + ' WHERE ' + MemoFilter.Text;
487484
end;
488485

source/lazaruscompat.pas

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface
1818
TSynEditHelper = class helper for TSynEdit
1919
public
2020
function GetTextLen: Integer;
21+
function TextIsEmpty: Boolean;
2122
function ConvertCodeStringToCommand(AString: string): TSynEditorCommand;
2223
function IndexToEditorCommand(const AIndex: Integer): Integer;
2324
end;
@@ -162,7 +163,13 @@ implementation
162163

163164
function TSynEditHelper.GetTextLen: Integer;
164165
begin
165-
Result := Self.Text.Length;
166+
Result := Length(Text);
167+
end;
168+
169+
function TSynEditHelper.TextIsEmpty: Boolean;
170+
begin
171+
// Introduced because GetTextLen seems to be unreliable, probably due to the lack of Trim()
172+
Result := Trim(Text).IsEmpty;
166173
end;
167174

168175
function TSynEditHelper.ConvertCodeStringToCommand(AString: string): TSynEditorCommand;

source/searchreplace.lfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ object frmSearchReplace: TfrmSearchReplace
33
Height = 389
44
Top = 0
55
Width = 542
6-
AutoSize = True
76
BorderIcons = []
87
Caption = 'Search and replace text'
98
ClientHeight = 389

0 commit comments

Comments
 (0)