예제 #1
0
        /// <summary>
        /// Attaches a new window to the filter. The default implementation
        /// parents un-parented windows to the application host. Override to
        /// provide custom logic.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="hWnd"></param>
        public virtual void AttachWindow(AppHost host, IntPtr hWnd)
        {
            // By default we just parent the window to the host. Note that some
            // dialogs may already be parented. These are skipped.

            if (!IsParented(hWnd))
                NativeMethods.SetParent(hWnd, GetHostHandle(host));
        }
예제 #2
0
        public override void ResizeWindow(AppHost host, IntPtr hWnd)
        {
            // Main windows aren't centered. We only handle the maximize case, and
            // only that when the window allows maximization.

            var style = (WindowStyle)NativeMethods.GetWindowLong(hWnd, NativeMethods.GWL_STYLE);

            if (_maximize && (style & WindowStyle.MaximizeBox) == WindowStyle.MaximizeBox)
            {
                if ((style & (WindowStyle.Caption | WindowStyle.SizeFrame)) != 0)
                {
                    // If we are going to maximize the main window, remove its
                    // chrome.

                    NativeMethods.SetWindowLong(
                        hWnd,
                        NativeMethods.GWL_STYLE,
                        (int)(style & ~(WindowStyle.Caption | WindowStyle.SizeFrame))
                    );

                    // Inform the window of the changes.

                    NativeMethods.SetWindowPos(
                        hWnd,
                        IntPtr.Zero,
                        0, 0, 0, 0,
                        NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_FRAMECHANGED
                    );
                }

                var parent = NativeMethods.GetParent(hWnd);
                var hostHandle = GetHostHandle(host);

                MaximizeWindow(hWnd, host.Size);
            }
        }
 public override void ResizeWindow(AppHost host, IntPtr hWnd)
 {
     CenterWindow(hWnd, host.Size);
 }
예제 #4
0
 /// <summary>
 /// Detaches a window from the filter. Override to provide custom logic.
 /// </summary>
 /// <param name="host"></param>
 /// <param name="hWnd"></param>
 public virtual void DetachWindow(AppHost host, IntPtr hWnd)
 {
 }
예제 #5
0
        internal IntPtr GetHostHandle(AppHost host)
        {
            if (_hostHandle == IntPtr.Zero)
            {
                if (host.InvokeRequired)
                {
                    return (IntPtr)host.Invoke(
                        new Func<AppHost, IntPtr>(GetHostHandle), host
                    );
                }
                else
                {
                    _hostHandle = host.Handle;
                }
            }

            return _hostHandle;
        }
예제 #6
0
 /// <summary>
 /// Called when the matched window must be resized. Override when
 /// windows handled by the filter must be resized based on the
 /// dimensions of the application host.
 /// </summary>
 /// <param name="host">Application host that hosts the application
 /// which created the provided window.</param>
 /// <param name="hWnd">Handle to the window to be resized.</param>
 public virtual void ResizeWindow(AppHost host, IntPtr hWnd)
 {
 }
예제 #7
0
 /// <summary>
 /// Called when the matched window must be resized. Override when
 /// windows handled by the filter must be resized based on the
 /// dimensions of the application host.
 /// </summary>
 /// <param name="host">Application host that hosts the application
 /// which created the provided window.</param>
 /// <param name="hWnd">Handle to the window to be resized.</param>
 public virtual void ResizeWindow(AppHost host, IntPtr hWnd)
 {
 }
예제 #8
0
 /// <summary>
 /// Detaches a window from the filter. Override to provide custom logic.
 /// </summary>
 /// <param name="host"></param>
 /// <param name="hWnd"></param>
 public virtual void DetachWindow(AppHost host, IntPtr hWnd)
 {
 }
예제 #9
0
 public override void AttachWindow(AppHost host, IntPtr hWnd)
 {
     NativeMethods.SetParent(hWnd, GetHostHandle(host));
 }