diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 9232f55c..941dcb06 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -295,12 +295,12 @@ type constructor Create; destructor Destroy; override; function ReadInt(Index: TAppSettingIndex; FormatName: String=''; Default: Integer=0): Integer; - function ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer; + //function ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer; function ReadBool(Index: TAppSettingIndex; FormatName: String=''; Default: Boolean=False): Boolean; function ReadString(Index: TAppSettingIndex; FormatName: String=''; Default: String=''): String; overload; function ReadString(ValueName: String): String; overload; procedure WriteInt(Index: TAppSettingIndex; Value: Integer; FormatName: String=''); - procedure WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String=''); + //procedure WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String=''); procedure WriteBool(Index: TAppSettingIndex; Value: Boolean; FormatName: String=''); procedure WriteString(Index: TAppSettingIndex; Value: String; FormatName: String=''); overload; procedure WriteString(ValueName, Value: String); overload; @@ -4185,12 +4185,12 @@ begin end; -function TAppSettings.ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer; +{function TAppSettings.ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer; begin // take a forms DesignTimePPI into account Result := ReadInt(Index, FormatName, Default); Result := AControl.ScaleDesignToForm(Result); -end; +end;} function TAppSettings.ReadBool(Index: TAppSettingIndex; FormatName: String=''; Default: Boolean=False): Boolean; @@ -4273,11 +4273,11 @@ begin end; -procedure TAppSettings.WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String=''); +{procedure TAppSettings.WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String=''); begin Value := AControl.ScaleFormToDesign(Value); WriteInt(Index, Value, FormatName); -end; +end;} procedure TAppSettings.WriteBool(Index: TAppSettingIndex; Value: Boolean; FormatName: String=''); diff --git a/source/column_selection.lfm b/source/column_selection.lfm index 6a2db72e..e8633d3a 100644 --- a/source/column_selection.lfm +++ b/source/column_selection.lfm @@ -14,6 +14,7 @@ object frmColumnSelection: TfrmColumnSelection OnClose = FormClose OnCreate = FormCreate OnDeactivate = FormDeactivate + OnDestroy = FormDestroy OnShow = FormShow object btnCancel: TButton Left = 146 diff --git a/source/column_selection.pas b/source/column_selection.pas index b596d6d8..de110d29 100644 --- a/source/column_selection.pas +++ b/source/column_selection.pas @@ -9,6 +9,9 @@ uses apphelpers, extra_controls, EditBtn; type + + { TfrmColumnSelection } + TfrmColumnSelection = class(TExtForm) btnCancel: TButton; btnOK: TButton; @@ -18,6 +21,7 @@ type editFilter: TEditButton; chkShowRowId: TCheckBox; procedure btnCancelClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure chklistColumnsClickCheck(Sender: TObject); procedure chkSelectAllClick(Sender: TObject); @@ -49,6 +53,8 @@ procedure TfrmColumnSelection.FormCreate(Sender: TObject); begin HasSizeGrip := True; FCheckedColumns := TStringList.Create; + Width := AppSettings.ReadInt(asColumnSelectorWidth); + Height := AppSettings.ReadInt(asColumnSelectorHeight); end; @@ -60,8 +66,6 @@ var i: Integer; Col: String; begin - Width := AppSettings.ReadIntDpiAware(asColumnSelectorWidth, Self); - Height := AppSettings.ReadIntDpiAware(asColumnSelectorHeight, Self); FCheckedColumns.Clear; for i:=0 to Mainform.SelectedTableColumns.Count-1 do begin Col := Mainform.SelectedTableColumns[i].Name; @@ -214,6 +218,12 @@ begin Close; end; +procedure TfrmColumnSelection.FormDestroy(Sender: TObject); +begin + AppSettings.WriteInt(asColumnSelectorWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asColumnSelectorHeight, ScaleFormToDesign(Height)); +end; + {** Cancel this dialog if the user clicks elsewhere on mainform @@ -230,8 +240,6 @@ end; procedure TfrmColumnSelection.FormClose(Sender: TObject; var Action: TCloseAction); begin - AppSettings.WriteIntDpiAware(asColumnSelectorWidth, Self, Width); - AppSettings.WriteIntDpiAware(asColumnSelectorHeight, Self, Height); Action := caFree; FCheckedColumns.Free; end; diff --git a/source/connections.pas b/source/connections.pas index 030ad267..369f28aa 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -474,11 +474,11 @@ end; procedure Tconnform.FormDestroy(Sender: TObject); begin // Save GUI stuff - AppSettings.WriteInt(asSessionManagerListWidth, pnlLeft.Width); - AppSettings.WriteInt(asSessionManagerWindowWidth, Width); - AppSettings.WriteInt(asSessionManagerWindowHeight, Height); - AppSettings.WriteInt(asSessionManagerWindowLeft, Left); - AppSettings.WriteInt(asSessionManagerWindowTop, Top); + AppSettings.WriteInt(asSessionManagerListWidth, ScaleFormToDesign(pnlLeft.Width)); + AppSettings.WriteInt(asSessionManagerWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asSessionManagerWindowHeight, ScaleFormToDesign(Height)); + AppSettings.WriteInt(asSessionManagerWindowLeft, ScaleFormToDesign(Left)); + AppSettings.WriteInt(asSessionManagerWindowTop, ScaleFormToDesign(Top)); SaveListSetup(ListSessions); end; diff --git a/source/copytable.lfm b/source/copytable.lfm index 524218b4..266fc229 100644 --- a/source/copytable.lfm +++ b/source/copytable.lfm @@ -10,6 +10,7 @@ object CopyTableForm: TCopyTableForm DesignTimePPI = 120 OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy OnResize = FormResize OnShow = FormShow Position = poMainFormCenter diff --git a/source/copytable.pas b/source/copytable.pas index b04cee8f..81ad49e9 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -10,6 +10,9 @@ uses Buttons; type + + { TCopyTableForm } + TCopyTableForm = class(TExtForm) editNewTablename: TEdit; lblNewTablename: TLabel; @@ -23,6 +26,7 @@ type btnRecentFilters: TSpeedButton; popupRecentFilters: TPopupMenu; procedure editNewTablenameChange(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure btnOKClick(Sender: TObject); procedure FormCreate(Sender: TObject); @@ -187,9 +191,6 @@ begin AppSettings.WriteString(asCopyTableRecentFilter, NewValues[i], IntToStr(i)); end; end; - // Store GUI setup - AppSettings.WriteIntDpiAware(asCopyTableWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asCopyTableWindowHeight, Self, Height); end; @@ -343,6 +344,13 @@ begin btnOK.Enabled := editNewTablename.Text <> ''; end; +procedure TCopyTableForm.FormDestroy(Sender: TObject); +begin + // Store GUI setup + AppSettings.WriteInt(asCopyTableWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asCopyTableWindowHeight, ScaleFormToDesign(Height)); +end; + procedure TCopyTableForm.btnOKClick(Sender: TObject); var diff --git a/source/editvar.pas b/source/editvar.pas index 4e9ba0f1..a31b4bed 100644 --- a/source/editvar.pas +++ b/source/editvar.pas @@ -57,13 +57,15 @@ uses main, apphelpers; procedure TfrmEditVariable.FormCreate(Sender: TObject); begin HasSizeGrip := True; + Width := AppSettings.ReadInt(asEditVarWindowWidth); + Height := AppSettings.ReadInt(asEditVarWindowHeight); end; procedure TfrmEditVariable.FormDestroy(Sender: TObject); begin - AppSettings.WriteIntDpiAware(asEditVarWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asEditVarWindowHeight, Self, Height); + AppSettings.WriteInt(asEditVarWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asEditVarWindowHeight, ScaleFormToDesign(Height)); end; @@ -92,8 +94,6 @@ procedure TfrmEditVariable.FormShow(Sender: TObject); var val: String; begin - Width := AppSettings.ReadIntDpiAware(asEditVarWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asEditVarWindowHeight, Self); // Verify variable type by value FVarType := vtString; if IsInt(FVarValue) then diff --git a/source/exportgrid.lfm b/source/exportgrid.lfm index e4b1351d..cbf2f287 100644 --- a/source/exportgrid.lfm +++ b/source/exportgrid.lfm @@ -13,6 +13,7 @@ object frmExportGrid: TfrmExportGrid DesignTimePPI = 120 OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy OnShow = FormShow Position = poMainFormCenter object btnOK: TButton diff --git a/source/exportgrid.pas b/source/exportgrid.pas index 2a605bb0..8fe26b23 100644 --- a/source/exportgrid.pas +++ b/source/exportgrid.pas @@ -29,6 +29,8 @@ type efJSONLines ); + { TfrmExportGrid } + TfrmExportGrid = class(TExtForm) btnOK: TButton; btnCancel: TButton; @@ -76,6 +78,7 @@ type procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure editFilenameRightButtonClick(Sender: TObject); procedure editFilenameChange(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure popupRecentFilesPopup(Sender: TObject); procedure menuCSVClick(Sender: TObject); procedure editCSVRightButtonClick(Sender: TObject); @@ -182,6 +185,8 @@ var comboItem: TComboExItem; begin HasSizeGrip := True; + Width := AppSettings.ReadInt(asGridExportWindowWidth); + Height := AppSettings.ReadInt(asGridExportWindowHeight); editFilename.Text := AppSettings.ReadString(asGridExportFilename); FRecentFiles := Explode(DELIM, AppSettings.ReadString(asGridExportRecentFiles)); comboEncoding.Items.Assign(MainForm.FileEncodings); @@ -230,8 +235,6 @@ end; procedure TfrmExportGrid.FormShow(Sender: TObject); begin // Show dialog. Expect "Grid" property to be set now by the caller. - Width := AppSettings.ReadIntDpiAware(asGridExportWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asGridExportWindowHeight, Self); chkIncludeAutoIncrement.OnClick := CalcSize; CalcSize(Sender); end; @@ -240,8 +243,6 @@ end; procedure TfrmExportGrid.FormClose(Sender: TObject; var Action: TCloseAction); begin // Store settings - AppSettings.WriteIntDpiAware(asGridExportWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asGridExportWindowHeight, Self, Height); if ModalResult = mrOK then begin AppSettings.WriteBool(asGridExportOutputCopy, radioOutputCopyToClipboard.Checked); AppSettings.WriteBool(asGridExportOutputFile, radioOutputFile.Checked); @@ -375,6 +376,12 @@ begin radioOutputFile.Checked := True; end; +procedure TfrmExportGrid.FormDestroy(Sender: TObject); +begin + AppSettings.WriteInt(asGridExportWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asGridExportWindowHeight, ScaleFormToDesign(Height)); +end; + procedure TfrmExportGrid.editFilenameRightButtonClick(Sender: TObject); var diff --git a/source/extra_controls.pas b/source/extra_controls.pas index a999205e..d16fcfe2 100644 --- a/source/extra_controls.pas +++ b/source/extra_controls.pas @@ -13,23 +13,6 @@ uses type // Form with a sizegrip in the lower right corner, without the need for a statusbar - { TControlTopComparer } - - TControlTopComparer = class(TComparer) - function Compare(constref Left, Right: TControl): Integer; override; - end; - - TControlRow = class(TObjectList) - Height: Integer - end; - - { TControlGrid } - - TControlGrid = class(TObjectList) - public - constructor Create(aParentControl: TControl); - end; - { TExtForm } TExtForm = class(TForm) @@ -43,7 +26,6 @@ type //procedure DoBeforeMonitorDpiChanged(OldDPI, NewDPI: Integer); override; //procedure DoAfterMonitorDpiChanged(OldDPI, NewDPI: Integer); override; procedure FilterNodesByEdit(Edit: TEditButton; Tree: TLazVirtualStringTree); - procedure ArrangeControls(aParentControl: TControl); public constructor Create(AOwner: TComponent); override; class procedure InheritFont(AFont: TFont); @@ -133,70 +115,6 @@ type implementation -{ TControlComparer } - -function TControlTopComparer.Compare(constref Left, Right: TControl): Integer; -begin - // Sort by Top position, so we can be sure if we find a first one in a row, there's no other above it - if Left.Top > Right.Top then - Result := 1 - else if Left.Top = Right.Top then - Result := 0 - else - Result := -1; -end; - -{ TControlGrid } - -constructor TControlGrid.Create(aParentControl: TControl); -const - yCoordStep = 10; -var - y, i: Integer; - FoundControl: TControl; - ControlRow: TControlRow; - AllControls: TObjectList; -begin - OwnsObjects := True; - y := 0; - AllControls := TObjectList.Create(TControlTopComparer.Create, False); - for i:=0 to aParentControl.Owner.ComponentCount-1 do begin - if aParentControl.Owner.Components[i] is TControl then begin - FoundControl := aParentControl.Owner.Components[i] as TControl; - if FoundControl.Parent = aParentControl then begin - AllControls.Add(FoundControl); - end; - end; - end; - AllControls.Sort; - - while y < aParentControl.Height + 100 do begin - ControlRow := TControlRow.Create(False); - ControlRow.Height := 0; - - for FoundControl in AllControls do begin - if (FoundControl.Top >= y) and (FoundControl.Top < y + yCoordStep) then begin - ControlRow.Add(FoundControl); - if ControlRow.Count = 1 then - y := FoundControl.Top; - ControlRow.Height := Max(ControlRow.Height, FoundControl.Height); - end; - end; - - // Add to grid if controls exist - if ControlRow.Count = 0 then begin - ControlRow.Free; - Inc(y, 1); - end - else begin - ControlRow.Height := aParentControl.ScaleDesignToForm(ControlRow.Height); - Add(ControlRow); - Inc(y, yCoordStep); - end; - - end; -end; - { TExtForm } @@ -355,7 +273,7 @@ begin // Column widths if ColWidths <> '' then ColWidths := ColWidths + ','; - ColWidth := List.Header.Columns[i].Width; // RoundCommercial(List.Header.Columns[i].Width / OwnerForm.ScaleFactor); + ColWidth := OwnerForm.ScaleFormToDesign(List.Header.Columns[i].Width); // RoundCommercial(List.Header.Columns[i].Width / OwnerForm.ScaleFactor); ColWidths := ColWidths + IntToStr(ColWidth); // Column visibility @@ -507,39 +425,6 @@ begin //Edit.Button.Visible := IsNotEmpty(Edit.Text); end; -procedure TExtForm.ArrangeControls(aParentControl: TControl); -const - PaddingPx = 6; - LabelMoveDown = 2; -var - Grid: TControlGrid; - Row: TControlRow; - FoundControl: TControl; - NewTopPos: Integer; -begin - // Reposition edits and combo boxes due to different height on different OS's - Grid := TControlGrid.Create(aParentControl); - - NewTopPos := PaddingPx; - for Row in Grid do begin - for FoundControl in Row do begin - if (akBottom in FoundControl.Anchors) and (akTop in FoundControl.Anchors) then - FoundControl.Height := FoundControl.Height + (FoundControl.Top - NewTopPos); - if (FoundControl is TLabel) and (FoundControl.Left < 30) then begin - FoundControl.Top := NewTopPos + LabelMoveDown; - FoundControl.Left := PaddingPx; - end - else begin - FoundControl.Top := NewTopPos; - end; - if (akRight in FoundControl.Anchors) and (FoundControl.Left + FoundControl.Width > aParentControl.Width - 30) then begin - FoundControl.Width := aParentControl.Width - FoundControl.Left - PaddingPx; - end; - end; - Inc(NewTopPos, Row.Height + PaddingPx); - end; - Grid.Free; -end; function TExtForm.ScaleSize(x: Extended): Integer; begin diff --git a/source/insertfiles.pas b/source/insertfiles.pas index 4acfcd67..ae875510 100644 --- a/source/insertfiles.pas +++ b/source/insertfiles.pas @@ -129,8 +129,8 @@ end; procedure TfrmInsertFiles.FormDestroy(Sender: TObject); begin - AppSettings.WriteIntDpiAware(asFileImportWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asFileImportWindowHeight, Self, Height); + AppSettings.WriteInt(asFileImportWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asFileImportWindowHeight, ScaleFormToDesign(Height)); SaveListSetup(ListColumns); SaveListSetup(listFiles); end; diff --git a/source/loaddata.lfm b/source/loaddata.lfm index a73d149b..6fee6686 100644 --- a/source/loaddata.lfm +++ b/source/loaddata.lfm @@ -12,6 +12,7 @@ object loaddataform: Tloaddataform DesignTimePPI = 120 OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy OnResize = FormResize OnShow = FormShow Position = poMainFormCenter diff --git a/source/loaddata.pas b/source/loaddata.pas index aa07d969..64000845 100644 --- a/source/loaddata.pas +++ b/source/loaddata.pas @@ -16,6 +16,9 @@ uses dbconnection, dbstructures; type + + { Tloaddataform } + Tloaddataform = class(TExtForm) btnImport: TButton; btnCancel: TButton; @@ -58,6 +61,7 @@ type const ProgressBarSteps=100; procedure FormCreate(Sender: TObject); procedure editFilenameChange(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure comboDatabaseChange(Sender: TObject); procedure comboTablePopulate(SelectTableName: String; RefreshDbObjects: Boolean); @@ -111,6 +115,8 @@ begin chkTruncateTable.Checked := False; grpDuplicates.ItemIndex := AppSettings.ReadInt(asCSVImportDuplicateHandling); grpParseMethod.ItemIndex := AppSettings.ReadInt(asCSVImportParseMethod); + Width := AppSettings.ReadInt(asCSVImportWindowWidth); + Height := AppSettings.ReadInt(asCSVImportWindowHeight); end; @@ -134,9 +140,6 @@ end; procedure Tloaddataform.FormShow(Sender: TObject); begin - Width := AppSettings.ReadIntDpiAware(asCSVImportWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asCSVImportWindowHeight, Self); - FConnection := MainForm.ActiveConnection; // Disable features supported in MySQL only, if active connection is not MySQL @@ -164,8 +167,6 @@ end; procedure Tloaddataform.FormClose(Sender: TObject; var Action: TCloseAction); begin // Save settings - AppSettings.WriteIntDpiAware(asCSVImportWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asCSVImportWindowHeight, Self, Height); AppSettings.WriteString(asCSVImportFilename, editFilename.Text); AppSettings.WriteString(asCSVImportSeparator, editFieldTerminator.Text); AppSettings.WriteString(asCSVImportEncloser, editFieldEncloser.Text); @@ -767,5 +768,11 @@ begin and (FileExists(editFilename.Text)); end; +procedure Tloaddataform.FormDestroy(Sender: TObject); +begin + AppSettings.WriteInt(asCSVImportWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asCSVImportWindowHeight, ScaleFormToDesign(Height)); +end; + end. diff --git a/source/main.pas b/source/main.pas index 4bbe4d6c..3132fece 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1846,10 +1846,10 @@ begin AppSettings.WriteInt(asMainWinOnMonitor, Monitor.MonitorNum); // Window dimensions are only valid when WindowState is normal. if WindowState = wsNormal then begin - AppSettings.WriteInt(asMainWinLeft, Left); - AppSettings.WriteInt(asMainWinTop, Top); - AppSettings.WriteIntDpiAware(asMainWinWidth, Self, Width); - AppSettings.WriteIntDpiAware(asMainWinHeight, Self, Height); + AppSettings.WriteInt(asMainWinLeft, ScaleFormToDesign(Left)); + AppSettings.WriteInt(asMainWinTop, ScaleFormToDesign(Top)); + AppSettings.WriteInt(asMainWinWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asMainWinHeight, ScaleFormToDesign(Height)); end; SaveListSetup(ListDatabases); SaveListSetup(ListVariables); @@ -2023,7 +2023,12 @@ begin Top := AppSettings.ReadInt(asMainWinTop); // ... state if AppSettings.ReadBool(asMainWinMaximized) then - WindowState := wsMaximized; + WindowState := wsMaximized + // ... dimensions + else begin + Width := AppSettings.ReadInt(asMainWinWidth); + Height := AppSettings.ReadInt(asMainWinHeight); + end; // ... and monitor placement MonitorIndex := AppSettings.ReadInt(asMainWinOnMonitor); MonitorIndex := Max(0, MonitorIndex); @@ -2832,12 +2837,6 @@ end; procedure TMainForm.FormShow(Sender: TObject); begin - // Window dimensions - if WindowState <> wsMaximized then begin - Width := AppSettings.ReadIntDpiAware(asMainWinWidth, Self); - Height := AppSettings.ReadIntDpiAware(asMainWinHeight, Self); - end; - {LogSQL(f_('Scaling controls to screen DPI: %d%%', [Round(ScaleFactor*100)])); if TStyleManager.IsCustomStyleActive and (ScaleFactor<>1) then begin LogSQL(f_('Caution: Style "%s" selected and non-default DPI factor - be aware that some styles appear broken with high DPI settings!', [TStyleManager.ActiveStyle.Name])); diff --git a/source/preferences.lfm b/source/preferences.lfm index c54c816a..ac0d9a68 100644 --- a/source/preferences.lfm +++ b/source/preferences.lfm @@ -13,6 +13,7 @@ object frmPreferences: TfrmPreferences DesignTimePPI = 120 OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy OnShow = FormShow Position = poMainFormCenter object pagecontrolMain: TPageControl diff --git a/source/preferences.pas b/source/preferences.pas index 0fa45e2e..517bac8d 100644 --- a/source/preferences.pas +++ b/source/preferences.pas @@ -32,6 +32,8 @@ type end; TGridColorsPresetList = TObjectList; + { TfrmPreferences } + TfrmPreferences = class(TExtForm) pagecontrolMain: TPageControl; tabMisc: TTabSheet; @@ -178,6 +180,7 @@ type Label5: TLabel; lblReformatter: TLabel; comboReformatter: TComboBox; + procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure Modified(Sender: TObject); procedure Apply(Sender: TObject); @@ -485,8 +488,6 @@ begin [mbOk]); end; MainForm.ActionList1.State := asNormal; - AppSettings.WriteIntDpiAware(asPreferencesWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asPreferencesWindowHeight, Self, Height); end; @@ -508,6 +509,8 @@ var Reformatter: TfrmReformatter; begin HasSizeGrip := True; + Width := AppSettings.ReadInt(asPreferencesWindowWidth); + Height := AppSettings.ReadInt(asPreferencesWindowHeight); // Misecllaneous // Hide browse button on Wine, as the browse dialog returns Windows-style paths, while we need a Unix path @@ -677,9 +680,6 @@ var begin Screen.Cursor := crHourGlass; - Width := AppSettings.ReadIntDpiAware(asPreferencesWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asPreferencesWindowHeight, Self); - // Read and display values chkAutoReconnect.Checked := AppSettings.ReadBool(asAutoReconnect);; chkAllowMultiInstances.Checked := AppSettings.ReadBool(asAllowMultipleInstances); @@ -812,6 +812,11 @@ begin screen.Cursor := crdefault; end; +procedure TfrmPreferences.FormDestroy(Sender: TObject); +begin + AppSettings.WriteInt(asPreferencesWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asPreferencesWindowHeight, ScaleFormToDesign(Height)); +end; procedure TfrmPreferences.SQLFontChange(Sender: TObject); @@ -1281,7 +1286,6 @@ begin end; end; - procedure TfrmPreferences.TreeShortcutItemsInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); var diff --git a/source/selectdbobject.pas b/source/selectdbobject.pas index 41c8af45..8b88455d 100644 --- a/source/selectdbobject.pas +++ b/source/selectdbobject.pas @@ -68,6 +68,8 @@ end; procedure TfrmSelectDBObject.FormCreate(Sender: TObject); begin HasSizeGrip := True; + Width := AppSettings.ReadInt(asSelectDBOWindowWidth); + Height := AppSettings.ReadInt(asSelectDBOWindowHeight); TreeDBO.TreeOptions := MainForm.DBtree.TreeOptions; TreeDBO.TreeOptions.SelectionOptions := TreeDBO.TreeOptions.SelectionOptions + [toMultiSelect]; FixVT(TreeDBO); @@ -76,8 +78,8 @@ end; procedure TfrmSelectDBObject.FormDestroy(Sender: TObject); begin - AppSettings.WriteIntDpiAware(asSelectDBOWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asSelectDBOWindowHeight, Self, Height); + AppSettings.WriteInt(asSelectDBOWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asSelectDBOWindowHeight, ScaleFormToDesign(Height)); end; @@ -98,8 +100,6 @@ end; procedure TfrmSelectDBObject.FormShow(Sender: TObject); begin - Width := AppSettings.ReadIntDpiAware(asSelectDBOWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asSelectDBOWindowHeight, Self); TreeDBO.Clear; TreeDBO.RootNodeCount := Mainform.DBtree.RootNodeCount; TreeDBO.OnFocusChanged(TreeDBO, TreeDBO.FocusedNode, 0); diff --git a/source/sqlhelp.lfm b/source/sqlhelp.lfm index c2dfeea9..28082ac3 100644 --- a/source/sqlhelp.lfm +++ b/source/sqlhelp.lfm @@ -12,6 +12,7 @@ object frmSQLhelp: TfrmSQLhelp FormStyle = fsStayOnTop OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy OnShow = FormShow object pnlMain: TPanel Left = 10 diff --git a/source/sqlhelp.pas b/source/sqlhelp.pas index c5c3ea94..bebfeddf 100644 --- a/source/sqlhelp.pas +++ b/source/sqlhelp.pas @@ -35,6 +35,7 @@ type MemoExample: TSynEdit; timerSearch: TTimer; procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure memosKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ButtonOnlinehelpClick(Sender: TObject); @@ -94,6 +95,14 @@ begin Caption := DEFAULT_WINDOW_CAPTION; FixVT(treeTopics); HasSizeGrip := True; + Top := AppSettings.ReadInt(asSQLHelpWindowTop); + Left := AppSettings.ReadInt(asSQLHelpWindowLeft); + Width := AppSettings.ReadInt(asSQLHelpWindowWidth); + Height := AppSettings.ReadInt(asSQLHelpWindowHeight); + MakeFullyVisible; + + pnlLeft.Width := AppSettings.ReadInt(asSQLHelpPnlLeftWidth); + memoDescription.Height := AppSettings.ReadInt(asSQLHelpPnlRightTopHeight); treeTopics.Clear; FreeAndNil(FRootTopics); @@ -102,15 +111,19 @@ begin treeTopics.RootNodeCount := FRootTopics.RecordCount; end; +procedure TfrmSQLhelp.FormDestroy(Sender: TObject); +begin + AppSettings.WriteInt(asSQLHelpWindowLeft, ScaleFormToDesign(Left)); + AppSettings.WriteInt(asSQLHelpWindowTop, ScaleFormToDesign(Top)); + AppSettings.WriteInt(asSQLHelpWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asSQLHelpWindowHeight, ScaleFormToDesign(Height)); + AppSettings.WriteInt(asSQLHelpPnlLeftWidth, ScaleFormToDesign(pnlLeft.Width)); + AppSettings.WriteInt(asSQLHelpPnlRightTopHeight, ScaleFormToDesign(memoDescription.Height)); +end; + procedure TfrmSQLhelp.FormClose(Sender: TObject; var Action: TCloseAction); begin - AppSettings.WriteInt(asSQLHelpWindowLeft, Left ); - AppSettings.WriteInt(asSQLHelpWindowTop, Top ); - AppSettings.WriteIntDpiAware(asSQLHelpWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asSQLHelpWindowHeight, Self, Height); - AppSettings.WriteIntDpiAware(asSQLHelpPnlLeftWidth, Self, pnlLeft.Width); - AppSettings.WriteIntDpiAware(asSQLHelpPnlRightTopHeight, Self, memoDescription.Height); Action := caFree; SqlHelpDialog := nil; end; @@ -227,7 +240,6 @@ begin ChildCount := Results.RecordCount; end; - procedure TfrmSQLhelp.treeTopicsInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); var @@ -270,14 +282,6 @@ end; procedure TfrmSQLhelp.FormShow(Sender: TObject); begin - Top := AppSettings.ReadInt(asSQLHelpWindowTop); - Left := AppSettings.ReadInt(asSQLHelpWindowLeft); - Width := AppSettings.ReadIntDpiAware(asSQLHelpWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asSQLHelpWindowHeight, Self); - MakeFullyVisible; - - pnlLeft.Width := AppSettings.ReadIntDpiAware(asSQLHelpPnlLeftWidth, Self); - memoDescription.Height := AppSettings.ReadIntDpiAware(asSQLHelpPnlRightTopHeight, Self); // Apply themed colors in OnShow, not OnCreate, as a check with <> nil returns false otherwise MainForm.SetupSynEditors(Self); // These SynMemo's don't have any (SQL) highligher, so we have to assign correct colors for basic text diff --git a/source/texteditor.pas b/source/texteditor.pas index 4718d10f..f21abf13 100644 --- a/source/texteditor.pas +++ b/source/texteditor.pas @@ -267,14 +267,19 @@ begin //MemoText.OnPaintTransient := MainForm.SynMemoQuery.OnPaintTransient; if AppSettings.ReadBool(asMemoEditorMaximized) then WindowState := wsMaximized; + // Restore form dimensions + if WindowState <> wsMaximized then begin + Width := AppSettings.ReadInt(asMemoEditorWidth); + Height := AppSettings.ReadInt(asMemoEditorHeight); + end; end; procedure TfrmTextEditor.FormDestroy(Sender: TObject); begin if WindowState <> wsMaximized then begin - AppSettings.WriteIntDpiAware(asMemoEditorWidth, Self, Width); - AppSettings.WriteIntDpiAware(asMemoEditorHeight, Self, Height); + AppSettings.WriteInt(asMemoEditorWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asMemoEditorHeight, ScaleFormToDesign(Height)); end; AppSettings.WriteBool(asMemoEditorMaximized, WindowState=wsMaximized); if btnWrap.Enabled then begin @@ -291,12 +296,6 @@ procedure TfrmTextEditor.FormShow(Sender: TObject); var HighlighterName: String; begin - // Restore form dimensions - if WindowState <> wsMaximized then begin - Width := AppSettings.ReadIntDpiAware(asMemoEditorWidth, Self); - Height := AppSettings.ReadIntDpiAware(asMemoEditorHeight, Self); - end; - if AppSettings.ReadBool(asMemoEditorWrap) and btnWrap.Enabled then begin btnWrap.Click; end; diff --git a/source/updatecheck.lfm b/source/updatecheck.lfm index cd19f8dc..24e6f3a6 100644 --- a/source/updatecheck.lfm +++ b/source/updatecheck.lfm @@ -12,6 +12,7 @@ object frmUpdateCheck: TfrmUpdateCheck DesignTimePPI = 120 OnClose = FormClose OnCreate = FormCreate + OnDestroy = FormDestroy OnShow = FormShow Position = poOwnerFormCenter object lblStatus: TLabel diff --git a/source/updatecheck.pas b/source/updatecheck.pas index 820de476..9753f244 100644 --- a/source/updatecheck.pas +++ b/source/updatecheck.pas @@ -10,6 +10,9 @@ uses Menus, Clipbrd, generic_types, DateUtils; type + + { TfrmUpdateCheck } + TfrmUpdateCheck = class(TExtForm) btnCancel: TButton; groupBuild: TGroupBox; @@ -25,6 +28,7 @@ type btnDonate: TButton; procedure FormCreate(Sender: TObject); procedure btnBuildClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure LinkLabelReleaseLinkClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure btnChangelogClick(Sender: TObject); @@ -71,13 +75,13 @@ begin btnDonate.Visible := MainForm.HasDonated(False) = nbFalse; btnDonate.Caption := f_('Donate to the %s project', [APPNAME]); HasSizeGrip := True; + Width := AppSettings.ReadInt(asUpdateCheckWindowWidth); + Height := AppSettings.ReadInt(asUpdateCheckWindowHeight); FRestartTaskName := 'yet_invalid'; end; procedure TfrmUpdateCheck.FormClose(Sender: TObject; var Action: TCloseAction); begin - AppSettings.WriteIntDpiAware(asUpdateCheckWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asUpdateCheckWindowHeight, Self, Height); if ModalResult <> btnBuild.ModalResult then begin DeleteRestartTask; end; @@ -98,8 +102,6 @@ end; } procedure TfrmUpdateCheck.FormShow(Sender: TObject); begin - Width := AppSettings.ReadIntDpiAware(asUpdateCheckWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asUpdateCheckWindowHeight, Self); Caption := f_('Check for %s updates', [APPNAME]) + ' ...'; Screen.Cursor := crHourglass; try @@ -246,6 +248,12 @@ begin // No auto-update end; +procedure TfrmUpdateCheck.FormDestroy(Sender: TObject); +begin + AppSettings.WriteInt(asUpdateCheckWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asUpdateCheckWindowHeight, ScaleFormToDesign(Height)); +end; + function TfrmUpdateCheck.GetLinkUrl(Sender: TObject; LinkType: String): String; var diff --git a/source/usermanager.lfm b/source/usermanager.lfm index cf3f8aa3..c53159df 100644 --- a/source/usermanager.lfm +++ b/source/usermanager.lfm @@ -14,6 +14,7 @@ object UserManagerForm: TUserManagerForm OnClose = FormClose OnCloseQuery = FormCloseQuery OnCreate = FormCreate + OnDestroy = FormDestroy OnResize = FormResize OnShow = FormShow Position = poMainFormCenter diff --git a/source/usermanager.pas b/source/usermanager.pas index c7c90ffd..f70c3b6f 100644 --- a/source/usermanager.pas +++ b/source/usermanager.pas @@ -114,6 +114,7 @@ type procedure editFromHostButtonClick(Sender: TObject); procedure editPasswordButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure btnAddUserClick(Sender: TObject); procedure btnDeleteUserClick(Sender: TObject); @@ -214,6 +215,12 @@ procedure TUserManagerForm.FormCreate(Sender: TObject); begin // Restore GUI setup HasSizeGrip := True; + Width := AppSettings.ReadInt(asUsermanagerWindowWidth); + Height := AppSettings.ReadInt(asUsermanagerWindowHeight); + pnlLeft.Width := AppSettings.ReadInt(asUsermanagerListWidth); + FixVT(listUsers); + FixVT(treePrivs); + RestoreListSetup(listUsers); lblWarning.Font.Color := clRed; PrivsRead := Explode(',', 'SELECT,SHOW VIEW,SHOW DATABASES,PROCESS,EXECUTE'); PrivsWrite := Explode(',', 'ALTER,CREATE,DROP,DELETE,UPDATE,INSERT,ALTER ROUTINE,CREATE ROUTINE,CREATE TEMPORARY TABLES,'+ @@ -223,6 +230,15 @@ begin 'REPLICATION SLAVE ADMIN,SET USER,SLAVE MONITOR'); end; +procedure TUserManagerForm.FormDestroy(Sender: TObject); +begin + // Save GUI setup + AppSettings.WriteInt(asUsermanagerWindowWidth, ScaleFormToDesign(Width)); + AppSettings.WriteInt(asUsermanagerWindowHeight, ScaleFormToDesign(Height)); + AppSettings.WriteInt(asUsermanagerListWidth, ScaleFormToDesign(pnlLeft.Width)); + SaveListSetup(listUsers); +end; + procedure TUserManagerForm.btnCancelClick(Sender: TObject); begin ModalResult := mrCancel; @@ -274,15 +290,6 @@ var end; begin - ArrangeControls(tabCredentials); - ArrangeControls(tabLimitations); - ArrangeControls(tabSSL); - Width := AppSettings.ReadIntDpiAware(asUsermanagerWindowWidth, Self); - Height := AppSettings.ReadIntDpiAware(asUsermanagerWindowHeight, Self); - pnlLeft.Width := AppSettings.ReadIntDpiAware(asUsermanagerListWidth, Self); - FixVT(listUsers); - FixVT(treePrivs); - RestoreListSetup(listUsers); FColorReadPriv := clGreen; FColorWritePriv := clMaroon; FColorAdminPriv := clNavy; @@ -450,11 +457,6 @@ begin FreeAndNil(FPrivsTable); FreeAndNil(FPrivsRoutine); FreeAndNil(FPrivsColumn); - // Save GUI setup - AppSettings.WriteIntDpiAware(asUsermanagerWindowWidth, Self, Width); - AppSettings.WriteIntDpiAware(asUsermanagerWindowHeight, Self, Height); - AppSettings.WriteIntDpiAware(asUsermanagerListWidth, Self, pnlLeft.Width); - SaveListSetup(listUsers); end;