/// <summary> /// Creates and initializes the native ExplorerBrowser control /// </summary> protected override void OnCreateControl() { base.OnCreateControl(); if (this.DesignMode == false) { explorerBrowserControl = new ExplorerBrowserClass(); // hooks up IExplorerPaneVisibility and ICommDlgBrowser event notifications ExplorerBrowserNativeMethods.IUnknown_SetSite(explorerBrowserControl, this); // hooks up IExplorerBrowserEvents event notification explorerBrowserControl.Advise( Marshal.GetComInterfaceForObject(this, typeof(IExplorerBrowserEvents)), out eventsCookie); // sets up ExplorerBrowser view connection point events viewEvents = new ExplorerBrowserViewEvents(this); NativeRect rect = new NativeRect(); rect.Top = ClientRectangle.Top; rect.Left = ClientRectangle.Left; rect.Right = ClientRectangle.Right; rect.Bottom = ClientRectangle.Bottom; explorerBrowserControl.Initialize(this.Handle, ref rect, null); // Force an initial show frames so that IExplorerPaneVisibility works the first time it is set. // This also enables the control panel to be browsed to. If it is not set, then navigating to // the control panel succeeds, but no items are visible in the view. explorerBrowserControl.SetOptions(ExplorerBrowserOptions.ShowFrames); // ExplorerBrowserOptions.NoBorder does not work, so we do it manually... RemoveWindowBorder(); explorerBrowserControl.SetPropertyBag(propertyBagName); if (antecreationNavigationTarget != null) { BeginInvoke(new MethodInvoker( delegate { Navigate(antecreationNavigationTarget); antecreationNavigationTarget = null; })); } } Application.AddMessageFilter(this); }
/// <summary> /// Creates and initializes the native ExplorerBrowser control /// </summary> protected override void OnCreateControl() { base.OnCreateControl(); HRESULT hr = HRESULT.S_OK; if (this.DesignMode == false) { explorerBrowserControl = new ExplorerBrowserClass(); // hooks up IExplorerPaneVisibility and ICommDlgBrowser event notifications hr = ExplorerBrowserNativeMethods.IUnknown_SetSite(explorerBrowserControl, this); // hooks up IExplorerBrowserEvents event notification hr = explorerBrowserControl.Advise( Marshal.GetComInterfaceForObject(this, typeof(IExplorerBrowserEvents)), out eventsCookie); // sets up ExplorerBrowser view connection point events viewEvents = new ExplorerBrowserViewEvents(this); CoreNativeMethods.RECT rect = new CoreNativeMethods.RECT(); rect.top = ClientRectangle.Top; rect.left = ClientRectangle.Left; rect.right = ClientRectangle.Right; rect.bottom = ClientRectangle.Bottom; explorerBrowserControl.Initialize(this.Handle, ref rect, null); // Force an initial show frames so that IExplorerPaneVisibility works the first time it is set. // This also enables the control panel to be browsed to. If it is not set, then navigating to // the control panel succeeds, but no items are visible in the view. explorerBrowserControl.SetOptions(EXPLORER_BROWSER_OPTIONS.EBO_SHOWFRAMES); explorerBrowserControl.SetPropertyBag(propertyBagName); if (antecreationNavigationTarget != null) { BeginInvoke(new MethodInvoker( delegate { Navigate(antecreationNavigationTarget); antecreationNavigationTarget = null; })); } } Application.AddMessageFilter(this); }
private void Create() { this.ExplorerBrowserNative = new ExplorerBrowserNative(); ShellLightwaightNativeMethods.IUnknown_SetSite(this.ExplorerBrowserNative, this); this.ExplorerBrowserNative.Advise( Marshal.GetComInterfaceForObject(this, typeof(IExplorerBrowserEvents)), out this.eventCookie); this.viewEvents = new ExplorerBrowserViewEvents(this); var rect = RECT.Create(0, 0, this.ActualWidth, this.ActualHeight); this.ExplorerBrowserNative.Initialize(this.hwndSource.Handle, ref rect, null); this.ExplorerBrowserNative.SetOptions(EXPLORER_BROWSER_OPTIONS.EBO_SHOWFRAMES); this.ExplorerBrowserNative.SetPropertyBag(this.PropertyBagName); }