Einzelnen Beitrag anzeigen

PeterPanino

Registriert seit: 4. Sep 2004
1.451 Beiträge
 
Delphi 10.4 Sydney
 
#1

Screen DPI und TrayIcon Größe?

  Alt 19. Okt 2023, 13:26
Ich verwende diesen Code zur Bestimmung des SCREEN DPI Wertes:

Delphi-Quellcode:
function GetScalingFactor: Integer;
// The function returns the number of pixels per logical inch along the screen width. Normally, this will be 96
// for a scaling of 100%. Higher values indicate higher scaling.
// Once you have the scaling factor, you can make an educated guess about the tray icon size. For example,
// if the scaling is 100% (96 DPI), a 16x16 icon is typical. For 200% (192 DPI), you might want to use a 32x32 icon.
// Please note that this is not a foolproof method; it's more of an educated guess based on the system's DPI settings.
var
  hdc: Winapi.Windows.HDC;
begin
  hdc := GetDC(0);
  try
    Result := GetDeviceCaps(hdc, LOGPIXELSX);
  finally
    ReleaseDC(0, hdc);
  end;
end;
Könnt ihr bitte mal testen, ob sich die Pixelgröße der Tray Icons abhängig von diesem Wert ändert?

Zweck: Ich erzeuge das Icon für mein Tray Icon dynamisch zur Laufzeit. Auf meinem Bildschirm ergibt die Tray Icon Größe 32x32 Pixel. Aber das könnte bei anderen Bildschirmen ja anders sein.
Geändert von PeterPanino, damit der Platz auf dem Bildschirm nicht so leer aussieht.
  Mit Zitat antworten Zitat