mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #718: Fonts may still be too large because the monitor on which a form is created has DPI > 100%. Calculate DpiScaleFactor based on that first monitor. See https://www.heidisql.com/forum.php?t=34230
This commit is contained in:
@ -356,7 +356,6 @@ type
|
|||||||
function GetCurrentPackageFullName(out Len: Cardinal; Name: PWideChar): Integer; stdcall; external kernel32 delayed;
|
function GetCurrentPackageFullName(out Len: Cardinal; Name: PWideChar): Integer; stdcall; external kernel32 delayed;
|
||||||
function GetUwpFullName: String;
|
function GetUwpFullName: String;
|
||||||
function RunningAsUwp: Boolean;
|
function RunningAsUwp: Boolean;
|
||||||
function DpiScaleFactor(Form: TForm): Double;
|
|
||||||
function GetThemeColor(Color: TColor): TColor;
|
function GetThemeColor(Color: TColor): TColor;
|
||||||
function ThemeIsDark(ThemeName: String): Boolean;
|
function ThemeIsDark(ThemeName: String): Boolean;
|
||||||
function ProcessExists(pid: Cardinal): Boolean;
|
function ProcessExists(pid: Cardinal): Boolean;
|
||||||
@ -2935,12 +2934,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function DpiScaleFactor(Form: TForm): Double;
|
|
||||||
begin
|
|
||||||
Result := Form.Monitor.PixelsPerInch / Form.PixelsPerInch;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function GetThemeColor(Color: TColor): TColor;
|
function GetThemeColor(Color: TColor): TColor;
|
||||||
begin
|
begin
|
||||||
// Not required with vcl-style-utils:
|
// Not required with vcl-style-utils:
|
||||||
|
@ -4,17 +4,19 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Forms, Windows, Messages, System.Types, StdCtrls, Clipbrd,
|
Classes, SysUtils, Forms, Windows, Messages, System.Types, StdCtrls, Clipbrd,
|
||||||
SizeGrip, SizeGripThemed, apphelpers, Vcl.Graphics;
|
SizeGrip, SizeGripThemed, apphelpers, Vcl.Graphics, Vcl.Dialogs;
|
||||||
|
|
||||||
type
|
type
|
||||||
// Form with a sizegrip in the lower right corner, without the need for a statusbar
|
// Form with a sizegrip in the lower right corner, without the need for a statusbar
|
||||||
TExtForm = class(TForm)
|
TExtForm = class(TForm)
|
||||||
private
|
private
|
||||||
FFontSet: Boolean;
|
FFontSet: Boolean;
|
||||||
|
FPixelsPerInchOnDefaultMonitor: Integer;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure AddSizeGrip;
|
procedure AddSizeGrip;
|
||||||
class procedure InheritFont(AFont: TFont; Form: TForm);
|
function DpiScaleFactor(Form: TForm=nil): Double;
|
||||||
|
procedure InheritFont(AFont: TFont);
|
||||||
protected
|
protected
|
||||||
procedure DoShow; override;
|
procedure DoShow; override;
|
||||||
end;
|
end;
|
||||||
@ -33,6 +35,7 @@ implementation
|
|||||||
|
|
||||||
constructor TExtForm.Create(AOwner: TComponent);
|
constructor TExtForm.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
|
FPixelsPerInchOnDefaultMonitor := Screen.Monitors[0].PixelsPerInch;
|
||||||
inherited;
|
inherited;
|
||||||
FFontSet := False;
|
FFontSet := False;
|
||||||
end;
|
end;
|
||||||
@ -43,7 +46,7 @@ begin
|
|||||||
// Expect the window to be on the wanted monitor now, so we can scale fonts according
|
// Expect the window to be on the wanted monitor now, so we can scale fonts according
|
||||||
// to the screen's DPI setting
|
// to the screen's DPI setting
|
||||||
if not FFontSet then begin
|
if not FFontSet then begin
|
||||||
InheritFont(Font, Self);
|
InheritFont(Font);
|
||||||
FFontSet := True;
|
FFontSet := True;
|
||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
@ -61,7 +64,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
class procedure TExtForm.InheritFont(AFont: TFont; Form: TForm);
|
function TExtForm.DpiScaleFactor(Form: TForm=nil): Double;
|
||||||
|
begin
|
||||||
|
Result := Monitor.PixelsPerInch / FPixelsPerInchOnDefaultMonitor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TExtForm.InheritFont(AFont: TFont);
|
||||||
var
|
var
|
||||||
LogFont: TLogFont;
|
LogFont: TLogFont;
|
||||||
GUIFontName: String;
|
GUIFontName: String;
|
||||||
@ -75,12 +84,12 @@ begin
|
|||||||
// Apply user specified font
|
// Apply user specified font
|
||||||
AFont.Name := GUIFontName;
|
AFont.Name := GUIFontName;
|
||||||
// Set size on top of automatic dpi-increased size
|
// Set size on top of automatic dpi-increased size
|
||||||
AFont.Size := Round(AppSettings.ReadInt(asGUIFontSize) * DpiScaleFactor(Form));
|
AFont.Size := Round(AppSettings.ReadInt(asGUIFontSize) * DpiScaleFactor);
|
||||||
end else begin
|
end else begin
|
||||||
// Apply system font. See issue #3204.
|
// Apply system font. See issue #3204.
|
||||||
// Code taken from http://www.gerixsoft.com/blog/delphi/system-font
|
// Code taken from http://www.gerixsoft.com/blog/delphi/system-font
|
||||||
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(TLogFont), @LogFont, 0) then begin
|
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(TLogFont), @LogFont, 0) then begin
|
||||||
AFont.Height := Round(LogFont.lfHeight * DpiScaleFactor(Form));
|
AFont.Height := Round(LogFont.lfHeight * DpiScaleFactor);
|
||||||
AFont.Orientation := LogFont.lfOrientation;
|
AFont.Orientation := LogFont.lfOrientation;
|
||||||
AFont.Charset := TFontCharset(LogFont.lfCharSet);
|
AFont.Charset := TFontCharset(LogFont.lfCharSet);
|
||||||
AFont.Name := PChar(@LogFont.lfFaceName);
|
AFont.Name := PChar(@LogFont.lfFaceName);
|
||||||
|
@ -4,10 +4,10 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
Dialogs, StdCtrls, ExtCtrls, gnugettext, System.UITypes;
|
Dialogs, StdCtrls, ExtCtrls, gnugettext, System.UITypes, extra_controls;
|
||||||
|
|
||||||
type
|
type
|
||||||
TfrmLogin = class(TForm)
|
TfrmLogin = class(TExtForm)
|
||||||
btnOK: TButton;
|
btnOK: TButton;
|
||||||
pnlBackground: TPanel;
|
pnlBackground: TPanel;
|
||||||
lblPrompt: TLabel;
|
lblPrompt: TLabel;
|
||||||
|
@ -1830,7 +1830,7 @@ begin
|
|||||||
|
|
||||||
Delimiter := AppSettings.ReadString(asDelimiter);
|
Delimiter := AppSettings.ReadString(asDelimiter);
|
||||||
|
|
||||||
InheritFont(SynCompletionProposal.Font, Self);
|
InheritFont(SynCompletionProposal.Font);
|
||||||
// Simulated link label, has non inherited blue font color
|
// Simulated link label, has non inherited blue font color
|
||||||
lblExplainProcess.Font.Color := clBlue;
|
lblExplainProcess.Font.Color := clBlue;
|
||||||
lblExplainProcessAnalyzer.Font.Color := clBlue;
|
lblExplainProcessAnalyzer.Font.Color := clBlue;
|
||||||
@ -1849,7 +1849,7 @@ begin
|
|||||||
QueryTab.spltHelpers := spltQueryHelpers;
|
QueryTab.spltHelpers := spltQueryHelpers;
|
||||||
QueryTab.spltQuery := spltQuery;
|
QueryTab.spltQuery := spltQuery;
|
||||||
QueryTab.tabsetQuery := tabsetQuery;
|
QueryTab.tabsetQuery := tabsetQuery;
|
||||||
InheritFont(QueryTab.tabsetQuery.Font, Self);
|
InheritFont(QueryTab.tabsetQuery.Font);
|
||||||
QueryTab.ResultTabs := TResultTabs.Create(True);
|
QueryTab.ResultTabs := TResultTabs.Create(True);
|
||||||
|
|
||||||
QueryTabs := TObjectList<TQueryTab>.Create(True);
|
QueryTabs := TObjectList<TQueryTab>.Create(True);
|
||||||
@ -10752,7 +10752,7 @@ begin
|
|||||||
// Prevent various problems with alignment of controls. See http://www.heidisql.com/forum.php?t=18924
|
// Prevent various problems with alignment of controls. See http://www.heidisql.com/forum.php?t=18924
|
||||||
QueryTab.tabsetQuery.Top := QueryTab.spltQuery.Top + QueryTab.spltQuery.Height;
|
QueryTab.tabsetQuery.Top := QueryTab.spltQuery.Top + QueryTab.spltQuery.Height;
|
||||||
QueryTab.tabsetQuery.Align := tabsetQuery.Align;
|
QueryTab.tabsetQuery.Align := tabsetQuery.Align;
|
||||||
InheritFont(QueryTab.tabsetQuery.Font, Self);
|
InheritFont(QueryTab.tabsetQuery.Font);
|
||||||
QueryTab.tabsetQuery.Images := tabsetQuery.Images;
|
QueryTab.tabsetQuery.Images := tabsetQuery.Images;
|
||||||
QueryTab.tabsetQuery.Style := tabsetQuery.Style;
|
QueryTab.tabsetQuery.Style := tabsetQuery.Style;
|
||||||
QueryTab.tabsetQuery.TabHeight := tabsetQuery.TabHeight;
|
QueryTab.tabsetQuery.TabHeight := tabsetQuery.TabHeight;
|
||||||
|
@ -184,11 +184,11 @@ begin
|
|||||||
btnSave.Enabled := Modified;
|
btnSave.Enabled := Modified;
|
||||||
btnDiscard.Enabled := Modified;
|
btnDiscard.Enabled := Modified;
|
||||||
// Buttons are randomly moved, since VirtualTree update, see #440
|
// Buttons are randomly moved, since VirtualTree update, see #440
|
||||||
btnSave.Top := Height - btnSave.Height - Round(3 * DpiScaleFactor(MainForm));
|
btnSave.Top := Height - btnSave.Height - Round(3 * MainForm.DpiScaleFactor);
|
||||||
btnHelp.Top := btnSave.Top;
|
btnHelp.Top := btnSave.Top;
|
||||||
btnDiscard.Top := btnSave.Top;
|
btnDiscard.Top := btnSave.Top;
|
||||||
btnRunProc.Top := btnSave.Top;
|
btnRunProc.Top := btnSave.Top;
|
||||||
btnRunProc.Left := Width - btnRunProc.Width - Round(3 * DpiScaleFactor(MainForm));
|
btnRunProc.Left := Width - btnRunProc.Width - Round(3 * MainForm.DpiScaleFactor);
|
||||||
Mainform.actRunRoutines.Enabled := DBObject.Name <> '';
|
Mainform.actRunRoutines.Enabled := DBObject.Name <> '';
|
||||||
Mainform.ShowStatusMsg;
|
Mainform.ShowStatusMsg;
|
||||||
Screen.Cursor := crDefault;
|
Screen.Cursor := crDefault;
|
||||||
|
@ -353,7 +353,7 @@ begin
|
|||||||
AlterCodeValid := False;
|
AlterCodeValid := False;
|
||||||
PageControlMainChange(Self); // Foreign key editor needs a hit
|
PageControlMainChange(Self); // Foreign key editor needs a hit
|
||||||
// Buttons are randomly moved, since VirtualTree update, see #440
|
// Buttons are randomly moved, since VirtualTree update, see #440
|
||||||
btnSave.Top := Height - btnSave.Height - Round(3 * DpiScaleFactor(MainForm));
|
btnSave.Top := Height - btnSave.Height - Round(3 * MainForm.DpiScaleFactor);
|
||||||
btnHelp.Top := btnSave.Top;
|
btnHelp.Top := btnSave.Top;
|
||||||
btnDiscard.Top := btnSave.Top;
|
btnDiscard.Top := btnSave.Top;
|
||||||
UpdateSQLCode;
|
UpdateSQLCode;
|
||||||
|
@ -164,7 +164,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// Buttons are randomly moved, since VirtualTree update, see #440
|
// Buttons are randomly moved, since VirtualTree update, see #440
|
||||||
btnSave.Top := Height - btnSave.Height - Round(3 * DpiScaleFactor(MainForm));
|
btnSave.Top := Height - btnSave.Height - Round(3 * MainForm.DpiScaleFactor);
|
||||||
btnHelp.Top := btnSave.Top;
|
btnHelp.Top := btnSave.Top;
|
||||||
btnDiscard.Top := btnSave.Top;
|
btnDiscard.Top := btnSave.Top;
|
||||||
Modification(Self);
|
Modification(Self);
|
||||||
|
Reference in New Issue
Block a user