• <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>

            hdqqq

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              35 隨筆 :: 0 文章 :: 104 評論 :: 0 Trackbacks

            unix系統下的banner是用于顯示點陣字體的程序cygwin下有類似的程序可以在windows下跑,但是不支持中文.

            所以自己寫了一個windows下的類似程序,自己建一個控制臺工程(需支持mfc)后,把下面的代碼復制一下就可以了.同時,新年快到了,祝大家:

            ???? #????? ##?????? ##??????????? #??? ##???????? #??? ####?
            ? ###### ###??????? #########????? # #?? #???????? #######???
            ??? # #? #??????? ##?? ##??????? # # ########????? #?? ##????
            ? ###### #######?? ##########??? # #???? #? #???? ##?? ##????
            ?#? ##? ## ## #??? ##? ##??????? # #???? ####???? ############
            ? ###### # ##??? ###############?? # ##########????? # ###???
            ?? ### ### ##??? ##??? ##? ####??? #??? # #? #????? ## ## ##?
            ? #### ##? ##????????? ##????????? #?? ## ##????? ###? ##? ####
            ?#? ##? #? ##????????? ##????????? # ###?? ##??? #?? # ##??? ##
            ??????????? #????????? ##????????? ##???????????????? ##??????

            ????? 8? 88??????????? 8?????????????? 8? 8??????????????? 88??
            ?? 8888888888???? 88888888888????? 88? 8 88?????? 88888??? 88??
            ????? 8? 8???????? 888888888?????? 8?? 8????????? 8 8 8 88888888
            ? 8888 888888?????? 8888888??????? 888888888????? 8 8 8??? 8888
            ???? 888? 88??????? 88?? 88?????????? 88888?????? 8 8 8?? 888??
            ?? 88? 8?? 888??????? 8888??????????? 88 88?????? 8 8 8? 8888??
            8888 8 8888 888? 88888888888888???? 88? 88??????? 888 8888 88??
            ??? 8? 88 88 8????? 88888888???? 8888? 88 888????? 8888??? 88??
            ?? 8 888 8 8??????? 88??? 88??????? 8888?? 8888? 888? 88 8888??
            ????? 88??????????? 88888888???????????????? 8???????????? 8???

            使用方式

            wbanner [-c 填充字符] [-f 字體名稱] [-s 字體大小] 顯示文本

            /////////////////

            // ?wbanner_6.cpp?:?Defines?the?entry?point?for?the?console?application.
            //

            #include?
            " stdafx.h "
            #include?
            " wbanner_6.h "

            #ifdef?_DEBUG
            #define ?new?DEBUG_NEW
            #undef ?THIS_FILE
            static ? char ?THIS_FILE[]? = ?__FILE__;
            #endif

            /////////////////////////////////////////////////////////////////////////// //
            // ?The?one?and?only?application?object

            CWinApp?theApp;

            using ? namespace ?std;


            #define ?BMP_WIDTH????100
            #define ?BMP_HEIGHT????30

            void ?ParseArg(CString & ?info,?CString & ?fill_str,CString & ?font_name,? int & ?font_size,? int ?argc,TCHAR * ?argv[])
            {
            ????
            int ?i;
            ????
            for ?(i? = ? 1 ;?i? < ?argc;?i ++ )?{
            ????????
            if ?(strcmp(argv[i],? " -c " )? == ? 0 ? && ?i? < ?argc)?{
            ????????????fill_str?
            = ?argv[ ++ i];
            ????????????
            continue ;
            ????????}
            ????????
            if ?(strcmp(argv[i],? " -f " )? == ? 0 ? && ?i? < ?argc)?{
            ????????????font_name?
            = ?argv[ ++ i];
            ????????????
            continue ;
            ????????}
            ????????
            if ?(strcmp(argv[i],? " -s " )? == ? 0 ? && ?i? < ?argc)?{
            ????????????font_size?
            = ?atoi(argv[ ++ i]);
            ????????????
            if ?(font_size? <= ? 120 )?
            ????????????????font_size?
            = ? 120 ;
            ????????????
            continue ;
            ????????}

            ????????info?
            = ?argv[i];
            ????????
            break ;
            ????}
            }

            void ?ShowBanner(LPCTSTR?fill_str,?LPCTSTR?info,?LPCTSTR?font_name,? int ?font_size)
            {
            ????CFont?lfont;
            ????CDC?ldc;
            ????CBitmap?lbmp;
            ????ldc.CreateCompatibleDC(NULL);
            ????lbmp.CreateCompatibleBitmap(
            & ldc,?BMP_WIDTH,?BMP_HEIGHT);
            ????CBitmap
            * ?pold? = ?(CBitmap * )ldc.SelectObject( & lbmp);
            ????
            ????lfont.CreatePointFont(font_size,?font_name,?
            & ldc);
            ????
            ????CFont
            * ?poldfont? = ?(CFont * )ldc.SelectObject( & lfont);
            ????
            ????CRect?lrect(
            0 ,? 0 ,?BMP_WIDTH,BMP_HEIGHT);
            ????
            ????ldc.FillSolidRect(
            0 , 0 ,?BMP_WIDTH,?BMP_HEIGHT,?RGB( 255 , 255 , 255 ));
            ????ldc.DrawText(info,?
            & lrect,?DT_LEFT);
            ????
            ????BITMAP?bmp_head;
            ????
            ????lbmp.GetBitmap(
            & bmp_head);
            ????
            ????
            ????DWORD?bufsize?
            = ?bmp_head.bmWidthBytes * bmp_head.bmHeight;
            ????
            char * ?buf? = ? new ? char [bufsize];
            ????
            ????memset(buf,?
            0 ,?bufsize);
            ????
            ????DWORD?get_ret?
            = ?lbmp.GetBitmapBits(bufsize,?( void * )buf);
            ????
            ????
            int ?i,j;
            ????
            if ?(get_ret? != ? 0 )?{
            ????????
            char ?ret[ 2 ]? = ?{? 13 ,? 10 };
            ????????CString?
            out [ 2 ]? = ?{fill_str,? " ? " };
            ????????
            for ?(i? = ? 0 ;?i? < ?bmp_head.bmHeight;?i ++ )
            ????????{
            ????????????
            int ?charcount? = ? 0 ;
            ????????????
            for ?(j? = ? 0 ;?j? < ?bmp_head.bmWidth;?j ++ )?{
            ????????????????
            int ?offset? = ?bmp_head.bmWidthBytes * i + j / 8 ;
            ????????????????
            char ?cur;
            ????????????????cur?
            = ?buf[offset];
            ????????????????
            char ?tt? = ?cur? & ?( 0x80 ? >> ?(j? % ? 8 ));
            ????????????????CString?temp;
            ????????????????
            if ?(tt? == ? 0 )?{
            ????????????????????temp?
            = ? out [ 0 ];
            ????????????????}
            else ?{
            ????????????????????temp?
            = ? out [ 1 ];
            ????????????????}
            ????????????????cout?
            << ?(LPCTSTR)temp;
            ????????????????charcount
            ++ ;
            ????????????}
            ????????????cout?
            << ?endl;
            ????????}
            ????}
            ????????
            ????ldc.SelectObject(pold);
            ????ldc.SelectObject(poldfont);
            ????delete?[]?buf;
            }

            void ?PrintUsage( int ?argc,?TCHAR * ?argv[])
            {
            ????cout?
            << ? " not?enough?arguments " ? << ?endl;
            ????cout?
            << ? " Usage: " ? << ?endl;
            ????cout?
            << ?argv[ 0 ]? << ? " ?[-c?#]?[-f?font_name]?[-s?font_size]?A?string?to?print " ? << ?endl;
            }

            int ?_tmain( int ?argc,?TCHAR * ?argv[],?TCHAR * ?envp[])
            {
            ????
            int ?nRetCode? = ? 0 ;

            ????
            // ?initialize?MFC?and?print?and?error?on?failure
            ???? if ?(AfxWinInit(::GetModuleHandle(NULL),?NULL,?::GetCommandLine(),? 0 ))
            ????{
            ????????
            // ?TODO:?change?error?code?to?suit?your?needs

            ????????CString?info?
            = ? " wbanner " ;
            ????????CString?font_name?
            = ? " 宋體 " ;
            ????????CString?fill_str?
            = ? " # " ;
            ????????
            int ?font_size? = ? 120 ;
            ????????
            ????????
            ????????
            if ?(argc? < ? 2 )?{
            ????????????PrintUsage(argc,?argv);
            ????????}
            else ?{
            ????????????ParseArg(info,?fill_str,?font_name,?font_size,?argc,?argv);
            ????????????ShowBanner(fill_str,?info,?font_name,?font_size);
            ????????}
            ????}
            else ?{
            ????????cerr?
            << ?_T( " Fatal?Error:?MFC?initialization?failed " )? << ?endl;
            ????????nRetCode?
            = ? 1 ;
            ????}
            ????
            return ?nRetCode;
            }


            posted on 2006-12-22 10:13 hdqqq 閱讀(1163) 評論(2)  編輯 收藏 引用 所屬分類: c/c++

            評論

            # re: windows下的banner 2008-04-24 12:06 huy666
            我編譯出錯

            Compiling...
            WinBanner.cpp
            e:\anew\winbanner\winbanner.cpp(187) : fatal error C1010: unexpected end of file while looking for precompiled header directive
            Error executing cl.exe.
            Creating browse info file...
            BSCMAKE: error BK1506 : cannot open file '.\Debug\WinBanner.sbr': No such file or directory
            Error executing bscmake.exe.

            WinBanner.exe - 2 error(s), 0 warning(s)

            wbanner_6.h的內容?

            請指教,多謝。
            huy666◎163.com
              回復  更多評論
              

            # re: windows下的banner 2008-04-24 12:33 huy666
            可以了
            #include " stdafx.h "
            #include " wbanner_6.h "
            改成
            #include "stdafx.h"
            #include "WinBanner.h"
            我的工程名WinBanner

            多謝 你的程序比較好玩  回復  更多評論
              

            久久久久亚洲AV无码专区首JN| 国产一区二区三区久久| 久久国产精品波多野结衣AV| 久久综合丁香激情久久| 久久精品99无色码中文字幕| 亚洲午夜精品久久久久久app| 亚洲精品乱码久久久久久自慰 | 污污内射久久一区二区欧美日韩| 伊人热热久久原色播放www| 久久99精品久久久久久hb无码| 国产精品欧美亚洲韩国日本久久| 无码人妻久久一区二区三区蜜桃| 国产91久久精品一区二区| 精品久久久久久无码不卡| 国产日产久久高清欧美一区| 久久亚洲中文字幕精品一区| 国产精品内射久久久久欢欢 | 国产精品视频久久久| 欧美日韩精品久久久久| 国产99久久久国产精免费| 天天躁日日躁狠狠久久| 亚洲精品综合久久| 久久精品二区| 青青国产成人久久91网| 精品乱码久久久久久久| 精品久久久久久中文字幕大豆网| 国产精品亚洲美女久久久| 999久久久无码国产精品| 亚洲欧美伊人久久综合一区二区 | 亚洲精品无码久久一线| 久久亚洲国产成人影院| 久久影视综合亚洲| 久久久久国产一区二区三区| 久久久国产精华液| 久久国产成人精品国产成人亚洲| 国产AV影片久久久久久| 99久久精品费精品国产| a级毛片无码兔费真人久久| 国产视频久久| 蜜桃麻豆www久久国产精品| 久久久中文字幕日本|