diff --git a/res/manifest.xml b/res/manifest.xml index 81263128..36996eaa 100644 --- a/res/manifest.xml +++ b/res/manifest.xml @@ -2,6 +2,13 @@ + + + true/pm + PerMonitorV2 + + + A lightweight, fast and flexible interface to MySQL diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 2bd0bdfa..ef362c7c 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -237,10 +237,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 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 WriteBool(Index: TAppSettingIndex; Value: Boolean; FormatName: String=''); procedure WriteString(Index: TAppSettingIndex; Value: String; FormatName: String=''); overload; procedure WriteString(ValueName, Value: String); overload; @@ -3997,6 +3999,13 @@ begin end; +function TAppSettings.ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer; +begin + Result := ReadInt(Index, FormatName, Default); + Result := Round(Result * AControl.ScaleFactor); +end; + + function TAppSettings.ReadBool(Index: TAppSettingIndex; FormatName: String=''; Default: Boolean=False): Boolean; var I: Integer; @@ -4077,6 +4086,13 @@ begin end; +procedure TAppSettings.WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String=''); +begin + Value := Round(Value / AControl.ScaleFactor); + WriteInt(Index, Value, FormatName); +end; + + procedure TAppSettings.WriteBool(Index: TAppSettingIndex; Value: Boolean; FormatName: String=''); begin Write(Index, FormatName, adBool, 0, Value, ''); diff --git a/source/bineditor.pas b/source/bineditor.pas index ae0ff46e..ff6dfac5 100644 --- a/source/bineditor.pas +++ b/source/bineditor.pas @@ -95,8 +95,8 @@ end; procedure TfrmBinEditor.FormDestroy(Sender: TObject); begin - AppSettings.WriteInt(asMemoEditorWidth, Width); - AppSettings.WriteInt(asMemoEditorHeight, Height); + AppSettings.WriteIntDpiAware(asMemoEditorWidth, Self, Width); + AppSettings.WriteIntDpiAware(asMemoEditorHeight, Self, Height); AppSettings.WriteBool(asMemoEditorWrap, btnWrap.Down); end; @@ -104,8 +104,8 @@ end; procedure TfrmBinEditor.FormShow(Sender: TObject); begin // Restore form dimensions - Width := AppSettings.ReadInt(asMemoEditorWidth); - Height := AppSettings.ReadInt(asMemoEditorHeight); + Width := AppSettings.ReadIntDpiAware(asMemoEditorWidth, Self); + Height := AppSettings.ReadIntDpiAware(asMemoEditorHeight, Self); if AppSettings.ReadBool(asMemoEditorWrap) then btnWrap.Click; // Fix label position: diff --git a/source/column_selection.pas b/source/column_selection.pas index ce02c39e..e2d47fa6 100644 --- a/source/column_selection.pas +++ b/source/column_selection.pas @@ -45,8 +45,6 @@ uses main; procedure TfrmColumnSelection.FormCreate(Sender: TObject); begin HasSizeGrip := True; - Width := AppSettings.ReadInt(asColumnSelectorWidth); - Height := AppSettings.ReadInt(asColumnSelectorHeight); FCheckedColumns := TStringList.Create; end; @@ -59,6 +57,8 @@ 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; @@ -225,8 +225,8 @@ end; procedure TfrmColumnSelection.FormClose(Sender: TObject; var Action: TCloseAction); begin - AppSettings.WriteInt(asColumnSelectorWidth, Width); - AppSettings.WriteInt(asColumnSelectorHeight, Height); + 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 5c73c8a5..3e5b6d4d 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -266,17 +266,6 @@ begin // Fix GUI stuff HasSizeGrip := True; - Width := AppSettings.ReadInt(asSessionManagerWindowWidth); - Height := AppSettings.ReadInt(asSessionManagerWindowHeight); - Left := AppSettings.ReadInt(asSessionManagerWindowLeft, '', Left); - Top := AppSettings.ReadInt(asSessionManagerWindowTop, '', Top); - // Move to visible area if window was on a now plugged off monitor previously - MakeFullyVisible; - - pnlLeft.Width := AppSettings.ReadInt(asSessionManagerListWidth); - splitterMain.OnMoved(Sender); - FixVT(ListSessions); - MainForm.RestoreListSetup(ListSessions); ListSessions.OnCompareNodes := MainForm.AnyGridCompareNodes; ListSessions.OnHeaderClick := MainForm.AnyGridHeaderClick; ListSessions.OnHeaderDraggedOut := MainForm.AnyGridHeaderDraggedOut; @@ -355,9 +344,9 @@ begin // Suspend calculating statistics as long as they're not visible TimerStatistics.Enabled := False; // Save GUI stuff - AppSettings.WriteInt(asSessionManagerListWidth, pnlLeft.Width); - AppSettings.WriteInt(asSessionManagerWindowWidth, Width); - AppSettings.WriteInt(asSessionManagerWindowHeight, Height); + AppSettings.WriteIntDpiAware(asSessionManagerListWidth, Self, pnlLeft.Width); + AppSettings.WriteIntDpiAware(asSessionManagerWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asSessionManagerWindowHeight, Self, Height); AppSettings.WriteInt(asSessionManagerWindowLeft, Left); AppSettings.WriteInt(asSessionManagerWindowTop, Top); MainForm.SaveListSetup(ListSessions); @@ -371,6 +360,17 @@ var PSess: PConnectionParameters; Node: PVirtualNode; begin + Width := AppSettings.ReadIntDpiAware(asSessionManagerWindowWidth, Self); + Height := AppSettings.ReadIntDpiAware(asSessionManagerWindowHeight, Self); + Left := AppSettings.ReadInt(asSessionManagerWindowLeft, '', Left); + Top := AppSettings.ReadInt(asSessionManagerWindowTop, '', Top); + // Move to visible area if window was on a now plugged off monitor previously + MakeFullyVisible; + pnlLeft.Width := AppSettings.ReadIntDpiAware(asSessionManagerListWidth, Self); + splitterMain.OnMoved(Sender); + FixVT(ListSessions); + MainForm.RestoreListSetup(ListSessions); + // Init sessions tree RefreshSessions(nil); diff --git a/source/copytable.pas b/source/copytable.pas index c1be80f4..3689a7a2 100644 --- a/source/copytable.pas +++ b/source/copytable.pas @@ -67,8 +67,6 @@ const procedure TCopyTableForm.FormCreate(Sender: TObject); begin HasSizeGrip := True; - Width := AppSettings.ReadInt(asCopyTableWindowWidth); - Height := AppSettings.ReadInt(asCopyTableWindowHeight); MainForm.SetupSynEditors; FixVT(TreeElements); end; @@ -96,6 +94,8 @@ var Item: TMenuItem; Tree: TVirtualStringTree; begin + Width := AppSettings.ReadIntDpiAware(asCopyTableWindowWidth, Self); + Height := AppSettings.ReadIntDpiAware(asCopyTableWindowHeight, Self); if Mainform.DBtree.Focused then Tree := Mainform.DBtree else @@ -185,8 +185,8 @@ begin end; end; // Store GUI setup - AppSettings.WriteInt(asCopyTableWindowWidth, Width); - AppSettings.WriteInt(asCopyTableWindowHeight, Height); + AppSettings.WriteIntDpiAware(asCopyTableWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asCopyTableWindowHeight, Self, Height); end; diff --git a/source/editvar.pas b/source/editvar.pas index 3c0211f3..e7c118ca 100644 --- a/source/editvar.pas +++ b/source/editvar.pas @@ -56,15 +56,13 @@ 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.WriteInt(asEditVarWindowWidth, Width); - AppSettings.WriteInt(asEditVarWindowHeight, Height); + AppSettings.WriteIntDpiAware(asEditVarWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asEditVarWindowHeight, Self, Height); end; @@ -93,6 +91,8 @@ 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.pas b/source/exportgrid.pas index c4ed9d21..18ce5145 100644 --- a/source/exportgrid.pas +++ b/source/exportgrid.pas @@ -110,8 +110,6 @@ var SenderName: String; 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); @@ -165,6 +163,8 @@ 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; @@ -173,8 +173,8 @@ end; procedure TfrmExportGrid.FormClose(Sender: TObject; var Action: TCloseAction); begin // Store settings - AppSettings.WriteInt(asGridExportWindowWidth, Width); - AppSettings.WriteInt(asGridExportWindowHeight, Height); + 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); diff --git a/source/insertfiles.pas b/source/insertfiles.pas index 175bb884..09c5cc46 100644 --- a/source/insertfiles.pas +++ b/source/insertfiles.pas @@ -127,8 +127,8 @@ end; procedure TfrmInsertFiles.FormDestroy(Sender: TObject); begin - AppSettings.WriteInt(asFileImportWindowWidth, Width); - AppSettings.WriteInt(asFileImportWindowHeight, Height); + AppSettings.WriteIntDpiAware(asFileImportWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asFileImportWindowHeight, Self, Height); MainForm.SaveListSetup(ListColumns); MainForm.SaveListSetup(listFiles); end; @@ -136,8 +136,8 @@ end; procedure TfrmInsertFiles.FormShow(Sender: TObject); begin - Width := AppSettings.ReadInt(asFileImportWindowWidth); - Height := AppSettings.ReadInt(asFileImportWindowHeight); + Width := AppSettings.ReadIntDpiAware(asFileImportWindowWidth, Self); + Height := AppSettings.ReadIntDpiAware(asFileImportWindowHeight, Self); FConnection := Mainform.ActiveConnection; Caption := FConnection.Parameters.SessionName + ' - ' + MainForm.actInsertFiles.Caption; comboDBs.Items.Clear; diff --git a/source/loaddata.pas b/source/loaddata.pas index 02256cd6..3b14aca6 100644 --- a/source/loaddata.pas +++ b/source/loaddata.pas @@ -95,8 +95,6 @@ procedure Tloaddataform.FormCreate(Sender: TObject); begin HasSizeGrip := True; // Restore settings - Width := AppSettings.ReadInt(asCSVImportWindowWidth); - Height := AppSettings.ReadInt(asCSVImportWindowHeight); editFilename.Text := AppSettings.ReadString(asCSVImportFilename); editFieldTerminator.Text := AppSettings.ReadString(asCSVImportSeparator); editFieldEncloser.Text := AppSettings.ReadString(asCSVImportEncloser); @@ -133,6 +131,9 @@ 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 @@ -160,8 +161,8 @@ end; procedure Tloaddataform.FormClose(Sender: TObject; var Action: TCloseAction); begin // Save settings - AppSettings.WriteInt(asCSVImportWindowWidth, Width); - AppSettings.WriteInt(asCSVImportWindowHeight, Height); + 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); diff --git a/source/main.pas b/source/main.pas index 0be810c1..f722dfa0 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1769,8 +1769,8 @@ begin if WindowState = wsNormal then begin AppSettings.WriteInt(asMainWinLeft, Left); AppSettings.WriteInt(asMainWinTop, Top); - AppSettings.WriteInt(asMainWinWidth, Width); - AppSettings.WriteInt(asMainWinHeight, Height); + AppSettings.WriteIntDpiAware(asMainWinWidth, Self, Width); + AppSettings.WriteIntDpiAware(asMainWinHeight, Self, Height); end; SaveListSetup(ListDatabases); SaveListSetup(ListVariables); @@ -1793,7 +1793,7 @@ end; } procedure TMainForm.FormCreate(Sender: TObject); var - i, j, MonitorIndex: Integer; + i, j: Integer; QueryTab: TQueryTab; Action, CopyAsAction: TAction; ExportFormat: TGridExportFormat; @@ -1956,21 +1956,6 @@ begin FixVT(ListTables); FixVT(treeQueryHelpers); - // Window position - Left := AppSettings.ReadInt(asMainWinLeft); - Top := AppSettings.ReadInt(asMainWinTop); - // .. dimensions - Width := AppSettings.ReadInt(asMainWinWidth); - Height := AppSettings.ReadInt(asMainWinHeight); - // ... state - if AppSettings.ReadBool(asMainWinMaximized) then - WindowState := wsMaximized; - // ... and monitor placement - MonitorIndex := AppSettings.ReadInt(asMainWinOnMonitor); - MonitorIndex := Max(0, MonitorIndex); - MonitorIndex := Min(Screen.MonitorCount-1, MonitorIndex); - MakeFullyVisible(Screen.Monitors[MonitorIndex]); - actQueryStopOnErrors.Checked := AppSettings.ReadBool(asStopOnErrorsInBatchMode); actBlobAsText.Checked := AppSettings.ReadBool(asDisplayBLOBsAsText); actQueryWordWrap.Checked := AppSettings.ReadBool(asWrapLongLines); @@ -2031,14 +2016,6 @@ begin if AppSettings.ReadBool(asDoubleClickInsertsNodeText) then menuDoubleClickInsertsNodeText.Click; - // Restore width of columns of all VirtualTrees - RestoreListSetup(ListDatabases); - RestoreListSetup(ListVariables); - RestoreListSetup(ListStatus); - RestoreListSetup(ListProcesses); - RestoreListSetup(ListCommandStats); - RestoreListSetup(ListTables); - // Shortcuts FActionList1DefaultCaptions := TStringList.Create; FActionList1DefaultHints := TStringList.Create; @@ -2723,7 +2700,32 @@ begin end; procedure TMainForm.FormShow(Sender: TObject); +var + MonitorIndex: Integer; begin + // Window position + Left := AppSettings.ReadInt(asMainWinLeft); + Top := AppSettings.ReadInt(asMainWinTop); + // .. dimensions + Width := AppSettings.ReadIntDpiAware(asMainWinWidth, Self); + Height := AppSettings.ReadIntDpiAware(asMainWinHeight, Self); + // ... state + if AppSettings.ReadBool(asMainWinMaximized) then + WindowState := wsMaximized; + // ... and monitor placement + MonitorIndex := AppSettings.ReadInt(asMainWinOnMonitor); + MonitorIndex := Max(0, MonitorIndex); + MonitorIndex := Min(Screen.MonitorCount-1, MonitorIndex); + MakeFullyVisible(Screen.Monitors[MonitorIndex]); + + // Restore width of columns of all VirtualTrees + RestoreListSetup(ListDatabases); + RestoreListSetup(ListVariables); + RestoreListSetup(ListStatus); + RestoreListSetup(ListProcesses); + RestoreListSetup(ListCommandStats); + RestoreListSetup(ListTables); + // Manually set focus to tree - otherwise the database filter as the first // control catches focus on startup, which is ugly. if DBtree.CanFocus then diff --git a/source/preferences.pas b/source/preferences.pas index c3bd00b9..e14d77e2 100644 --- a/source/preferences.pas +++ b/source/preferences.pas @@ -472,8 +472,8 @@ begin [mbOk]); end; MainForm.ActionList1.State := asNormal; - AppSettings.WriteInt(asPreferencesWindowWidth, Width); - AppSettings.WriteInt(asPreferencesWindowHeight, Height); + AppSettings.WriteIntDpiAware(asPreferencesWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asPreferencesWindowHeight, Self, Height); end; @@ -495,9 +495,6 @@ var 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 if IsWine then begin @@ -622,7 +619,10 @@ var LangCode, GUIFont: String; i: Integer; begin - screen.Cursor := crHourGlass; + Screen.Cursor := crHourGlass; + + Width := AppSettings.ReadIntDpiAware(asPreferencesWindowWidth, Self); + Height := AppSettings.ReadIntDpiAware(asPreferencesWindowHeight, Self); // Read and display values chkAutoReconnect.Checked := AppSettings.ReadBool(asAutoReconnect);; diff --git a/source/selectdbobject.pas b/source/selectdbobject.pas index d8b7314b..f16c0e85 100644 --- a/source/selectdbobject.pas +++ b/source/selectdbobject.pas @@ -66,8 +66,6 @@ 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 +74,8 @@ end; procedure TfrmSelectDBObject.FormDestroy(Sender: TObject); begin - AppSettings.WriteInt(asSelectDBOWindowWidth, Width); - AppSettings.WriteInt(asSelectDBOWindowHeight, Height); + AppSettings.WriteIntDpiAware(asSelectDBOWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asSelectDBOWindowHeight, Self, Height); end; @@ -98,6 +96,8 @@ 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.pas b/source/sqlhelp.pas index 04a6c0c9..ad530578 100644 --- a/source/sqlhelp.pas +++ b/source/sqlhelp.pas @@ -85,14 +85,6 @@ procedure TfrmSQLhelp.FormCreate(Sender: TObject); begin // Set window-layout lblKeyword.Font.Style := [fsBold]; - 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); Caption := DEFAULT_WINDOW_CAPTION; FixVT(treeTopics); HasSizeGrip := True; @@ -109,10 +101,10 @@ procedure TfrmSQLhelp.FormClose(Sender: TObject; var Action: TCloseAction); begin AppSettings.WriteInt(asSQLHelpWindowLeft, Left ); AppSettings.WriteInt(asSQLHelpWindowTop, Top ); - AppSettings.WriteInt(asSQLHelpWindowWidth, Width); - AppSettings.WriteInt(asSQLHelpWindowHeight, Height); - AppSettings.WriteInt(asSQLHelpPnlLeftWidth, pnlLeft.Width); - AppSettings.WriteInt(asSQLHelpPnlRightTopHeight, memoDescription.Height); + 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; @@ -272,6 +264,14 @@ 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; // These SynMemo's don't have any (SQL) highligher, so we have to assign correct colors for basic text diff --git a/source/tabletools.pas b/source/tabletools.pas index 15bdda0c..e3b80f7d 100644 --- a/source/tabletools.pas +++ b/source/tabletools.pas @@ -250,11 +250,6 @@ begin DATA_INSERTNEW := _('Insert ignore (do not update existing)'); DATA_UPDATE := _('Replace existing data'); - // Restore GUI setup - Width := AppSettings.ReadInt(asTableToolsWindowWidth); - Height := AppSettings.ReadInt(asTableToolsWindowHeight); - TreeObjects.Width := AppSettings.ReadInt(asTableToolsTreeWidth); - // Find text tab memoFindText.Text := AppSettings.ReadString(asTableToolsFindText); SynMemoFindText.Text := AppSettings.ReadString(asTableToolsFindSQL); @@ -320,6 +315,11 @@ var idx: Integer; DBObj: TDBObject; begin + // Restore GUI setup + Width := AppSettings.ReadIntDpiAware(asTableToolsWindowWidth, Self); + Height := AppSettings.ReadIntDpiAware(asTableToolsWindowHeight, Self); + TreeObjects.Width := AppSettings.ReadIntDpiAware(asTableToolsTreeWidth, Self); + // When this form is displayed the second time, databases may be deleted or filtered. // Also, checked nodes must be unchecked and unchecked nodes may need to be checked. TreeObjects.Clear; @@ -462,9 +462,9 @@ begin if Assigned(FTargetConnection) then FreeAndNil(FTargetConnection); // Save GUI setup - AppSettings.WriteInt(asTableToolsWindowWidth, Width); - AppSettings.WriteInt(asTableToolsWindowHeight, Height); - AppSettings.WriteInt(asTableToolsTreeWidth, TreeObjects.Width); + AppSettings.WriteIntDpiAware(asTableToolsWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asTableToolsWindowHeight, Self, Height); + AppSettings.WriteIntDpiAware(asTableToolsTreeWidth, Self, TreeObjects.Width); end; diff --git a/source/texteditor.pas b/source/texteditor.pas index a00827a7..463b5888 100644 --- a/source/texteditor.pas +++ b/source/texteditor.pas @@ -211,14 +211,6 @@ begin menuMacLB.Tag := Integer(lbsMac); menuWideLB.Tag := Integer(lbsWide); menuMixedLB.Tag := Integer(lbsMixed); - // Restore form dimensions - Width := AppSettings.ReadInt(asMemoEditorWidth); - Height := AppSettings.ReadInt(asMemoEditorHeight); - if AppSettings.ReadBool(asMemoEditorMaximized) then - WindowState := wsMaximized; - - if AppSettings.ReadBool(asMemoEditorWrap) then - btnWrap.Click; Highlighters := SynEditHighlighter.GetPlaceableHighlighters; for i:=0 to Highlighters.Count-1 do begin @@ -235,8 +227,8 @@ end; procedure TfrmTextEditor.FormDestroy(Sender: TObject); begin if WindowState <> wsMaximized then begin - AppSettings.WriteInt(asMemoEditorWidth, Width); - AppSettings.WriteInt(asMemoEditorHeight, Height); + AppSettings.WriteIntDpiAware(asMemoEditorWidth, Self, Width); + AppSettings.WriteIntDpiAware(asMemoEditorHeight, Self, Height); end; AppSettings.WriteBool(asMemoEditorMaximized, WindowState=wsMaximized); AppSettings.WriteBool(asMemoEditorWrap, btnWrap.Down); @@ -251,6 +243,15 @@ procedure TfrmTextEditor.FormShow(Sender: TObject); var HighlighterName: String; begin + // Restore form dimensions + Width := AppSettings.ReadIntDpiAware(asMemoEditorWidth, Self); + Height := AppSettings.ReadIntDpiAware(asMemoEditorHeight, Self); + if AppSettings.ReadBool(asMemoEditorMaximized) then + WindowState := wsMaximized; + + if AppSettings.ReadBool(asMemoEditorWrap) then + btnWrap.Click; + // Select previously used highlighter HighlighterName := AppSettings.GetDefaultString(asMemoEditorHighlighter); if Assigned(FTableColumn) then begin diff --git a/source/theme_preview.pas b/source/theme_preview.pas index 3795d7e9..7208a789 100644 --- a/source/theme_preview.pas +++ b/source/theme_preview.pas @@ -43,8 +43,8 @@ end; procedure TfrmThemePreview.FormShow(Sender: TObject); begin - Width := AppSettings.ReadInt(asThemePreviewWidth); - Height := AppSettings.ReadInt(asThemePreviewHeight); + Width := AppSettings.ReadIntDpiAware(asThemePreviewWidth, Self); + Height := AppSettings.ReadIntDpiAware(asThemePreviewHeight, Self); Top := AppSettings.ReadInt(asThemePreviewTop); Left := AppSettings.ReadInt(asThemePreviewLeft); ToggleCheckBoxWithoutClick(FToggleCheckbox, True); @@ -53,8 +53,8 @@ end; procedure TfrmThemePreview.FormClose(Sender: TObject; var Action: TCloseAction); begin - AppSettings.WriteInt(asThemePreviewWidth, Width); - AppSettings.WriteInt(asThemePreviewHeight, Height); + AppSettings.WriteIntDpiAware(asThemePreviewWidth, Self, Width); + AppSettings.WriteIntDpiAware(asThemePreviewHeight, Self, Height); AppSettings.WriteInt(asThemePreviewTop, Top); AppSettings.WriteInt(asThemePreviewLeft, Left); ToggleCheckBoxWithoutClick(FToggleCheckbox, False); diff --git a/source/updatecheck.pas b/source/updatecheck.pas index f3806ba7..c8663ab9 100644 --- a/source/updatecheck.pas +++ b/source/updatecheck.pas @@ -65,14 +65,12 @@ begin imgDonate.OnClick := MainForm.DonateClick; imgDonate.Visible := MainForm.HasDonated(False) = nbFalse; HasSizeGrip := True; - Width := AppSettings.ReadInt(asUpdateCheckWindowWidth); - Height := AppSettings.ReadInt(asUpdateCheckWindowHeight); end; procedure TfrmUpdateCheck.FormClose(Sender: TObject; var Action: TCloseAction); begin - AppSettings.WriteInt(asUpdateCheckWindowWidth, Width); - AppSettings.WriteInt(asUpdateCheckWindowHeight, Height); + AppSettings.WriteIntDpiAware(asUpdateCheckWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asUpdateCheckWindowHeight, Self, Height); end; {** @@ -90,6 +88,8 @@ 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 diff --git a/source/usermanager.pas b/source/usermanager.pas index 22028a99..0992502d 100644 --- a/source/usermanager.pas +++ b/source/usermanager.pas @@ -208,12 +208,6 @@ begin // Restore GUI setup HasSizeGrip := True; lblWarning.Font.Color := clRed; - Width := AppSettings.ReadInt(asUsermanagerWindowWidth); - Height := AppSettings.ReadInt(asUsermanagerWindowHeight); - pnlLeft.Width := AppSettings.ReadInt(asUsermanagerListWidth); - FixVT(listUsers); - FixVT(treePrivs); - Mainform.RestoreListSetup(listUsers); PrivsRead := Explode(',', 'SELECT,SHOW VIEW,SHOW DATABASES,PROCESS,EXECUTE'); PrivsWrite := Explode(',', 'ALTER,CREATE,DROP,DELETE,UPDATE,INSERT,ALTER ROUTINE,CREATE ROUTINE,CREATE TEMPORARY TABLES,'+ 'CREATE VIEW,INDEX,TRIGGER,EVENT,REFERENCES,CREATE TABLESPACE'); @@ -250,6 +244,13 @@ var end; begin + Width := AppSettings.ReadIntDpiAware(asUsermanagerWindowWidth, Self); + Height := AppSettings.ReadIntDpiAware(asUsermanagerWindowHeight, Self); + pnlLeft.Width := AppSettings.ReadIntDpiAware(asUsermanagerListWidth, Self); + FixVT(listUsers); + FixVT(treePrivs); + Mainform.RestoreListSetup(listUsers); + FConnection := Mainform.ActiveConnection; Version := FConnection.ServerVersionInt; FPrivsGlobal := InitPrivList('FILE,PROCESS,RELOAD,SHUTDOWN'); @@ -403,9 +404,9 @@ begin FreeAndNil(FPrivsRoutine); FreeAndNil(FPrivsColumn); // Save GUI setup - AppSettings.WriteInt(asUsermanagerWindowWidth, Width); - AppSettings.WriteInt(asUsermanagerWindowHeight, Height); - AppSettings.WriteInt(asUsermanagerListWidth, pnlLeft.Width); + AppSettings.WriteIntDpiAware(asUsermanagerWindowWidth, Self, Width); + AppSettings.WriteIntDpiAware(asUsermanagerWindowHeight, Self, Height); + AppSettings.WriteIntDpiAware(asUsermanagerListWidth, Self, pnlLeft.Width); Mainform.SaveListSetup(listUsers); end;