Giving up on high DPI readiness - remove tweaks which mostly don't work as expected, and even differently on various computers. Instead, let Windows blur fonts.

This commit is contained in:
Ansgar Becker
2019-07-18 20:53:53 +02:00
parent 2ebbdc6ba3
commit c31cae2060
21 changed files with 50 additions and 85 deletions

View File

@ -2,13 +2,6 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
<description>A lightweight, fast and flexible interface to MySQL</description>
<dependency>

View File

@ -96,8 +96,8 @@ end;
procedure TfrmBinEditor.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asMemoEditorWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asMemoEditorHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asMemoEditorWidth, Width);
AppSettings.WriteInt(asMemoEditorHeight, Height);
AppSettings.WriteBool(asMemoEditorWrap, btnWrap.Down);
end;

View File

@ -55,8 +55,8 @@ end;
procedure TColumnSelectionForm.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asColumnSelectorWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asColumnSelectorHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asColumnSelectorWidth, Width);
AppSettings.WriteInt(asColumnSelectorHeight, Height);
FCheckedColumns.Free;
end;

View File

@ -348,9 +348,9 @@ end;
procedure Tconnform.FormDestroy(Sender: TObject);
begin
// Save GUI stuff
AppSettings.WriteInt(asSessionManagerListWidth, Round(ListSessions.Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSessionManagerWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSessionManagerWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSessionManagerListWidth, ListSessions.Width);
AppSettings.WriteInt(asSessionManagerWindowWidth, Width);
AppSettings.WriteInt(asSessionManagerWindowHeight, Height);
AppSettings.WriteInt(asSessionManagerWindowLeft, Left);
AppSettings.WriteInt(asSessionManagerWindowTop, Top);
MainForm.SaveListSetup(ListSessions);

View File

@ -83,8 +83,8 @@ end;
procedure TCopyTableForm.FormDestroy(Sender: TObject);
begin
// Save GUI stuff
AppSettings.WriteInt(asCopyTableWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asCopyTableWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asCopyTableWindowWidth, Width);
AppSettings.WriteInt(asCopyTableWindowHeight, Height);
end;

View File

@ -83,12 +83,12 @@ begin
Components[i].Free;
end;
Margin := Round(3 * DpiScaleFactor(Self));
Margin := 3;
MarginBig := Margin * 2;
Width1 := Round(15 * DpiScaleFactor(Self));
Width2 := Round(160 * DpiScaleFactor(Self));
Width3 := Round(23 * DpiScaleFactor(Self));
Width4 := Round(23 * DpiScaleFactor(Self));
Width1 := 15;
Width2 := 160;
Width3 := 23;
Width4 := 23;
// Set initial width to avoid resizing form to 0
TopPos := pnlBevel.BorderWidth + MarginBig;

View File

@ -64,8 +64,8 @@ end;
procedure TfrmEditVariable.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asEditVarWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asEditVarWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asEditVarWindowWidth, Width);
AppSettings.WriteInt(asEditVarWindowHeight, Height);
end;

View File

@ -149,8 +149,8 @@ procedure TfrmExportGrid.FormDestroy(Sender: TObject);
begin
// Store settings
if not FHiddenCopyMode then begin
AppSettings.WriteInt(asGridExportWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asGridExportWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asGridExportWindowWidth, Width);
AppSettings.WriteInt(asGridExportWindowHeight, Height);
if ModalResult = mrOK then begin
AppSettings.WriteBool(asGridExportOutputCopy, radioOutputCopyToClipboard.Checked);
AppSettings.WriteBool(asGridExportOutputFile, radioOutputFile.Checked);

View File

