static public void SetWindowBounds(IntPtr handle, WindowRect rect) { if (!MoveWindow(handle, rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y2 - rect.Y1, true)) { throw new InvalidOperationException(); } }
void ClingToMaster(uint msg) { if (Interop.IsWindow(masterHandle)) { try { switch (msg) { case 0x07: this.Topmost = true; this.Topmost = false; Interop.SetForegroundWindow(masterHandle); break; case 0x08: break; default: if (Interop.IsIconic(masterHandle)) { this.WindowState = WindowState.Minimized; } else { this.WindowState = WindowState.Normal; WindowRect r = Interop.GetWindowBounds(masterHandle); Interop.SetWindowBounds(thisHandle, new WindowRect(r.X2, r.Y1, r.X2 + (int)this.Width, r.Y2)); this.Opacity = 1.0f; } break; } } catch { Dispatcher.InvokeShutdown(); } } }
public static void SetWindowBounds(IntPtr handle, WindowRect rect) { if (!MoveWindow(handle, rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y2 - rect.Y1, true)) throw new InvalidOperationException(); }
static extern bool GetWindowRect(IntPtr hWnd, out WindowRect lpRect);