Einzelnen Beitrag anzeigen

user69

Registriert seit: 10. Dez 2004
92 Beiträge
 
#1

High DPI per Monitor V2 (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)

  Alt 29. Nov 2017, 17:54
Hallo,

kann mir jemand helfen, wie ich in Delphi 10 (Berlin) herausfinde ob mein Programm in High DPI per Monitor V2 läuft?

Dass ich das Programm per Manifest in ab Win10 1703 in Per Monitor DPI 2 schalten kann weiß ich.
(<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>)

Aber wie frage ich ab ob mein Programm wirklich PerMonitorDPIV2 bekommen hat (für ältere Win10 ist das nämlich nicht so)?

Der folgende Code sollte dies machen, aber mir fehlen die Deklarationen für:
GetThreadDpiAwarenessContext
AreDpiAwarenessContextsEqual

Die sind in Delphi 10 Berlin noch nicht vorhanden. Und ich tu mich da schwer, dies richtig zu machen. Bei MSDN findet man die ja, aber wie müssen die in Delphi aussehen?
https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx


Delphi-Quellcode:
function GetDPIAwareness: Integer;
type
  DPI_AWARENESS_CONTEXT = type THandle;
const
  DPI_AWARENESS_CONTEXT_UNAWARE = DPI_AWARENESS_CONTEXT(-1);
  DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = DPI_AWARENESS_CONTEXT(-2);
  DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = DPI_AWARENESS_CONTEXT(-3);
  DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = DPI_AWARENESS_CONTEXT(-4);
var dpiAwarenessContext: DPI_AWARENESS_CONTEXT;
begin
  Result:= 0; //asume unaware
  // Get the DPI awareness of the window from the DPI-awareness context of the thread
  dpiAwarenessContext := GetThreadDpiAwarenessContext();
  // Convert DPI awareness to a string
  if IsDpiAware then begin
    if (AreDpiAwarenessContextsEqual(dpiAwarenessContext, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)) then begin
       //DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
       Result:= 2;
    end
    else begin
       //DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
       Result:= 1;
    end;
  end;
end;
Kann mir jemand bei den Deklarationen helfen? Ich denk die Funktionen stammen aus user32
Danke
  Mit Zitat antworten Zitat