/// <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 OnGotFocus(EventArgs e) { if (ActiveControl != null) { if (!ActiveControl.Visible) { base.OnGotFocus(EventArgs.Empty); } SetFocus(activeControl); return; } if (Parent != null) { IContainerControl container = Parent.GetContainerControl(); if (container != null) { if (!container.ActivateControl(this)) { return; } } } base.OnGotFocus(e); }