internal static bool GetClientSize(IntPtr hwnd, out System.Drawing.Size size)
 {
     NativeRect rect = new NativeRect();
     if (!GetClientRect(hwnd, ref rect))
     {
         size = new System.Drawing.Size(-1, -1);
         return false;
     }
     size = new System.Drawing.Size(rect.Right, rect.Bottom);
     return true;
 }
Ejemplo n.º 2
0
        internal static System.Drawing.Size GetNonClientArea(IntPtr hwnd)
        {
            var c = new NativePoint();

            TabbedThumbnailNativeMethods.ClientToScreen(hwnd, ref c);

            var r = new NativeRect();

            TabbedThumbnailNativeMethods.GetWindowRect(hwnd, ref r);

            return new System.Drawing.Size(c.X - r.Left, c.Y - r.Top);
        }
        /// <summary>
        /// Selects a portion of a window's client area to display as that window's thumbnail in the taskbar.
        /// </summary>
        /// <param name="windowHandle">The handle to a window represented in the taskbar. This has to be a top-level window.</param>
        /// <param name="clippingRectangle">Rectangle structure that specifies a selection within the window's client area,
        /// relative to the upper-left corner of that client area.
        /// <para>If this parameter is null, the clipping area will be cleared and the default display of the thumbnail will be used instead.</para></param>
        public void SetThumbnailClip(IntPtr windowHandle, Rectangle? clippingRectangle)
        {
            if (clippingRectangle == null)
            {
                ClearThumbnailClip(windowHandle);
                return;
            }

            NativeRect rect = new NativeRect();
            rect.Left = clippingRectangle.Value.Left;
            rect.Top = clippingRectangle.Value.Top;
            rect.Right = clippingRectangle.Value.Right;
            rect.Bottom = clippingRectangle.Value.Bottom;

            IntPtr rectPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(rect));
            try
            {
                Marshal.StructureToPtr(rect, rectPtr, true);
                TaskbarList.Instance.SetThumbnailClip(windowHandle, rectPtr);
            }
            finally
            {
                Marshal.FreeCoTaskMem(rectPtr);
            }
        }
 /// <summary>
 /// Called to update the bounds and position of the preview control
 /// </summary>
 /// <param name="bounds"></param>
 protected abstract void UpdateBounds(NativeRect bounds);
 void IPreviewHandler.SetWindow(IntPtr hwnd, ref NativeRect rect)
 {
     _parentHwnd = hwnd;
     UpdateBounds(rect);
     SetParentHandle(_parentHwnd);
 }
 void IPreviewHandler.SetRect(ref NativeRect rect)
 {
     UpdateBounds(rect);
 }
        /// <summary>
        /// Sizes the native control to match the WinForms control wrapper.
        /// </summary>
        /// <param name="e">Contains information about the size changed event.</param>
        protected override void OnSizeChanged(EventArgs e)
        {
            if (explorerBrowserControl != null)
            {
                NativeRect rect = new NativeRect();
                rect.Top = ClientRectangle.Top;
                rect.Left = ClientRectangle.Left;
                rect.Right = ClientRectangle.Right;
                rect.Bottom = ClientRectangle.Bottom;

                IntPtr ptr = IntPtr.Zero;
                explorerBrowserControl.SetRect(ref ptr, rect);
            }

            base.OnSizeChanged(e);
        }
        /// <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);
        }
 public static extern bool GetWindowRect(IntPtr hwnd, ref NativeRect rect);
 public static extern bool GetClientRect(IntPtr hwnd, ref NativeRect rect);
 protected override void UpdateBounds(NativeRect bounds)
 {
     _bounds = bounds;
     UpdatePlacement();
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 protected override void UpdateBounds(NativeRect bounds)
 {
     Control.Bounds = Rectangle.FromLTRB(bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
     Control.Visible = true;
 }
 public virtual extern void SetRect([In, Out] ref IntPtr phdwp, NativeRect rcBrowser);