| | |
| | | |
| | | public void RestoreTopLevelWindow(IntPtr hwnd) |
| | | { |
| | | RestoreTopLevelStyle(hwnd); |
| | | NativeMethods.SetParent(hwnd, IntPtr.Zero); |
| | | var error = NativeMethods.GetLastError(); |
| | | if (error != 0) |
| | |
| | | DiagnosticCodes.Win32InteropFailed, |
| | | "RestoreTopLevelWindow failed.", |
| | | new Dictionary<string, string> { ["hwnd"] = hwnd.ToString("X"), ["error"] = error.ToString() }); |
| | | } |
| | | |
| | | if (!NativeMethods.SetWindowPos( |
| | | hwnd, |
| | | IntPtr.Zero, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | NativeMethods.SwpNoMove | NativeMethods.SwpNoSize | NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpFrameChanged)) |
| | | { |
| | | RecordWin32Failure("RestoreTopLevelWindow.SetWindowPos", hwnd); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return new RectD(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); |
| | | } |
| | | |
| | | private static void RestoreTopLevelStyle(IntPtr hwnd) |
| | | { |
| | | var current = unchecked((uint)NativeMethods.GetWindowLongPtr(hwnd, NativeMethods.GwlStyle).ToInt64()); |
| | | var updated = (current | NativeMethods.WsPopup | NativeMethods.WsVisible) & ~NativeMethods.WsChild; |
| | | NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlStyle, new IntPtr(unchecked((int)updated))); |
| | | } |
| | | } |