Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Low/High DPI zur Laufzeit ändern? (https://www.delphipraxis.net/198573-low-high-dpi-zur-laufzeit-aendern.html)

Thomasl 22. Jul 2021 15:13

AW: Low/High DPI zur Laufzeit ändern?
 
Ab Windows10 1809 gibt es ja UnawareGdiScaled

Das Funktioniert sogar.
Alle Schriften sind mit voller Auflösung scharf.
Oder auch selbst gemaltes mit GDI+.
Ohne jetzt mit viel Aufwand ein ganzes Programm auf PerMonitorAwareV2 zu ändern.

Jetzt zum Problem. Das geht nur wenn DoubleBuffered aus ist. Sonst ist es unscharf wie vorher.
Also ohne DoubleBuffered und ParentBackground Flackert es.

Bekommt man das Flackern auch ohne DoubleBuffered weg?
Bei GDI mache ich schon nur Invalidate, dann zeichnet alles in einem rutsch


Bei ehr Statischen Programmen ist es OK mit UnawareGdiScaled ein und DoubleBuffered aus.

Aber nicht bei einem HMI wo sich viel oft ändert.

(Jetzt noch Delphi XE4)


Delphi-Quellcode:
const
  Context_Undefined = 0;
  Context_Unaware = -1;
  Context_SystemAware = -2;
  Context_PerMonitorAware = -3;
  Context_PerMonitorAwareV2 = -4;
  Context_UnawareGdiScaled = -5;

type
  TSetProcessDPIAwarenessContext = function(value: Integer): HRESULT; stdcall;


var
  setProcessDPIAwarenessContext: TSetProcessDPIAwarenessContext;
  hd2: THandle;
  hr: HRESULT;

  hd2 := LoadLibrary('user32.dll');
  if hd2 <> 0 then
  begin
    setProcessDPIAwarenessContext := GetProcAddress(hd2, 'SetProcessDpiAwarenessContext');
    if Assigned(setProcessDPIAwarenessContext) then
    begin
      hr := setProcessDPIAwarenessContext(Context_UnawareGdiScaled);
    end;
    FreeLibrary(hd2);
  end;

Thomasl 30. Jul 2021 11:56

AW: Low/High DPI zur Laufzeit ändern?
 
So geht es auch bei x64

Code:
{$IFDEF WIN64}
  TSetProcessDPIAwarenessContext = function(value: Int64): HRESULT; stdcall;
{$ELSE}
  TSetProcessDPIAwarenessContext = function(value: Integer): HRESULT; stdcall;
{$ENDIF}


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:13 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz