Ejemplo n.º 1
0
		/// <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);

				explorerBrowserControl.SetPropertyBag(propertyBagName);

				if (antecreationNavigationTarget != null) {
					BeginInvoke(new MethodInvoker(
					delegate {
						Navigate(antecreationNavigationTarget);
						antecreationNavigationTarget = null;
					}));
				}
			}

			Application.AddMessageFilter(this);
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Creates and initializes the native ExplorerBrowser control
        /// </summary>
        protected override void OnCreateControl()
        {
            base.OnCreateControl();

            if (this.DesignMode == false)
            {
                explorerBrowserControl = new ExplorerBrowserClass();

                this.BorderStyle = System.Windows.Forms.BorderStyle.None;
                
                // 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);
                if (IsOldSysListView)
                {
                    WindowsAPI.IFolderViewOptions fvo = (WindowsAPI.IFolderViewOptions)explorerBrowserControl;
                    fvo.SetFolderViewOptions(WindowsAPI.FOLDERVIEWOPTIONS.VISTALAYOUT, WindowsAPI.FOLDERVIEWOPTIONS.VISTALAYOUT);
                }
                
                
                NativeRect rect = new NativeRect();
                rect.Top = ClientRectangle.Top - 1;
                rect.Left = ClientRectangle.Left - 1;
                rect.Right = ClientRectangle.Right + 1;
                rect.Bottom = ClientRectangle.Bottom  + 1;

                

                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);

                explorerBrowserControl.SetPropertyBag(propertyBagName);


                if (antecreationNavigationTarget != null)
                {
                    //BeginInvoke(new MethodInvoker(
                    //delegate
                    //{
                        Navigate(antecreationNavigationTarget);
                        antecreationNavigationTarget = null;
                    //}));
                }
            }

                Application.AddMessageFilter(this);
        }