protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) { ISite site = (this.ParentInternal == null) ? null : this.ParentInternal.Site; if (base.IsHandleCreated && ((site == null) || !site.DesignMode)) { Rectangle bounds = base.Bounds; base.SetBoundsCore(x, y, width, height, specified); Rectangle rectangle2 = base.Bounds; int num = bounds.Height - rectangle2.Height; if (num != 0) { System.Windows.Forms.NativeMethods.WINDOWPLACEMENT placement = new System.Windows.Forms.NativeMethods.WINDOWPLACEMENT { length = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.WINDOWPLACEMENT)) }; for (int i = 0; i < base.Controls.Count; i++) { Control control = base.Controls[i]; if ((control != null) && (control is Form)) { Form wrapper = (Form)control; if (wrapper.CanRecreateHandle() && (wrapper.WindowState == FormWindowState.Minimized)) { System.Windows.Forms.UnsafeNativeMethods.GetWindowPlacement(new HandleRef(wrapper, wrapper.Handle), ref placement); placement.ptMinPosition_y -= num; if (placement.ptMinPosition_y == -1) { if (num < 0) { placement.ptMinPosition_y = 0; } else { placement.ptMinPosition_y = -2; } } placement.flags = 1; System.Windows.Forms.UnsafeNativeMethods.SetWindowPlacement(new HandleRef(wrapper, wrapper.Handle), ref placement); placement.flags = 0; } } } } } else { base.SetBoundsCore(x, y, width, height, specified); } }
private void UpdateWindowState() { if (base.IsHandleCreated) { FormWindowState windowState = this.WindowState; System.Windows.Forms.NativeMethods.WINDOWPLACEMENT placement = new System.Windows.Forms.NativeMethods.WINDOWPLACEMENT { length = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.WINDOWPLACEMENT)) }; System.Windows.Forms.UnsafeNativeMethods.GetWindowPlacement(new HandleRef(this, base.Handle), ref placement); switch (placement.showCmd) { case 1: case 4: case 5: case 8: case 9: if (this.formState[FormStateWindowState] != 0) { this.formState[FormStateWindowState] = 0; } break; case 2: case 6: case 7: if (this.formState[FormStateMdiChildMax] == 0) { this.formState[FormStateWindowState] = 1; } break; case 3: if (this.formState[FormStateMdiChildMax] == 0) { this.formState[FormStateWindowState] = 2; } break; } if ((windowState == FormWindowState.Normal) && (this.WindowState != FormWindowState.Normal)) { if (this.WindowState == FormWindowState.Minimized) { this.SuspendLayoutForMinimize(); } this.restoredWindowBounds.Size = this.ClientSize; this.formStateEx[FormStateExWindowBoundsWidthIsClientSize] = 1; this.formStateEx[FormStateExWindowBoundsHeightIsClientSize] = 1; this.restoredWindowBoundsSpecified = BoundsSpecified.Size; this.restoredWindowBounds.Location = this.Location; this.restoredWindowBoundsSpecified |= BoundsSpecified.Location; this.restoreBounds.Size = this.Size; this.restoreBounds.Location = this.Location; } if ((windowState == FormWindowState.Minimized) && (this.WindowState != FormWindowState.Minimized)) { this.ResumeLayoutFromMinimize(); } switch (this.WindowState) { case FormWindowState.Normal: base.SetState(0x10000, false); break; case FormWindowState.Minimized: case FormWindowState.Maximized: base.SetState(0x10000, true); break; } if (windowState != this.WindowState) { this.AdjustSystemMenu(); } } }
internal override void RecreateHandleCore() { System.Windows.Forms.NativeMethods.WINDOWPLACEMENT placement = new System.Windows.Forms.NativeMethods.WINDOWPLACEMENT(); FormStartPosition manual = FormStartPosition.Manual; if (!this.IsMdiChild && ((this.WindowState == FormWindowState.Minimized) || (this.WindowState == FormWindowState.Maximized))) { placement.length = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.WINDOWPLACEMENT)); System.Windows.Forms.UnsafeNativeMethods.GetWindowPlacement(new HandleRef(this, base.Handle), ref placement); } if (this.StartPosition != FormStartPosition.Manual) { manual = this.StartPosition; this.StartPosition = FormStartPosition.Manual; } EnumThreadWindowsCallback callback = null; System.Windows.Forms.SafeNativeMethods.EnumThreadWindowsCallback callback2 = null; if (base.IsHandleCreated) { callback = new EnumThreadWindowsCallback(); if (callback != null) { callback2 = new System.Windows.Forms.SafeNativeMethods.EnumThreadWindowsCallback(callback.Callback); System.Windows.Forms.UnsafeNativeMethods.EnumThreadWindows(System.Windows.Forms.SafeNativeMethods.GetCurrentThreadId(), new System.Windows.Forms.NativeMethods.EnumThreadWindowsCallback(callback2.Invoke), new HandleRef(this, base.Handle)); callback.ResetOwners(); } } base.RecreateHandleCore(); if (callback != null) { callback.SetOwners(new HandleRef(this, base.Handle)); } if (manual != FormStartPosition.Manual) { this.StartPosition = manual; } if (placement.length > 0) { System.Windows.Forms.UnsafeNativeMethods.SetWindowPlacement(new HandleRef(this, base.Handle), ref placement); } if (callback2 != null) { GC.KeepAlive(callback2); } }
protected override void WndProc(ref Message m) { int msg = m.Msg; switch (msg) { case 0x4e: case 0x204e: { System.Windows.Forms.NativeMethods.NMHDR lParam = (System.Windows.Forms.NativeMethods.NMHDR) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMHDR)); switch (lParam.code) { case -521: { System.Windows.Forms.NativeMethods.WINDOWPLACEMENT placement = new System.Windows.Forms.NativeMethods.WINDOWPLACEMENT(); System.Windows.Forms.UnsafeNativeMethods.GetWindowPlacement(new HandleRef(null, lParam.hwndFrom), ref placement); if (((placement.rcNormalPosition_left != 0) || (placement.rcNormalPosition_top != 0)) || (this.hotItem == -1)) { goto Label_02BE; } int num = 0; for (int i = 0; i <= this.hotItem; i++) { num += this.buttonsCollection[i].GetButtonWidth(); } int num3 = placement.rcNormalPosition_right - placement.rcNormalPosition_left; int num4 = placement.rcNormalPosition_bottom - placement.rcNormalPosition_top; int x = (base.Location.X + num) + 1; int y = base.Location.Y + (this.ButtonSize.Height / 2); System.Windows.Forms.NativeMethods.POINT pt = new System.Windows.Forms.NativeMethods.POINT(x, y); System.Windows.Forms.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, base.Handle), pt); if (pt.y < SystemInformation.WorkingArea.Y) { pt.y += (this.ButtonSize.Height / 2) + 1; } if ((pt.y + num4) > SystemInformation.WorkingArea.Height) { pt.y -= ((this.ButtonSize.Height / 2) + num4) + 1; } if ((pt.x + num3) > SystemInformation.WorkingArea.Right) { pt.x -= (this.ButtonSize.Width + num3) + 2; } System.Windows.Forms.SafeNativeMethods.SetWindowPos(new HandleRef(null, lParam.hwndFrom), System.Windows.Forms.NativeMethods.NullHandleRef, pt.x, pt.y, 0, 0, 0x15); m.Result = (IntPtr) 1; return; } case -520: this.WmNotifyNeedTextA(ref m); m.Result = (IntPtr) 1; return; case -530: if (Marshal.SystemDefaultCharSize != 2) { break; } this.WmNotifyNeedText(ref m); m.Result = (IntPtr) 1; return; case -706: m.Result = (IntPtr) 1; goto Label_02BE; case -713: this.WmNotifyHotItemChange(ref m); goto Label_02BE; case -710: this.WmNotifyDropDown(ref m); goto Label_02BE; } break; } default: if (msg == 0x2111) { this.WmReflectCommand(ref m); } break; } Label_02BE: base.WndProc(ref m); }
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) { ISite site = (this.ParentInternal == null) ? null : this.ParentInternal.Site; if (base.IsHandleCreated && ((site == null) || !site.DesignMode)) { Rectangle bounds = base.Bounds; base.SetBoundsCore(x, y, width, height, specified); Rectangle rectangle2 = base.Bounds; int num = bounds.Height - rectangle2.Height; if (num != 0) { System.Windows.Forms.NativeMethods.WINDOWPLACEMENT placement = new System.Windows.Forms.NativeMethods.WINDOWPLACEMENT { length = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.WINDOWPLACEMENT)) }; for (int i = 0; i < base.Controls.Count; i++) { Control control = base.Controls[i]; if ((control != null) && (control is Form)) { Form wrapper = (Form) control; if (wrapper.CanRecreateHandle() && (wrapper.WindowState == FormWindowState.Minimized)) { System.Windows.Forms.UnsafeNativeMethods.GetWindowPlacement(new HandleRef(wrapper, wrapper.Handle), ref placement); placement.ptMinPosition_y -= num; if (placement.ptMinPosition_y == -1) { if (num < 0) { placement.ptMinPosition_y = 0; } else { placement.ptMinPosition_y = -2; } } placement.flags = 1; System.Windows.Forms.UnsafeNativeMethods.SetWindowPlacement(new HandleRef(wrapper, wrapper.Handle), ref placement); placement.flags = 0; } } } } } else { base.SetBoundsCore(x, y, width, height, specified); } }