Browse Source

Merge pull request #452 from KvanTTT/master

Fixed DPI scaling .dll not found. fixed #449
pull/453/head
Steven Kirk 11 years ago
parent
commit
7779a0b39b
  1. 5
      src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
  2. 7
      src/Windows/Perspex.Win32/Win32Platform.cs
  3. 17
      src/Windows/Perspex.Win32/WindowImpl.cs

5
src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs

@ -742,6 +742,9 @@ namespace Perspex.Win32.Interop
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GlobalFree(IntPtr hMem);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr LoadLibrary(string fileName);
[DllImport("comdlg32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetSaveFileNameW")]
public static extern bool GetSaveFileName(IntPtr lpofn);
@ -751,6 +754,8 @@ namespace Perspex.Win32.Interop
[DllImport("comdlg32.dll")]
public static extern int CommDlgExtendedError();
public static bool ShCoreAvailable => LoadLibrary("shcore.dll") != IntPtr.Zero;
[DllImport("shcore.dll")]
public static extern void SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value);

7
src/Windows/Perspex.Win32/Win32Platform.cs

@ -28,8 +28,11 @@ namespace Perspex.Win32
public Win32Platform()
{
// Declare that this process is aware of per monitor DPI
UnmanagedMethods.SetProcessDpiAwareness(UnmanagedMethods.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE);
// Declare that this process is aware of per monitor DPI
if (UnmanagedMethods.ShCoreAvailable)
{
UnmanagedMethods.SetProcessDpiAwareness(UnmanagedMethods.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE);
}
CreateMessageWindow();
}

17
src/Windows/Perspex.Win32/WindowImpl.cs

@ -609,14 +609,17 @@ namespace Perspex.Win32
_hwnd,
UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST);
uint dpix, dpiy;
if (UnmanagedMethods.GetDpiForMonitor(
monitor,
UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI,
out dpix,
out dpiy) == 0)
if (UnmanagedMethods.ShCoreAvailable)
{
_scaling = dpix / 96.0;
uint dpix, dpiy;
if (UnmanagedMethods.GetDpiForMonitor(
monitor,
UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI,
out dpix,
out dpiy) == 0)
{
_scaling = dpix / 96.0;
}
}
}

Loading…
Cancel
Save