Browse Source

Implemented ScaleFactor() for TWindowsDesktop. Fixes #16.
Fixed Desktop client width/height calculations.

woollybah 6 năm trước cách đây
mục cha
commit
0eace12857
1 tập tin đã thay đổi với 19 bổ sung3 xóa
  1. 19 3
      win32maxguiex.mod/win32maxguiex.bmx

+ 19 - 3
win32maxguiex.mod/win32maxguiex.bmx

@@ -1530,7 +1530,7 @@ Type TWindowsDesktop Extends TWindowsGadget
 	
 	Method ClientHeight()
 		Local Rect[4]
-		If Super.ClientHeight() = height And SystemParametersInfoW( SPI_GETWORKAREA, 0, Rect, 0 ) 
+		If SystemParametersInfoW( SPI_GETWORKAREA, 0, Rect, 0 ) 
 			Return Rect[3]-Rect[1]
 		Else
 			Return Super.ClientHeight()
@@ -1539,13 +1539,29 @@ Type TWindowsDesktop Extends TWindowsGadget
 	
 	Method ClientWidth()
 		Local Rect[4]
-		If Super.ClientWidth() = width And SystemParametersInfoW( SPI_GETWORKAREA, 0, Rect, 0 ) 
+		If SystemParametersInfoW( SPI_GETWORKAREA, 0, Rect, 0 ) 
 			Return Rect[2]-Rect[0]
 		Else
 			Return Super.ClientWidth()
 		EndIf
 	EndMethod
-	
+
+	Method ScaleFactor:Int()
+		If GetDpiForMonitor Then
+			Local hwnd:Byte Ptr = GetDesktopWindow()
+			Local monitor:Byte Ptr = MonitorFromWindow(hwnd, 0)
+			If monitor Then
+				Local xdpi:UInt
+				Local ydpi:UInt
+				Local res:Byte Ptr = GetDpiForMonitor(monitor, 0, xdpi, ydpi)
+				If xdpi > 96 Then
+					Return 2
+				End If
+			End If
+		End If
+		Return 1
+	End Method
+
 EndType
 
 Type TWindowsWindow Extends TWindowsGadget