internal ContainerControl FindContainerControlInternal() { if (this.Site != null) { IDesignerHost designerHost = (IDesignerHost)this.Site.GetService(typeof(IDesignerHost)); if (designerHost != null) { IComponent component = designerHost.RootComponent; if ((component != null) && (component is ContainerControl)) { return((ContainerControl)component); } } } ContainerControl containerControl = null; for (Control control = this; control != null; control = control.Parent) { ContainerControl control_as_ContainerContral = control as ContainerControl; if (control_as_ContainerContral != null) { containerControl = control_as_ContainerContral; } } if (containerControl == null) { containerControl = Control.FromHandle(UnsafeNativeMethods.GetParent(new HandleRef(this, base.Handle))) as ContainerControl; } if (ApplicationShim.IsParkingWindow(containerControl)) { containerControl = null; } this.SetActiveXHostState(ActiveXHelper.RecomputeContainingControl, containerControl == null); return(containerControl); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case NativeMethods.WM_LBUTTONDOWN: case NativeMethods.WM_RBUTTONDOWN: case NativeMethods.WM_MBUTTONDOWN: case NativeMethods.WM_MOUSEACTIVATE: if (!base.DesignMode) { this.Focus(); } this.DefWndProc(ref m); return; case NativeMethods.WM_LBUTTONUP: case NativeMethods.WM_LBUTTONDBLCLK: case NativeMethods.WM_RBUTTONUP: case NativeMethods.WM_RBUTTONDBLCLK: case NativeMethods.WM_MBUTTONUP: case NativeMethods.WM_MBUTTONDBLCLK: case NativeMethods.x2055: case NativeMethods.WM_CONTEXTMENU: case NativeMethods.WM_ERASEBKGND: case NativeMethods.WM_SYSCOLORCHANGE: case NativeMethods.WM_SETCURSOR: case NativeMethods.WM_DRAWITEM: this.DefWndProc(ref m); return; case NativeMethods.WM_COMMAND: if (!ControlShim.ReflectMessageInternal(m.LParam, ref m)) { this.DefWndProc(ref m); } return; case NativeMethods.WM_HELP: base.WndProc(ref m); this.DefWndProc(ref m); return; case NativeMethods.WM_DESTROY: break; case NativeMethods.WM_KILLFOCUS: this.hwndFocus = m.WParam; try { base.WndProc(ref m); return; } finally { this.hwndFocus = IntPtr.Zero; } default: if (m.Msg == ActiveXHelper.REGMSG_MSG) { m.Result = (IntPtr)0x7b; } else { base.WndProc(ref m); } return; } if ((this.activeXState >= ActiveXHelper.ActiveXState.InPlaceActive)) { IntPtr window = this.activeXOleInPlaceObject.GetWindow(); if (window != IntPtr.Zero) { ApplicationShim.ParkHandle(new HandleRef(this.activeXOleInPlaceObject, window)); } } if (base.RecreatingHandle) { this.activeXReloadingState = this.activeXState; } this.ChangeActiveXStateDownTo(ActiveXHelper.ActiveXState.Running); if (this.activeXWindow != null) { this.activeXWindow.ReleaseHandle(); } this.OnHandleDestroyed(EventArgs.Empty); }