Skip to content

HighDpi problems

mattia72 edited this page Dec 19, 2024 · 1 revision

https://zarko-gajic.iz.hr/delphi-high-dpi-road-ensuring-your-ui-looks-correctly/

To get DPI of current monitor:

function TRipGrepperDpiScaler.GetActualDPI : Integer;
begin
	var
	dbgMsg := TDebugMsgBeginEnd.New('TRipGrepperDpiScaler.GetActualDPI', True);
	var
	monitor := Screen.MonitorFromWindow(GetForegroundWindow());
	if (Assigned(monitor)) then begin
		dbgMsg.Msg('Monitor.ppi: ' + monitor.PixelsPerInch.ToString);
		Result := monitor.PixelsPerInch;
	end else begin
		dbgMsg.Msg('Screen.ppi: ' + monitor.PixelsPerInch.ToString);
		Result := Screen.PixelsPerInch;
	end;
end;
Clone this wiki locally