• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 94, comments - 250, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Win32控制臺清屏方法

            Posted on 2010-06-30 20:18 Condor 閱讀(2876) 評論(0)  編輯 收藏 引用

            最后覺得項目中的控制臺不大好用,就添加了一些小功能,比如清屏;當然最簡單的方法是調用系統自帶的函數system(“cls”);,這里提供一個方法一樣可以清屏(測試比cls要快一些):

             

             /* Standard error macro for reporting API errors */ 
             
            #define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \ 
                on line 
            %d\n", __FILE__, GetLastError(), api, __LINE__);}

             
            void cls( HANDLE hConsole )
             {
                COORD coordScreen 
            = { 00 };    /* here's where we'll home the
                                                    cursor 
            */ 
                BOOL bSuccess;
                DWORD cCharsWritten;
                CONSOLE_SCREEN_BUFFER_INFO csbi; 
            /* to get buffer info */ 
                DWORD dwConSize;                 
            /* number of character cells in
                                                    the current buffer 
            */ 

                
            /* get the number of character cells in the current buffer */ 

                bSuccess 
            = GetConsoleScreenBufferInfo( hConsole, &csbi );
                PERR( bSuccess, 
            "GetConsoleScreenBufferInfo" );
                dwConSize 
            = csbi.dwSize.X * csbi.dwSize.Y;

                
            /* fill the entire screen with blanks */ 

                bSuccess 
            = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
                   dwConSize, coordScreen, 
            &cCharsWritten );
                PERR( bSuccess, 
            "FillConsoleOutputCharacter" );

                
            /* get the current text attribute */ 

                bSuccess 
            = GetConsoleScreenBufferInfo( hConsole, &csbi );
                PERR( bSuccess, 
            "ConsoleScreenBufferInfo" );

                
            /* now set the buffer's attributes accordingly */ 

                bSuccess 
            = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
                   dwConSize, coordScreen, 
            &cCharsWritten );
                PERR( bSuccess, 
            "FillConsoleOutputAttribute" );

                
            /* put the cursor at (0, 0) */ 

                bSuccess 
            = SetConsoleCursorPosition( hConsole, coordScreen );
                PERR( bSuccess, 
            "SetConsoleCursorPosition" );
                
            return;
             }

             

            天天躁日日躁狠狠久久| 久久99精品国产麻豆宅宅| 久久97久久97精品免视看秋霞 | 亚洲精品无码久久千人斩| 精品人妻伦九区久久AAA片69| 久久精品一本到99热免费| 99久久99久久精品国产片| 怡红院日本一道日本久久 | 无码人妻少妇久久中文字幕蜜桃| 狠狠色丁香婷婷综合久久来| 四虎久久影院| 久久综合九色综合精品| 久久久久久精品久久久久| 久久国产精品二国产精品| 国内精品久久人妻互换| 伊人久久五月天| 激情五月综合综合久久69| 久久AV高清无码| 亚洲国产精品久久久天堂| 久久精品这里只有精99品| 热久久这里只有精品| 久久Av无码精品人妻系列 | 1000部精品久久久久久久久| 日韩十八禁一区二区久久 | 色欲综合久久躁天天躁蜜桃| 欧美久久亚洲精品| 国产亚洲色婷婷久久99精品91| 91精品国产9l久久久久| 久久久久亚洲精品无码蜜桃| 久久精品国产亚洲AV蜜臀色欲| 亚洲精品综合久久| 伊人色综合九久久天天蜜桃| 久久强奷乱码老熟女网站| 精品久久久久久无码免费| 国产成人久久777777| 国产午夜电影久久| 国产成人精品综合久久久| 久久精品国产99久久久香蕉| 国产精品99久久不卡| 无码任你躁久久久久久老妇 | 久久久久人妻精品一区二区三区 |