protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            if (!(PresentationSource.FromVisual(this) is HwndSource source))
            {
                throw new InvalidOperationException("HwndSource is missing.");
            }

            this._source = source;
            this._source.AddHook(this.WndProc);
            this._handle = source.Handle;

            this.SystemDpi  = DpiHelper.GetDpiForSystem();
            this.CurrentDpi = this.SystemDpi;
            this.UpdateDpiResources();

            var wndStyle = User32.GetWindowLong(this._handle);
            var wexStyle = User32.GetWindowLongEx(this._handle);

            User32.SetWindowLong(this._handle, wndStyle & ~WindowStyles.WS_SYSMENU);
            User32.SetWindowLongEx(this._handle, wexStyle | WindowExStyles.WS_EX_TOOLWINDOW);

            if (this.Owner is WindowWrapper wrapper)
            {
                base.Owner = wrapper.Window;
            }

            this._sourceInitialized = true;
        }