/// <summary> /// Private constructor. The public way to access this class is through the static Current property. /// </summary> private SystemParameters2() { // This window gets used for calculations about standard caption button locations // so it has WS_OVERLAPPEDWINDOW as a style to give it normal caption buttons. // This window may be shown during calculations of caption bar information, so create it at a location that's likely offscreen. _messageHwnd = new MessageWindow(0, WS.OVERLAPPEDWINDOW | WS.DISABLED, 0, new Rect(-16000, -16000, 100, 100), "", _WndProc); _messageHwnd.Dispatcher.ShutdownStarted += (sender, e) => Utility.SafeDispose(ref _messageHwnd); // Fixup the default values of the DPs. _InitializeIsGlassEnabled(); _InitializeGlassColor(); _InitializeCaptionHeight(); _InitializeWindowNonClientFrameThickness(); _InitializeWindowResizeBorderThickness(); _InitializeCaptionButtonLocation(); _InitializeSmallIconSize(); _InitializeHighContrast(); _InitializeThemeInfo(); // WindowCornerRadius isn't exposed by true system parameters, so it requires the theme to be initialized first. _InitializeWindowCornerRadius(); _UpdateTable = new Dictionary<WM, List<_SystemMetricUpdate>> { { WM.THEMECHANGED, new List<_SystemMetricUpdate> { _UpdateThemeInfo, _UpdateHighContrast, _UpdateWindowCornerRadius, _UpdateCaptionButtonLocation } }, { WM.SETTINGCHANGE, new List<_SystemMetricUpdate> { _UpdateCaptionHeight, _UpdateWindowResizeBorderThickness, _UpdateSmallIconSize, _UpdateHighContrast, _UpdateWindowNonClientFrameThickness, _UpdateCaptionButtonLocation } }, {WM.DWMNCRENDERINGCHANGED, new List<_SystemMetricUpdate> {_UpdateIsGlassEnabled}}, {WM.DWMCOMPOSITIONCHANGED, new List<_SystemMetricUpdate> {_UpdateIsGlassEnabled}}, {WM.DWMCOLORIZATIONCOLORCHANGED, new List<_SystemMetricUpdate> {_UpdateGlassColor}} }; }
private SystemParameters2() { EventHandler handler = null; this._messageHwnd = new Standard.MessageWindow(0, Standard.WS.BORDER | Standard.WS.DISABLED | Standard.WS.DLGFRAME | Standard.WS.GROUP | Standard.WS.MAXIMIZEBOX | Standard.WS.SIZEBOX | Standard.WS.SYSMENU, Standard.WS_EX.LEFT, new Rect(-16000.0, -16000.0, 100.0, 100.0), "", new Standard.WndProc(this._WndProc)); if (handler == null) { handler = (sender, e) => Standard.Utility.SafeDispose <Standard.MessageWindow>(ref this._messageHwnd); } this._messageHwnd.Dispatcher.ShutdownStarted += handler; this._InitializeIsGlassEnabled(); this._InitializeGlassColor(); this._InitializeCaptionHeight(); this._InitializeWindowNonClientFrameThickness(); this._InitializeWindowResizeBorderThickness(); this._InitializeCaptionButtonLocation(); this._InitializeSmallIconSize(); this._InitializeHighContrast(); this._InitializeThemeInfo(); this._InitializeWindowCornerRadius(); Dictionary <Standard.WM, List <_SystemMetricUpdate> > dictionary = new Dictionary <Standard.WM, List <_SystemMetricUpdate> >(); dictionary.Add(Standard.WM.THEMECHANGED, new List <_SystemMetricUpdate> { new _SystemMetricUpdate(this._UpdateThemeInfo), new _SystemMetricUpdate(this._UpdateHighContrast), new _SystemMetricUpdate(this._UpdateWindowCornerRadius), new _SystemMetricUpdate(this._UpdateCaptionButtonLocation) }); dictionary.Add(Standard.WM.WININICHANGE, new List <_SystemMetricUpdate> { new _SystemMetricUpdate(this._UpdateCaptionHeight), new _SystemMetricUpdate(this._UpdateWindowResizeBorderThickness), new _SystemMetricUpdate(this._UpdateSmallIconSize), new _SystemMetricUpdate(this._UpdateHighContrast), new _SystemMetricUpdate(this._UpdateWindowNonClientFrameThickness), new _SystemMetricUpdate(this._UpdateCaptionButtonLocation) }); dictionary.Add(Standard.WM.DWMNCRENDERINGCHANGED, new List <_SystemMetricUpdate> { new _SystemMetricUpdate(this._UpdateIsGlassEnabled) }); dictionary.Add(Standard.WM.DWMCOMPOSITIONCHANGED, new List <_SystemMetricUpdate> { new _SystemMetricUpdate(this._UpdateIsGlassEnabled) }); dictionary.Add(Standard.WM.DWMCOLORIZATIONCOLORCHANGED, new List <_SystemMetricUpdate> { new _SystemMetricUpdate(this._UpdateGlassColor) }); this._UpdateTable = dictionary; }
private void _Dispose(bool disposing, bool isHwndBeingDestroyed) { if (this._isDisposed) { return; } this._isDisposed = true; IntPtr hwnd = this.Handle; string className = this._className; if (isHwndBeingDestroyed) { base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback((object arg) => MessageWindow._DestroyWindow(IntPtr.Zero, className))); } else if (this.Handle != IntPtr.Zero) { if (base.CheckAccess()) { MessageWindow._DestroyWindow(hwnd, className); } else { base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback((object arg) => MessageWindow._DestroyWindow(hwnd, className))); } } MessageWindow.s_windowLookup.Remove(hwnd); this._className = null; this.Handle = IntPtr.Zero; }