public void Show(IWin32Window owner) { if (owner == this) { throw new InvalidOperationException(SR.GetString("OwnsSelfOrOwner", new object[] { "Show" })); } if (base.Visible) { throw new InvalidOperationException(SR.GetString("ShowDialogOnVisible", new object[] { "Show" })); } if (!base.Enabled) { throw new InvalidOperationException(SR.GetString("ShowDialogOnDisabled", new object[] { "Show" })); } if (!this.TopLevel) { throw new InvalidOperationException(SR.GetString("ShowDialogOnNonTopLevel", new object[] { "Show" })); } if (!SystemInformation.UserInteractive) { throw new InvalidOperationException(SR.GetString("CantShowModalOnNonInteractive")); } if (((owner != null) && ((((int) UnsafeNativeMethods.GetWindowLong(new HandleRef(owner, Control.GetSafeHandle(owner)), -20)) & 8) == 0)) && (owner is Control)) { owner = ((Control) owner).TopLevelControlInternal; } IntPtr activeWindow = UnsafeNativeMethods.GetActiveWindow(); IntPtr handle = (owner == null) ? activeWindow : Control.GetSafeHandle(owner); base.Properties.SetObject(PropDialogOwner, owner); Form ownerInternal = this.OwnerInternal; if ((owner is Form) && (owner != ownerInternal)) { this.Owner = (Form) owner; } if ((handle != IntPtr.Zero) && (handle != base.Handle)) { if (UnsafeNativeMethods.GetWindowLong(new HandleRef(owner, handle), -8) == base.Handle) { throw new ArgumentException(SR.GetString("OwnsSelfOrOwner", new object[] { "show" }), "owner"); } UnsafeNativeMethods.GetWindowLong(new HandleRef(this, base.Handle), -8); UnsafeNativeMethods.SetWindowLong(new HandleRef(this, base.Handle), -8, new HandleRef(owner, handle)); } base.Visible = true; }