private UpdateMonitorDpi ( double dpiX, double dpiY ) : System.Windows.Vector | ||
dpiX | double | |
dpiY | double | |
리턴 | System.Windows.Vector |
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg != NativeMethods.WM_DPICHANGED || _source?.CompositionTarget == null) { return(IntPtr.Zero); } // Marshal the value in the lParam into a Rect. var newDisplayRect = (Win32Rect)Marshal.PtrToStructure(lParam, typeof(Win32Rect)); // Set the Window’s position & size. var matrix = _source.CompositionTarget.TransformFromDevice; var ul = matrix.Transform(new Vector(newDisplayRect.Left, newDisplayRect.Top)); var hw = matrix.Transform(new Vector(newDisplayRect.Right - newDisplayRect.Left, newDisplayRect.Bottom - newDisplayRect.Top)); Left = ul.X; Top = ul.Y; UpdateWindowSize(hw.X, hw.Y); // Remember the current DPI settings. var oldDpiX = DpiInformation.MonitorDpiX; var oldDpiY = DpiInformation.MonitorDpiY; // Get the new DPI settings from wParam var dpiX = (double)(wParam.ToInt32() >> 16); var dpiY = (double)(wParam.ToInt32() & 0x0000FFFF); if (oldDpiX != dpiX || oldDpiY != dpiY) { DpiInformation.UpdateMonitorDpi(dpiX, dpiY); // update layout scale UpdateLayoutTransform(); // raise DpiChanged event OnDpiChanged(EventArgs.Empty); } handled = true; return(IntPtr.Zero); }
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch ((WindowMessage)msg) { case WindowMessage.SystemCommand: var command = (WindowSystemCommand)(wParam.ToInt32() & 0xfff0); if (command == WindowSystemCommand.Move && PreferredFullscreenMode) { Logging.Debug("Cancel movement in preferred fullscreen mode"); handled = true; } break; case WindowMessage.EnterSizeMove: Logging.Debug("Movement started"); OnDragged(true); break; case WindowMessage.ExitSizeMove: Logging.Debug("Movement ended"); OnDragged(false); break; case WindowMessage.DpiChanged: if (!IsAnyLogicDisabled()) { var dpiX = (double)(wParam.ToInt32() >> 16); var dpiY = (double)(wParam.ToInt32() & 0x0000FFFF); Logging.Debug($"DPI changed: {dpiX}, {dpiY}"); if (_dpi != null && _dpi.UpdateMonitorDpi(dpiX, dpiY)) { UpdateScaleRelatedParams(); } } handled = true; break; } return(IntPtr.Zero); }