コード例 #1
0
        Client Manage( IntPtr hwnd , TileMode tileMode )
        {

            if ( ContainClient( hwnd ) )
            {
                return GetClient( hwnd );
            }
            WindowInfo windowInfo = new WindowInfo( );
            User32Methods.GetWindowInfo( hwnd , ref windowInfo );
            Client client = CreateClient( hwnd );
            if ( tileMode == TileMode.Tile )
            {

                WindowPlacement windowPlacement = new WindowPlacement( );
                if ( User32Methods.IsWindowVisible( client.Hwnd )  )
                {
                    User32Methods.SetWindowPlacement( hwnd , ref windowPlacement );
                }

                if ( User32Methods.IsWindowVisible( client.Hwnd )  )
                {
                    Rectangle windowRect = windowInfo.WindowRect;
                    DWM.resize( client , windowRect.Left , windowRect.Top , windowRect.Width , windowRect.Height , ScreenGeom.Rect );
                }
            }
            client.TileMode = tileMode;

            WindowManager.Attach( client , WindowManager.SelectedTag );
            return client;
        }
コード例 #2
0
ファイル: Win32Api.cs プロジェクト: xgenvn/d-term
        private static bool IsMainWindow(IntPtr windowHandle)
        {
            var style = (WindowStyles)User32Helpers.GetWindowLongPtr(windowHandle, WindowLongFlags.GWL_STYLE);

            var isMinimized = (style & WindowStyles.WS_MINIMIZE) == WindowStyles.WS_MINIMIZE;

            return
                (User32Methods.IsWindow(windowHandle) &&
                 (User32Methods.IsWindowVisible(windowHandle) || isMinimized));
        }
コード例 #3
0
        void UpdateGeom( )
        {
            var hwnd = ThreadWindowHandles.FindWindow( "Shell_TrayWnd" , null );
            RECT rect = new RECT();

            if ( User32Methods.IsWindowVisible( hwnd )  )
            {
                ThreadWindowHandles.SystemParametersInfoGet( ( uint )SystemParametersDesktopInfo.SPI_GETWORKAREA , 0 ,
                    ref rect , ( uint )SystemParamtersInfoFlags.None );
                ScreenGeom = rect;
            }
            else
            {
                int sx = User32Methods.GetSystemMetrics( SystemMetrics.SM_XVIRTUALSCREEN );
                int sy = User32Methods.GetSystemMetrics( SystemMetrics.SM_YVIRTUALSCREEN );
                int sw = User32Methods.GetSystemMetrics( SystemMetrics.SM_CXVIRTUALSCREEN );
                int sh = User32Methods.GetSystemMetrics( SystemMetrics.SM_CYVIRTUALSCREEN );
                ScreenGeom = new RECT( sx , sy , sw , sh );
            }
            // 固定値
            BarHeight = 20;
            int wy = ScreenGeom.Top;
            int wh = ScreenGeom.Height;
            BarY = -BarHeight;
            {
                if ( TopBar )
                {
                    wy = ScreenGeom.Top + BarHeight;
                    BarY = wy - BarHeight;
                }
                else
                {
                    BarY = wy + wh;
                }
                wh = ScreenGeom.Height - BarHeight;
            }
            // ここ全体 TileWindowManagerに持っていきたい
            WindowManager.ScreenGeom = ScreenGeom;
        }
コード例 #4
0
 public bool IsVisible()
 {
     return(User32Methods.IsWindowVisible(this.Handle));
 }
コード例 #5
0
        TileMode IsManageable( IntPtr hwnd )
        {
            if ( ContainClient( hwnd ) )
            {
                return TileMode.NoHandle;
            }
            if ( hwnd == Handle )
            {
                return TileMode.NoHandle;
            }
            String windowText = ThreadWindowHandles.GetWindowText( hwnd );
            String classText = ThreadWindowHandles.GetClassText( hwnd );
            bool isFloatListName = false;
            if ( !_TileSetting.IsTilingTarget( hwnd ) )
            {
                isFloatListName = true;
            }
            if ( _TileSetting.IsBlackTarget( hwnd ) )
            {
                return TileMode.NoHandle;
            }
            Trace.WriteLine( windowText + " : className = " + classText );
#if RECOVER
            if ( 
                windowText.Contains( "Chrome" ) ||
                windowText.Contains( "Avast Secure" ) ||
                windowText.Contains( "Visual" ) ||
                windowText.Contains( "VIM" ) ||
                classText.Contains( "CabinetWClass" ) ||
                windowText.Contains("pmx") ||
                windowText.Contains("Blender")
                )
            {
                DWM.setVisibility( hwnd , true );
                return TileMode.Tile;
            }
#endif
            if ( User32Methods.GetWindowPlacement( hwnd , out WindowPlacement windowPlacement ) )
            {
                if ( ( windowPlacement.ShowCmd & ShowWindowCommands.SW_HIDE ) != 0 )
                {
                    return TileMode.NoHandle;
                }
            }

            var parent = ThreadWindowHandles.GetParent( hwnd );
            var owner = User32Helpers.GetWindow( hwnd , GetWindowFlag.GW_OWNER );
            WindowStyles style = WindowStyle( hwnd );
            //tosafeがほしいけど別ライブラリ内
            var exStyle = ( WindowExStyles )( User32Helpers.GetWindowLongPtr( hwnd , WindowLongFlags.GWL_EXSTYLE ).ToInt32( ) );
            bool isParentOK = parent != IntPtr.Zero && IsManageable( parent ) == TileMode.Tile;
            bool isTool = ( exStyle & WindowExStyles.WS_EX_TOOLWINDOW ) != 0;
            bool isApp = ( exStyle & WindowExStyles.WS_EX_APPWINDOW ) != 0;
            if ( isParentOK && !ContainClient( parent ) )
            {
                // なんか見えないウィンドウをmanageするので
                //Manage( hwnd );
            }

            if ( ( style & WindowStyles.WS_DISABLED ) != 0 )
            {
                return TileMode.NoHandle;
            }
            // WS_POPUPWINDOW も含んでいる
            if ( ( style & WindowStyles.WS_POPUP ) != 0 )
            {
                return TileMode.NoHandle;
            }
            bool hasParent = parent != IntPtr.Zero;
            var winIsVisibleAndNoParent = !hasParent && User32Methods.IsWindowVisible( hwnd );
            if ( winIsVisibleAndNoParent || isParentOK )
            {
                if ( ( !isTool && !hasParent ) || ( isTool && isParentOK ) || ( isApp && hasParent ) )
                {
                    if ( windowText != null )
                    {

                        Trace.Write( windowText );
                        Trace.WriteLine( " isTool : " + isTool + " isApp : " + isApp + " style : " + style );
                    }
                    if ( isFloatListName )
                    {
                        return TileMode.Float;
                    }
                    return TileMode.Tile;
                }
            }
            return TileMode.NoHandle;
        }