/// <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)
            {
                TaskbarManager.Instance.TaskbarList.SetThumbnailClip(windowHandle, IntPtr.Zero);
                return;
            }

            CoreNativeMethods.RECT rect = new CoreNativeMethods.RECT();
            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);
                TaskbarManager.Instance.TaskbarList.SetThumbnailClip(windowHandle, rectPtr);
            }
            finally
            {
                Marshal.FreeCoTaskMem(rectPtr);
            }
        }
Beispiel #2
0
        internal static bool GetClientSize(IntPtr hwnd, out System.Drawing.Size size)
        {
            CoreNativeMethods.RECT rect = new CoreNativeMethods.RECT();

            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);
        }
Beispiel #3
0
        internal static System.Drawing.Size GetNonClientArea(IntPtr hwnd)
        {
            var c = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(hwnd, ref c);

            var r = new CoreNativeMethods.RECT();

            TabbedThumbnailNativeMethods.GetWindowRect(hwnd, ref r);

            return(new System.Drawing.Size(c.X - r.left, c.Y - r.top));
        }
        /// <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);
        }
        /// <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)
            {
                CoreNativeMethods.RECT rect = new CoreNativeMethods.RECT();
                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>
        /// Excludes a UI element from the AeroGlass frame.
        /// </summary>
        /// <param name="element">The element to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeElementFromAeroGlass(FrameworkElement element)
        {
            if (AeroGlassCompositionEnabled)
            {
                // calculate total size of window nonclient area
                HwndSource             hwndSource = PresentationSource.FromVisual(this) as HwndSource;
                CoreNativeMethods.RECT windowRect = new CoreNativeMethods.RECT( );
                CoreNativeMethods.RECT clientRect = new CoreNativeMethods.RECT( );
                DesktopWindowManagerNativeMethods.GetWindowRect(hwndSource.Handle, ref windowRect);
                DesktopWindowManagerNativeMethods.GetClientRect(hwndSource.Handle, ref clientRect);
                Size nonClientSize =
                    new Size(
                        (double)(windowRect.right - windowRect.left) - (double)(clientRect.right - clientRect.left),
                        (double)(windowRect.bottom - windowRect.top) - (double)(clientRect.bottom - clientRect.top));

                // calculate size of element relative to nonclient area
                GeneralTransform transform    = element.TransformToAncestor(this);
                Point            topLeftFrame =
                    transform.Transform(new Point(0, 0));
                Point bottomRightFrame =
                    transform.Transform(
                        new Point(
                            element.ActualWidth + nonClientSize.Width,
                            element.ActualHeight + nonClientSize.Height));

                // Create a margin structure
                MARGINS margins = new MARGINS( );
                margins.cxLeftWidth    = (int)topLeftFrame.X;
                margins.cxRightWidth   = (int)(this.ActualWidth - bottomRightFrame.X);
                margins.cyTopHeight    = (int)(topLeftFrame.Y);
                margins.cyBottomHeight = (int)(this.ActualHeight - bottomRightFrame.Y);

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(windowHandle, ref margins);
            }
        }
Beispiel #7
0
 public virtual extern void SetRect([In, Out] ref IntPtr phdwp, CoreNativeMethods.RECT rcBrowser);
Beispiel #8
0
 public virtual extern void Initialize(IntPtr hwndParent, [In] ref CoreNativeMethods.RECT prc, [In] FOLDERSETTINGS pfs);
Beispiel #9
0
 internal static extern bool GetWindowRect(IntPtr hwnd, ref CoreNativeMethods.RECT rect);