Skip to content
Permalink
Browse files

Fix wrong calculated height and width of tool buttons after DPI chang…

…e / move between monitors. Closes #446
  • Loading branch information...
ansgarbecker committed Jul 7, 2019
1 parent 2c5d6eb commit 535336850a01c3f4b68d4b75fd9a52c0f1730893
Showing with 15 additions and 0 deletions.
  1. +15 −0 source/main.pas
@@ -654,6 +654,7 @@ TMainForm = class(TForm)
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;
@@ -11767,6 +11768,20 @@ procedure TMainForm.CMStyleChanged(var Msg: TMessage);
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

0 comments on commit 5353368

Please sign in to comment.
You can’t perform that action at this time.