Windows: Add Screen CLass
This commit is contained in:
parent
781a6ae55b
commit
d360a43a25
22
Windows/Screen.vb
Normal file
22
Windows/Screen.vb
Normal file
@ -0,0 +1,22 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
Public Class Screen
|
||||
<DllImport("gdi32.dll")>
|
||||
Private Shared Function GetDeviceCaps(ByVal hdc As IntPtr, ByVal nIndex As Integer) As Integer
|
||||
End Function
|
||||
|
||||
Public Enum DeviceCap
|
||||
VERTRES = 10
|
||||
DESKTOPVERTRES = 117
|
||||
End Enum
|
||||
|
||||
Public Shared Function GetScalingFactor() As Single
|
||||
Dim g As Graphics = Graphics.FromHwnd(IntPtr.Zero)
|
||||
Dim desktop As IntPtr = g.GetHdc()
|
||||
Dim LogicalScreenHeight As Integer = GetDeviceCaps(desktop, CInt(DeviceCap.VERTRES))
|
||||
Dim PhysicalScreenHeight As Integer = GetDeviceCaps(desktop, CInt(DeviceCap.DESKTOPVERTRES))
|
||||
Dim ScreenScalingFactor As Single = CSng(PhysicalScreenHeight) / CSng(LogicalScreenHeight)
|
||||
Return ScreenScalingFactor
|
||||
End Function
|
||||
End Class
|
||||
@ -319,7 +319,7 @@ Public Class Window
|
||||
|
||||
Private Function GetRelativeRectangle(ControlRect As NativeMethods.RectangleAPI, WindowRect As NativeMethods.RectangleAPI, Anchor As Anchor) As NativeMethods.RectangleAPI
|
||||
Try
|
||||
Dim oScreenRect As Rectangle = Screen.PrimaryScreen.Bounds
|
||||
Dim oScreenRect As Rectangle = System.Windows.Forms.Screen.PrimaryScreen.Bounds
|
||||
Dim oLeft, oBottom, oTop, oRight As Integer
|
||||
|
||||
_Logger.Debug("Calculating Rectangle for Anchor {0}", Anchor.ToString)
|
||||
|
||||
@ -85,6 +85,7 @@
|
||||
<Compile Include="File.vb" />
|
||||
<Compile Include="Hotkey.vb" />
|
||||
<Compile Include="NativeMethods.vb" />
|
||||
<Compile Include="Screen.vb" />
|
||||
<Compile Include="Utils.vb" />
|
||||
<Compile Include="Window.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user