@ -15,7 +15,6 @@ type
public
constructor Create(AOwner: TComponent); override;
procedure AddSizeGrip;
function DpiScaleFactor(Form: TForm=nil): Double;
procedure InheritFont(AFont: TFont);
protected
procedure DoShow; override;
@ -64,12 +63,6 @@ begin
end;
function TExtForm.DpiScaleFactor(Form: TForm=nil): Double;
begin
Result := Monitor.PixelsPerInch / FPixelsPerInchOnDefaultMonitor;
end;
procedure TExtForm.InheritFont(AFont: TFont);
var
LogFont: TLogFont;
@ -84,12 +77,12 @@ begin
// Apply user specified font
AFont.Name := GUIFontName;
// Set size on top of automatic dpi-increased size
AFont.Size := Round(AppSettings.ReadInt(asGUIFontSize) * DpiScaleFactor);
AFont.Size := AppSettings.ReadInt(asGUIFontSize);
end else begin
// Apply system font. See issue #3204.
// Code taken from http://www.gerixsoft.com/blog/delphi/system-font
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(TLogFont), @LogFont, 0) then begin
AFont.Height := Round(LogFont.lfHeight * DpiScaleFactor);
AFont.Height := LogFont.lfHeight;
AFont.Orientation := LogFont.lfOrientation;
AFont.Charset := TFontCharset(LogFont.lfCharSet);
AFont.Name := PChar(@LogFont.lfFaceName);

View File

@ -129,8 +129,8 @@ end;
procedure TfrmInsertFiles.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asFileImportWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asFileImportWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asFileImportWindowWidth, Width);
AppSettings.WriteInt(asFileImportWindowHeight, Height);
MainForm.SaveListSetup(ListColumns);
MainForm.SaveListSetup(listFiles);
end;

View File

@ -117,8 +117,8 @@ end;
procedure Tloaddataform.FormDestroy(Sender: TObject);
begin
// Save settings
AppSettings.WriteInt(asCSVImportWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asCSVImportWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asCSVImportWindowWidth, Width);
AppSettings.WriteInt(asCSVImportWindowHeight, Height);
AppSettings.WriteString(asCSVImportFilename, editFilename.Text);
AppSettings.WriteString(asCSVImportSeparator, editFieldTerminator.Text);
AppSettings.WriteString(asCSVImportEncloser, editFieldEncloser.Text);

View File

