public void OnWndProc(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam,
                              bool restorePlacement, bool activate)
        {
            if (msg != SingleInstanceMessage)
            {
                return;
            }

            if (restorePlacement)
            {
                WindowPlacement placement = WindowPlacement.GetPlacement(hwnd, false);

                if (placement.IsValid && placement.IsMinimized)
                {
                    placement.ShowCmd = WindowNative.SwShowNormal;

                    placement.SetPlacement(hwnd);
                }
            }

            if (!activate)
            {
                return;
            }

            WindowNative.SetForegroundWindow(hwnd);
            WindowUtils.ActivateWindow(WindowUtils.GetModalWindow(hwnd));
        }
        public void OnWndProc(System.Windows.Window window, IntPtr hwnd, uint msg,
                              IntPtr wParam, IntPtr lParam, bool restorePlacement, bool activate)
        {
            if (!(window is INativeRestorableWindow restorableWindow))
            {
                OnWndProc(hwnd, msg, wParam, lParam, restorePlacement, activate);

                return;
            }

            if (msg != SingleInstanceMessage)
            {
                return;
            }

            if (restorePlacement)
            {
                WindowPlacement placement = WindowPlacement.GetPlacement(hwnd, false);

                if (placement.IsValid && placement.IsMinimized)
                {
                    placement.Flags |= WindowNative.WpfAsyncWindowPlacement;

                    placement.ShowCmd = restorableWindow.DuringRestoreToMaximized
                        ? WindowNative.SwShowMaximized
                        : WindowNative.SwShowNormal;

                    placement.SetPlacement(hwnd);
                }
            }

            if (!activate)
            {
                return;
            }

            WindowNative.SetForegroundWindow(hwnd);
            WindowUtils.ActivateWindow(WindowUtils.GetModalWindow(hwnd));
        }