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

            動態生成對話框

            Creating   a   Template   in   Memory
            Applications   sometimes   adapt   or   modify   the   content   of   dialog   boxes   depending   on   the   current   state   of   the   data   being   processed.   In   such   cases,   it   is   not   practical   to   provide   all   possible   dialog   box   templates   as   resources   in   the   application 's   executable   file.   But   creating   templates   in   memory   gives   the   application   more   flexibility   to   adapt   to   any   circumstances.  

            In   the   following   example,   the   application   creates   a   template   in   memory   for   a   modal   dialog   box   that   contains   a   message   and   OK   and   Help   buttons.  

            In   a   dialog   template,   all   character   strings,   such   as   the   dialog   box   and   button   titles,   must   be   Unicode   strings.   This   example   uses   the   MultiByteToWideChar   function   to   generate   these   Unicode   strings,   because   Windows   95/98   and   Windows   NT/Windows   2000   support   MultiByteToWideChar  

            The   DLGITEMTEMPLATE   structures   in   a   dialog   template   must   be   aligned   on   DWORD   boundaries.   To   align   these   structures,   this   example   uses   a   helper   routine   that   takes   an   input   pointer   and   returns   the   closest   pointer   that   is   aligned   on   a   DWORD   boundary.

            #define   ID_HELP       150
            #define   ID_TEXT       200

            LPWORD   lpwAlign   (   LPWORD   lpIn)
            {
                    ULONG   ul;

                    ul   =   (ULONG)   lpIn;
                    ul   +=3;
                    ul   > > =2;
                    ul   < <=2;
                    return   (LPWORD)   ul;
            }

            LRESULT   DisplayMyMessage(HINSTANCE   hinst,   HWND   hwndOwner,  
                    LPSTR   lpszMessage)
            {
                    HGLOBAL   hgbl;
                    LPDLGTEMPLATE   lpdt;
                    LPDLGITEMTEMPLATE   lpdit;
                    LPWORD   lpw;
                    LPWSTR   lpwsz;
                    LRESULT   ret;
                    int   nchar;

                    hgbl   =   GlobalAlloc(GMEM_ZEROINIT,   1024);
                    if   (!hgbl)
                            return   -1;
             
                    lpdt   =   (LPDLGTEMPLATE)GlobalLock(hgbl);
             
                    //   Define   a   dialog   box.
             
                    lpdt-> style   =   WS_POPUP   |   WS_BORDER   |   WS_SYSMENU
                                                  |   DS_MODALFRAME   |   WS_CAPTION;
                    lpdt-> cdit   =   3;     //   number   of   controls
                    lpdt-> x     =   10;     lpdt-> y     =   10;
                    lpdt-> cx   =   100;   lpdt-> cy   =   100;

                    lpw   =   (LPWORD)   (lpdt   +   1);
                    *lpw++   =   0;       //   no   menu
                    *lpw++   =   0;       //   predefined   dialog   box   class   (by   default)

                    lpwsz   =   (LPWSTR)   lpw;
                    nchar   =   1+   MultiByteToWideChar   (CP_ACP,   0,   "My   Dialog ",  
                                                                                    -1,   lpwsz,   50);
                    lpw       +=   nchar;

                    //-----------------------
                    //   Define   an   OK   button.
                    //-----------------------
                    lpw   =   lpwAlign   (lpw);   //   align   DLGITEMTEMPLATE   on   DWORD   boundary
                    lpdit   =   (LPDLGITEMTEMPLATE)   lpw;
                    lpdit-> x     =   10;   lpdit-> y     =   70;
                    lpdit-> cx   =   80;   lpdit-> cy   =   20;
                    lpdit-> id   =   IDOK;     //   OK   button   identifier
                    lpdit-> style   =   WS_CHILD   |   WS_VISIBLE   |   BS_DEFPUSHBUTTON;

                    lpw   =   (LPWORD)   (lpdit   +   1);
                    *lpw++   =   0xFFFF;
                    *lpw++   =   0x0080;         //   button   class

                    lpwsz   =   (LPWSTR)   lpw;
                    nchar   =   1+MultiByteToWideChar   (CP_ACP,   0,   "OK ",   -1,   lpwsz,   50);
                    lpw       +=   nchar;
                    lpw   =   lpwAlign   (lpw);   //   align   creation   data   on   DWORD   boundary
                    *lpw++   =   0;                       //   no   creation   data

                    //-----------------------
                    //   Define   a   Help   button.
                    //-----------------------
                    lpw   =   lpwAlign   (lpw);   //   align   DLGITEMTEMPLATE   on   DWORD   boundary
                    lpdit   =   (LPDLGITEMTEMPLATE)   lpw;
                    lpdit-> x     =   55;   lpdit-> y     =   10;
                    lpdit-> cx   =   40;   lpdit-> cy   =   20;
                    lpdit-> id   =   ID_HELP;         //   Help   button   identifier
                    lpdit-> style   =   WS_CHILD   |   WS_VISIBLE   |   BS_PUSHBUTTON;

                    lpw   =   (LPWORD)   (lpdit   +   1);
                    *lpw++   =   0xFFFF;
                    *lpw++   =   0x0080;                                   //   button   class   atom

                    lpwsz   =   (LPWSTR)   lpw;
                    nchar   =   1+MultiByteToWideChar   (CP_ACP,   0,   "Help ",   -1,   lpwsz,   50);
                    lpw       +=   nchar;
                    lpw   =   lpwAlign   (lpw);   //   align   creation   data   on   DWORD   boundary
                    *lpw++   =   0;                       //   no   creation   data

                    //-----------------------
                    //   Define   a   static   text   control.
                    //-----------------------
                    lpw   =   lpwAlign   (lpw);   //   align   DLGITEMTEMPLATE   on   DWORD   boundary
                    lpdit   =   (LPDLGITEMTEMPLATE)   lpw;
                    lpdit-> x     =   10;   lpdit-> y     =   10;
                    lpdit-> cx   =   40;   lpdit-> cy   =   20;
                    lpdit-> id   =   ID_TEXT;     //   text   identifier
                    lpdit-> style   =   WS_CHILD   |   WS_VISIBLE   |   SS_LEFT;

                    lpw   =   (LPWORD)   (lpdit   +   1);
                    *lpw++   =   0xFFFF;
                    *lpw++   =   0x0082;                                                   //   static   class

                    for   (lpwsz   =   (LPWSTR)lpw;        
                            *lpwsz++   =   (WCHAR)   *lpszMessage++;
                    );
                    lpw   =   (LPWORD)lpwsz;
                    lpw   =   lpwAlign   (lpw);   //   align   creation   data   on   DWORD   boundary
                    *lpw++   =   0;                       //   no   creation   data

                    GlobalUnlock(hgbl);  
                    ret   =   DialogBoxIndirect(hinst,   (LPDLGTEMPLATE)   hgbl,  
                            hwndOwner,   (DLGPROC)   DialogProc);  
                    GlobalFree(hgbl);  
                    return   ret;  
            }

            posted on 2011-03-24 10:53 wrh 閱讀(638) 評論(0)  編輯 收藏 引用

            導航

            <2010年11月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久综合久久伊人| 成人久久精品一区二区三区| 久久99热这里只频精品6| 亚洲中文字幕无码久久2017| 成人国内精品久久久久影院| 亚洲精品无码久久毛片| 久久99精品国产麻豆| 久久久久久国产精品美女| 亚洲精品无码成人片久久| 91精品日韩人妻无码久久不卡| 久久久www免费人成精品| 亚洲国产精品无码久久| 久久久精品人妻无码专区不卡| 国产成年无码久久久久毛片| 久久99热精品| 色综合久久久久久久久五月| 国产精品青草久久久久福利99| 久久婷婷五月综合97色直播| AV无码久久久久不卡蜜桃| 亚洲欧美久久久久9999| 99久久婷婷国产一区二区| 无码人妻精品一区二区三区久久久 | 午夜精品久久久久久久| 久久综合九色欧美综合狠狠 | 99久久www免费人成精品| 无码国内精品久久综合88| 91精品国产91久久| 久久精品国产91久久综合麻豆自制| 久久伊人精品一区二区三区| 久久精品亚洲男人的天堂| 精品精品国产自在久久高清| 性欧美丰满熟妇XXXX性久久久| 国产精品成人久久久| 尹人香蕉久久99天天拍| 日韩欧美亚洲综合久久影院Ds | 9999国产精品欧美久久久久久| 久久亚洲精品人成综合网| 色播久久人人爽人人爽人人片aV| 久久精品一区二区影院 | 亚洲国产成人久久一区久久| 免费观看久久精彩视频|