@ -658,7 +658,6 @@ type
procedure actExitApplicationExecute(Sender: TObject);
procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
procedure CMStyleChanged(var Msg: TMessage); message CM_STYLECHANGED;
procedure DPIChanged(var Msg: TMessage); message WM_DPICHANGED;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure AfterFormCreate;
@ -1922,8 +1921,8 @@ begin
// Data-Font:
DataGrid.Font.Name := AppSettings.ReadString(asDataFontName);
QueryGrid.Font.Name := AppSettings.ReadString(asDataFontName);
DataGrid.Font.Size := Round(AppSettings.ReadInt(asDataFontSize) * DpiScaleFactor(Self));
QueryGrid.Font.Size := Round(AppSettings.ReadInt(asDataFontSize) * DpiScaleFactor(Self));
DataGrid.Font.Size := AppSettings.ReadInt(asDataFontSize);
QueryGrid.Font.Size := AppSettings.ReadInt(asDataFontSize);
FixVT(DataGrid, AppSettings.ReadInt(asGridRowLineCount));
FixVT(QueryGrid, AppSettings.ReadInt(asGridRowLineCount));
// Load color settings
@ -2537,7 +2536,7 @@ var
function CalcPanelWidth(PreferredWidth, Percentage: Integer): Integer;
begin
Result := Round(Min(PreferredWidth * DpiScaleFactor(Self), Width / 100 * Percentage));
Result := Round(Min(PreferredWidth, Width / 100 * Percentage));
end;
begin
// Exit early when user pressed "Cancel" on connection dialog
@ -7537,8 +7536,6 @@ var
i, ColWidth: Integer;
ColWidths, ColsVisible, ColPos, Regname: String;
OwnerForm: TWinControl;
IsFrame: Boolean;
ScaleDownFactor: Double;
begin
// Prevent sporadic crash on startup
if List = nil then
@ -7547,16 +7544,12 @@ begin
ColsVisible := '';
ColPos := '';
OwnerForm := GetParentFormOrFrame(List);
IsFrame := OwnerForm is TFrame;
ScaleDownFactor := DpiScaleFactor(GetParentForm(List) as TForm);
for i := 0 to List.Header.Columns.Count - 1 do
begin
// Column widths
if ColWidths <> '' then
ColWidths := ColWidths + ',';
ColWidth := List.Header.Columns[i].Width;
if IsFrame then
ColWidth := Round(ColWidth / ScaleDownFactor);
ColWidths := ColWidths + IntToStr(ColWidth);
// Column visibility
@ -8012,14 +8005,14 @@ var
begin
// Apply somehow changed font settings to all existing grids
DataGrid.Font.Name := AppSettings.ReadString(asDataFontName);
DataGrid.Font.Size := Round(AppSettings.ReadInt(asDataFontSize) * DpiScaleFactor(Self));
DataGrid.Font.Size := AppSettings.ReadInt(asDataFontSize);
FixVT(Mainform.DataGrid, AppSettings.ReadInt(asGridRowLineCount));
for i:=Mainform.tabQuery.PageIndex to Mainform.PageControlMain.PageCount-1 do begin
QueryTab := Mainform.QueryTabs[i-Mainform.tabQuery.PageIndex];
for j:=0 to QueryTab.ResultTabs.Count-1 do begin
Grid := QueryTab.ResultTabs[j].Grid;
Grid.Font.Name := AppSettings.ReadString(asDataFontName);
Grid.Font.Size := Round(AppSettings.ReadInt(asDataFontSize) * DpiScaleFactor(Self));
Grid.Font.Size := AppSettings.ReadInt(asDataFontSize);
FixVT(Grid, AppSettings.ReadInt(asGridRowLineCount));
end;
end;
@ -11521,7 +11514,7 @@ begin
Editor.Color := GetThemeColor(clWindow);
Editor.ScrollHintColor := GetThemeColor(clInfoBk);
Editor.Font.Name := AppSettings.ReadString(asFontName);
Editor.Font.Size := Round(AppSettings.ReadInt(asFontSize) * DpiScaleFactor(Self));
Editor.Font.Size := AppSettings.ReadInt(asFontSize);
Editor.Gutter.BorderColor := GetThemeColor(clWindow);
Editor.Gutter.Color := GetThemeColor(clBtnFace);
Editor.Gutter.Font.Name := Editor.Font.Name;
@ -11839,20 +11832,6 @@ begin
end;
procedure TMainForm.DPIChanged(var Msg: TMessage);
const
DesignedToolbarHeight = 22;
DesignedToolbarWidth = 23;
begin
inherited;
LogSQL('New PPI:'+ Monitor.PixelsPerInch.ToString, lcDebug);
// Fix wrong calculated height and width of tool buttons after DPI change / move between monitors
ToolBarMainButtons.ButtonHeight := Round(DesignedToolbarHeight * DpiScaleFactor(Self));
ToolBarMainButtons.ButtonWidth := Round(DesignedToolbarWidth * DpiScaleFactor(Self));
end;
procedure TMainForm.DefaultHandler(var Message);
begin
if TMessage(Message).Msg = SecondInstMsgId then begin

View File

@ -610,8 +610,8 @@ end;
procedure Toptionsform.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asPreferencesWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asPreferencesWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asPreferencesWindowWidth, Width);
AppSettings.WriteInt(asPreferencesWindowHeight, Height);
end;
procedure Toptionsform.FormShow(Sender: TObject);

View File

@ -184,11 +184,11 @@ begin
btnSave.Enabled := Modified;
btnDiscard.Enabled := Modified;
// Buttons are randomly moved, since VirtualTree update, see #440
btnSave.Top := Height - btnSave.Height - Round(3 * MainForm.DpiScaleFactor);
btnSave.Top := Height - btnSave.Height - 3;
btnHelp.Top := btnSave.Top;
btnDiscard.Top := btnSave.Top;
btnRunProc.Top := btnSave.Top;
btnRunProc.Left := Width - btnRunProc.Width - Round(3 * MainForm.DpiScaleFactor);
btnRunProc.Left := Width - btnRunProc.Width - 3;
Mainform.actRunRoutines.Enabled := DBObject.Name <> '';
Mainform.ShowStatusMsg;
Screen.Cursor := crDefault;

