/// <devdoc> /// Cleans up form state after a control has been removed. /// Package scope for Control /// </devdoc> /// <internalonly/> internal virtual void AfterControlRemoved(Control control) { if (control == activeControl || control.Contains(activeControl)) { // REGISB: this branch never seems to be reached. // leaving it intact to be on the safe side bool selected = SelectNextControl(control, true, true, true, true); if (selected) { FocusActiveControlInternal(); } } else if (activeControl == null && ParentInternal != null) { // The last control of an active container was removed. Focus needs to be given to the next // control in the Form. ContainerControl cc = ParentInternal.GetContainerControlInternal() as ContainerControl; if (cc != null && cc.ActiveControl == this) { Form f = FindFormInternal(); if (f != null) { f.SelectNextControl(this, true, true, true, true); } } } if (control == unvalidatedControl || control.Contains(unvalidatedControl)) { unvalidatedControl = null; } }
public void Invalidate() { if (this.ParentInternal != null) { ParentInternal.Invalidate(this.Bounds, true); } }
protected override void WndProc(ref Message m) { switch (m.Msg) { case NativeMethods.WM_NCHITTEST: // label returns HT_TRANSPARENT for everything, so all messages get // routed to the parent. Change this so we can tell what's going on. // if (ParentInternal != null) { Point pt = ParentInternal.PointToClientInternal(new Point((int)m.LParam)); m.Result = (IntPtr)((Bounds.Contains(pt) ? NativeMethods.HTCLIENT : NativeMethods.HTNOWHERE)); } else { base.WndProc(ref m); } break; // NT4 and Windows 95 STATIC controls don't properly handle WM_PRINTCLIENT case NativeMethods.WM_PRINTCLIENT: SendMessage(NativeMethods.WM_PAINT, m.WParam, IntPtr.Zero); break; default: base.WndProc(ref m); break; } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { // all the grip painting should be on the ToolStrip itself. if (ParentInternal != null) { ParentInternal.OnPaintGrip(e); } }
protected override void OnPaint(PaintEventArgs e) { // all the grip painting should be on the ToolStrip itself. if (ParentInternal is not null) { ParentInternal.OnPaintGrip(e); } }
/// <include file='doc\ToolStripComboButton.uex' path='docs/doc[@for="ToolStripSplitButton.OnMouseUp"]/*' /> /// <devdoc> /// Summary of OnMouseUp. /// </devdoc> protected override void OnMouseUp(MouseEventArgs e) { if (!Enabled) { return; } SplitButtonButton.Push(false); if (DropDownButtonBounds.Contains(e.Location)) { if (e.Button == MouseButtons.Left) { if (DropDown.Visible) { Debug.Assert(ParentInternal != null, "Parent is null here, not going to get accurate ID"); byte closeMouseId = (ParentInternal == null) ? (byte)0: ParentInternal.GetMouseId(); if (closeMouseId != openMouseId) { openMouseId = 0; // reset the mouse id, we should never get this value from toolstrip. ToolStripManager.ModalMenuFilter.CloseActiveDropDown(DropDown, ToolStripDropDownCloseReason.AppClicked); Select(); } } } } Point clickPoint = new Point(e.X, e.Y); if ((e.Button == MouseButtons.Left) && this.SplitButtonButton.Bounds.Contains(clickPoint)) { bool shouldFireDoubleClick = false; if (DoubleClickEnabled) { long newTime = DateTime.Now.Ticks; long deltaTicks = newTime - lastClickTime; lastClickTime = newTime; // use >= for cases where the succession of click events is so fast it's not picked up by // DateTime resolution. Debug.Assert(deltaTicks >= 0, "why are deltaticks less than zero? thats some mighty fast clicking"); // if we've seen a mouse up less than the double click time ago, we should fire. if (deltaTicks >= 0 && deltaTicks < DoubleClickTicks) { shouldFireDoubleClick = true; } } if (shouldFireDoubleClick) { OnButtonDoubleClick(new System.EventArgs()); // VSWhidbey 486983: if we actually fired DoubleClick - reset the lastClickTime. lastClickTime = 0; } else { OnButtonClick(new System.EventArgs()); } } }
/// <devdoc> /// WM_SETFOCUS handler /// </devdoc> /// <internalonly/> private void WmSetFocus(ref Message m) { if (!HostedInWin32DialogManager) { if (ActiveControl != null) { ImeSetFocus(); // REGISB: Do not raise GotFocus event since the focus // is given to the visible ActiveControl if (!ActiveControl.Visible) { OnGotFocus(EventArgs.Empty); } FocusActiveControlInternal(); } else { if (ParentInternal != null) { IContainerControl c = ParentInternal.GetContainerControlInternal(); if (c != null) { bool succeeded = false; ContainerControl knowncontainer = c as ContainerControl; if (knowncontainer != null) { succeeded = knowncontainer.ActivateControlInternal(this); } else { // SECREVIEW : Taking focus and activating a control is response // : to a user gesture (WM_SETFOCUS) is OK. // IntSecurity.ModifyFocus.Assert(); try { succeeded = c.ActivateControl(this); } finally { CodeAccessPermission.RevertAssert(); } } if (!succeeded) { return; } } } base.WndProc(ref m); } } else { base.WndProc(ref m); } }
protected override void OnMouseUp(MouseEventArgs e) { if (!Enabled) { return; } if (this.m_mouseDown) { this.m_mouseDown = false; if (this.m_scrollTabType == ScrollTabType.ScrollTabLeft) { ScrollDirection direction = ScrollDirection.Left; if (ParentInternal.RightToLeft == RightToLeft.Yes) { direction = ScrollDirection.Right; } if (this.ScrollTab != null) { this.ScrollTab(direction); } } else if (this.m_scrollTabType == ScrollTabType.ScrollTabRight) { ScrollDirection direction = ScrollDirection.Right; if (ParentInternal.RightToLeft == RightToLeft.Yes) { direction = ScrollDirection.Left; } if (this.ScrollTab != null) { this.ScrollTab(direction); } } else { if (this.m_isDroppedDown) { this.m_isDroppedDown = false; } else { Point dropPoint = default(Point); if (ParentInternal.RightToLeft == RightToLeft.Yes) { dropPoint = ParentInternal.PointToScreen(new Point(Right - this.m_mdiMenu.Width, ParentInternal.Height - 5)); } else { dropPoint = ParentInternal.PointToScreen(new Point(Left, ParentInternal.Height - 5)); } this.m_mdiMenu.Show(dropPoint, ToolStripDropDownDirection.Default); } } } }
internal virtual void Unselect() { if (stateSelected == false) { return; } stateSelected = false; if (Available && ParentInternal != null) { ParentInternal.NotifySelectionChange(this); } }
protected override void OnMouseUp(MouseEventArgs e) { if ((Control.ModifierKeys != Keys.Alt) && (e.Button == MouseButtons.Left)) { Debug.Assert(ParentInternal != null, "Parent is null here, not going to get accurate ID"); byte closeMouseId = (ParentInternal == null) ? (byte)0: ParentInternal.GetMouseId(); if (closeMouseId != openMouseId) { openMouseId = 0; // reset the mouse id, we should never get this value from toolstrip. ToolStripManager.ModalMenuFilter.CloseActiveDropDown(DropDown, ToolStripDropDownCloseReason.AppClicked); Select(); } } base.OnMouseUp(e); }
protected internal override bool ProcessMnemonic(char charCode) { // checking IsMnemonic is not necessary - toolstrip does this for us. if (ParentInternal != null) { if (!CanSelect) { ParentInternal.SetFocusUnsafe(); ParentInternal.SelectNextToolStripItem(this, /*forward=*/ true); } else { FireEvent(ToolStripItemEventType.Click); } return(true); } return(false); }
/// <include file='doc\ContainerControl.uex' path='docs/doc[@for="ContainerControl.Select"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected override void Select(bool directed, bool forward) { bool correctParentActiveControl = true; if (ParentInternal != null) { IContainerControl c = ParentInternal.GetContainerControlInternal(); if (c != null) { c.ActiveControl = this; correctParentActiveControl = (c.ActiveControl == this); } } if (directed && correctParentActiveControl) { SelectNextControl(null, forward, true, true, false); } }
/// <include file='doc\ToolStripComboButton.uex' path='docs/doc[@for="ToolStripSplitButton.OnMouseDown"]/*' /> /// <devdoc> /// Summary of OnMouseDown. /// </devdoc> protected override void OnMouseDown(MouseEventArgs e) { if (DropDownButtonBounds.Contains(e.Location)) { if (e.Button == MouseButtons.Left) { if (!DropDown.Visible) { Debug.Assert(ParentInternal != null, "Parent is null here, not going to get accurate ID"); openMouseId = (ParentInternal == null) ? (byte)0: ParentInternal.GetMouseId(); this.ShowDropDown(/*mousePress = */ true); } } } else { SplitButtonButton.Push(true); } }
/// <include file='doc\ToolStripPopupButton.uex' path='docs/doc[@for="ToolStripDropDownButton.OnMouseDown"]/*' /> /// <devdoc> /// Overriden to invoke displaying the popup. /// </devdoc> protected override void OnMouseDown(MouseEventArgs e) { if ((Control.ModifierKeys != Keys.Alt) && (e.Button == MouseButtons.Left)) { if (DropDown.Visible) { ToolStripManager.ModalMenuFilter.CloseActiveDropDown(DropDown, ToolStripDropDownCloseReason.AppClicked); } else { // opening should happen on mouse down. Debug.Assert(ParentInternal != null, "Parent is null here, not going to get accurate ID"); openMouseId = (ParentInternal == null) ? (byte)0: ParentInternal.GetMouseId(); this.ShowDropDown(/*mousePush =*/ true); } } base.OnMouseDown(e); }
protected override void OnMouseDown(MouseEventArgs e) { ParentInternal.OnMdiNewTabClick(); }