Skip to content

Commit

Permalink
Issue #718: Fonts may be too large because they get scaled before the…
Browse files Browse the repository at this point in the history
… window gets moved to the wanted screen. So, this moves the code for scaling fonts to FormShow, so we can scale fonts according to the screen's DPI setting.
  • Loading branch information
ansgarbecker committed Jul 18, 2019
1 parent 70c79b3 commit 6a75e8c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion source/extra_controls.pas
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ interface
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
FFontSet: Boolean;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
procedure AddSizeGrip; procedure AddSizeGrip;
class procedure InheritFont(AFont: TFont; Form: TForm); class procedure InheritFont(AFont: TFont; Form: TForm);
protected
procedure DoShow; override;
end; end;
// Memo replacement which accepts any line break format // Memo replacement which accepts any line break format
TLineNormalizingMemo = class(TMemo) TLineNormalizingMemo = class(TMemo)
Expand All @@ -30,9 +34,22 @@ implementation
constructor TExtForm.Create(AOwner: TComponent); constructor TExtForm.Create(AOwner: TComponent);
begin begin
inherited; inherited;
InheritFont(Font, Self); FFontSet := False;
end;


procedure TExtForm.DoShow;
begin
// Expect the window to be on the wanted monitor now, so we can scale fonts according
// to the screen's DPI setting
if not FFontSet then begin
InheritFont(Font, Self);
FFontSet := True;
end;
inherited;
end; end;



procedure TExtForm.AddSizeGrip; procedure TExtForm.AddSizeGrip;
var var
FGripper: TSizeGripThemed; FGripper: TSizeGripThemed;
Expand Down

0 comments on commit 6a75e8c

Please sign in to comment.