(Hopefully) fix game camera being shifted on Windows 10
authoralfadur
Fri, 06 Oct 2017 14:45:22 +0200
changeset 12657 2065819170ce
parent 12656 161c10db4f27
child 12658 966124c80861
(Hopefully) fix game camera being shifted on Windows 10 IMPORTANT: This fix needs testing before 0.9.23 release!
hedgewars/hwengine.pas
--- a/hedgewars/hwengine.pas	Fri Oct 06 14:03:13 2017 +0200
+++ b/hedgewars/hwengine.pas	Fri Oct 06 14:45:22 2017 +0200
@@ -36,6 +36,7 @@
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}
      {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF}
      {$IFDEF ANDROID}, GLUnit{$ENDIF}
+     {$IFDEF WIN32}, dynlibs{$ENDIF}
      ;
 
 {$IFDEF HWLIBRARY}
@@ -52,6 +53,12 @@
 procedure freeEverything(complete:boolean); forward;
 {$ENDIF}
 
+{$IFDEF WIN32}
+type TSetProcessDpiAwareness = function(value: Integer): Integer; stdcall;
+var SetProcessDpiAwareness: TSetProcessDpiAwareness;
+var ShcoreLibHandle: TLibHandle;
+{$ENDIF}
+
 ///////////////////////////////////////////////////////////////////////////////
 function DoTimer(Lag: LongInt): boolean;
 var s: shortstring;
@@ -587,6 +594,17 @@
 begin
 {$ENDIF}
 
+{$IFDEF WIN32}
+    ShcoreLibHandle := LoadLibrary('Shcore.dll');
+    if (ShcoreLibHandle <> 0) then
+    begin
+        SetProcessDpiAwareness :=
+            TSetProcessDpiAwareness(GetProcedureAddress(ShcoreLibHandle, 'SetProcessDpiAwareness'));
+        if (SetProcessDpiAwareness <> nil) then
+            SetProcessDpiAwareness(1);
+    end;
+{$ENDIF}
+
 ///////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////// m a i n ///////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////