View File

@ -74,8 +74,8 @@ end;
procedure TfrmSelectDBObject.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asSelectDBOWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSelectDBOWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSelectDBOWindowWidth, Width);
AppSettings.WriteInt(asSelectDBOWindowHeight, Height);
end;

View File

@ -265,10 +265,10 @@ procedure TfrmSQLhelp.FormDestroy(Sender: TObject);
begin
AppSettings.WriteInt(asSQLHelpWindowLeft, Left );
AppSettings.WriteInt(asSQLHelpWindowTop, Top );
AppSettings.WriteInt(asSQLHelpWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSQLHelpWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSQLHelpPnlLeftWidth, Round(pnlLeft.Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSQLHelpPnlRightTopHeight, Round(memoDescription.Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asSQLHelpWindowWidth, Width);
AppSettings.WriteInt(asSQLHelpWindowHeight, Height);
AppSettings.WriteInt(asSQLHelpPnlLeftWidth, pnlLeft.Width);
AppSettings.WriteInt(asSQLHelpPnlRightTopHeight, memoDescription.Height);
SqlHelpDialog := nil;
end;

View File

@ -353,7 +353,7 @@ begin
AlterCodeValid := False;
PageControlMainChange(Self); // Foreign key editor needs a hit
// Buttons are randomly moved, since VirtualTree update, see #440
btnSave.Top := Height - btnSave.Height - Round(3 * MainForm.DpiScaleFactor);
btnSave.Top := Height - btnSave.Height - 3;
btnHelp.Top := btnSave.Top;
btnDiscard.Top := btnSave.Top;
UpdateSQLCode;

View File

@ -304,9 +304,9 @@ end;
procedure TfrmTableTools.FormDestroy(Sender: TObject);
begin
// Save GUI setup
AppSettings.WriteInt(asTableToolsWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asTableToolsWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asTableToolsTreeWidth, Round(TreeObjects.Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asTableToolsWindowWidth, Width);
AppSettings.WriteInt(asTableToolsWindowHeight, Height);
AppSettings.WriteInt(asTableToolsTreeWidth, TreeObjects.Width);
end;

View File

@ -225,8 +225,8 @@ end;
procedure TfrmTextEditor.FormDestroy(Sender: TObject);
begin
if WindowState <> wsMaximized then begin
AppSettings.WriteInt(asMemoEditorWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asMemoEditorHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asMemoEditorWidth, Width);
AppSettings.WriteInt(asMemoEditorHeight, Height);
end;
AppSettings.WriteBool(asMemoEditorMaximized, WindowState=wsMaximized);
AppSettings.WriteBool(asMemoEditorWrap, btnWrap.Down);

View File

@ -164,7 +164,7 @@ begin
end;
end;
// Buttons are randomly moved, since VirtualTree update, see #440
btnSave.Top := Height - btnSave.Height - Round(3 * MainForm.DpiScaleFactor);
btnSave.Top := Height - btnSave.Height - 3;
btnHelp.Top := btnSave.Top;
btnDiscard.Top := btnSave.Top;
Modification(Self);

View File

@ -225,9 +225,9 @@ end;
procedure TUserManagerForm.FormDestroy(Sender: TObject);
begin
// FormDestroy: Save GUI setup
AppSettings.WriteInt(asUsermanagerWindowWidth, Round(Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asUsermanagerWindowHeight, Round(Height / DpiScaleFactor(Self)));
AppSettings.WriteInt(asUsermanagerListWidth, Round(pnlLeft.Width / DpiScaleFactor(Self)));
AppSettings.WriteInt(asUsermanagerWindowWidth, Width);
AppSettings.WriteInt(asUsermanagerWindowHeight, Height);
AppSettings.WriteInt(asUsermanagerListWidth, pnlLeft.Width);
Mainform.SaveListSetup(listUsers);
end;