亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wtl for mfc programmers, part i.mht

?? 大家知道wtl是window UI庫
?? MHT
?? 第 1 頁 / 共 5 頁
字號:
inheritance=20
      list, each with a <CODE>CHAIN_MSG_MAP</CODE> macro so that =
messages are=20
      passed to it. This is different from MFC, where each=20
      <CODE>CWnd</CODE>-derived class can have only one base class, and =
MFC=20
      automatically passes unhandled messages to the base class.</P>
      <H2><A name=3Dexestructure></A>Structure of an ATL EXE</H2>
      <P>So now that we have a complete (if not entirely useful) main =
window,=20
      let's see how to use it in a program. An ATL executable contains a =
global=20
      <CODE>CComModule</CODE> variable called <CODE>_Module</CODE>. This =
is=20
      analogous to the global <CODE>CWinApp</CODE> variable called=20
      <CODE>theApp</CODE> in an MFC program; the only difference is that =
in ATL,=20
      the variable <I>must</I> be called <CODE>_Module</CODE>.</P>
      <P>Here's how we start our stdafx.h:</P><PRE><SPAN =
class=3Dcpp-comment>// stdafx.h:</SPAN>
<SPAN class=3Dcpp-preprocessor>#define STRICT</SPAN>
<SPAN class=3Dcpp-preprocessor>#define VC_EXTRALEAN</SPAN>
=20
<SPAN class=3Dcpp-preprocessor>#include &lt;atlbase.h&gt;        // Base =
ATL classes</SPAN>
<SPAN class=3Dcpp-keyword>extern</SPAN> CComModule _Module;  <SPAN =
class=3Dcpp-comment>// Global _Module</SPAN>
<SPAN class=3Dcpp-preprocessor>#include &lt;atlwin.h&gt;         // ATL =
windowing classes</SPAN></PRE>
      <P>atlbase.h will include the basic Windows headers, so there's no =
need to=20
      include windows.h, tchar.h, etc. In our CPP file, we declare the=20
      <CODE>_Module</CODE> variable:</P><PRE><SPAN =
class=3Dcpp-comment>// main.cpp:</SPAN>
CComModule _Module;</PRE>
      <P><CODE>CComModule</CODE> had explicit initialization and =
shutdown=20
      functions that we need to call in <CODE>WinMain()</CODE>, so let's =
start=20
      with those:</P><PRE><SPAN class=3Dcpp-comment>// main.cpp:</SPAN>
CComModule _Module;
=20
<SPAN class=3Dcpp-keyword>int</SPAN> WINAPI WinMain(HINSTANCE hInst, =
HINSTANCE hInstPrev,
                   LPSTR szCmdLine, <SPAN class=3Dcpp-keyword>int</SPAN> =
nCmdShow)
{
    _Module.Init(NULL, hInst);
    _Module.Term();
}</PRE>
      <P>The first parameter to <CODE>Init()</CODE> is only used in COM =
servers.=20
      Since our EXE contains no COM objects, we can just pass =
<CODE>NULL</CODE>.=20
      ATL doesn't provide its own <CODE>WinMain()</CODE> or message pump =
like=20
      MFC, so to get our program running, we create a =
<CODE>CMyWindow</CODE>=20
      object and add a message pump.</P><PRE><SPAN =
class=3Dcpp-comment>// main.cpp:</SPAN>
<SPAN class=3Dcpp-preprocessor>#include "MyWindow.h"</SPAN>
CComModule _Module;
=20
<SPAN class=3Dcpp-keyword>int</SPAN> WINAPI WinMain(HINSTANCE hInst, =
HINSTANCE hInstPrev,
                   LPSTR szCmdLine, <SPAN class=3Dcpp-keyword>int</SPAN> =
nCmdShow)
{
    _Module.Init(NULL, hInst);
=20
CMyWindow wndMain;
MSG msg;
=20
    <SPAN class=3Dcpp-comment>// Create &amp; show our main =
window</SPAN>
    <SPAN class=3Dcpp-keyword>if</SPAN> ( NULL =3D=3D wndMain.Create ( =
NULL, CWindow::rcDefault,=20
                                 _T(<SPAN class=3Dcpp-string>"My First =
ATL Window"</SPAN>) ))
        {
        <SPAN class=3Dcpp-comment>// Bad news, window creation =
failed</SPAN>
        <SPAN class=3Dcpp-keyword>return</SPAN> <SPAN =
class=3Dcpp-literal>1</SPAN>;
        }
=20
    wndMain.ShowWindow(nCmdShow);
    wndMain.UpdateWindow();
=20
    <SPAN class=3Dcpp-comment>// Run the message loop</SPAN>
    <SPAN class=3Dcpp-keyword>while</SPAN> ( GetMessage(&amp;msg, NULL, =
<SPAN class=3Dcpp-literal>0</SPAN>, <SPAN class=3Dcpp-literal>0</SPAN>) =
&gt; <SPAN class=3Dcpp-literal>0</SPAN> )
        {
        TranslateMessage(&amp;msg);
        DispatchMessage(&amp;msg);
        }
=20
    _Module.Term();
    <SPAN class=3Dcpp-keyword>return</SPAN> msg.wParam;
}</PRE>
      <P>The only unusual thing in the above code is=20
      <CODE>CWindow::rcDefault</CODE>, which is a <CODE>RECT</CODE> =
member of=20
      <CODE>CWindow</CODE>. Using that as the window's initial =
<CODE>RECT</CODE>=20
      is like using <CODE>CW_USEDEFAULT</CODE> for the width and height =
with the=20
      <CODE>CreateWindow()</CODE> API.</P>
      <P>Under the hood, ATL uses some assembly-language black magic to =
connect=20
      the main window's handle to its corresponding =
<CODE>CMyWindow</CODE>=20
      object. The upside of this is that there is no problem passing=20
      <CODE>CWindow</CODE> objects between threads, something that fails =

      miserably with <CODE>CWnd</CODE>s in MFC.</P>
      <P>Here's what our window looks like:</P>
      <P><IMG height=3D249 alt=3D" [First ATL window - 4K] "=20
      src=3D"http://www.codeproject.com/wtl/WTL4MFC1/firstwin.png" =
width=3D370=20
      align=3Dbottom border=3D0></P>
      <P>Nothing particularly exciting, I'll admit. To spice it up, =
we'll add an=20
      <I>About</I> menu item that shows a dialog.</P>
      <H2><A name=3Ddialogs></A>Dialogs in ATL</H2>
      <P>As mentioned earlier, ATL has two dialog classes. We'll use=20
      <CODE>CDialogImpl</CODE> for our about dialog. Making a new dialog =
class=20
      is almost like making a new frame window class; there are just two =

      differences:</P>
      <OL>
        <LI>The base class is <CODE>CDialogImpl</CODE> instead of=20
        <CODE>CWindowImpl</CODE>.=20
        <LI>You need to define a public member called <CODE>IDD</CODE> =
that=20
        holds the resource ID of the dialog. </LI></OL>
      <P>Here is the start of a new class definition for an about =
dialog:</P><PRE><SPAN class=3Dcpp-keyword>class</SPAN> CAboutDlg : <SPAN =
class=3Dcpp-keyword>public</SPAN> CDialogImpl&lt;CAboutDlg&gt;
{
<SPAN class=3Dcpp-keyword>public</SPAN>:
    <SPAN class=3Dcpp-keyword>enum</SPAN> { IDD =3D IDD_ABOUT };
=20
    BEGIN_MSG_MAP(CAboutDlg)
    END_MSG_MAP()
};</PRE>
      <P>ATL has no built-in handlers for the <I>OK</I> and =
<I>Cancel</I>=20
      buttons, so we need to code them ourselves, along with a=20
      <CODE>WM_CLOSE</CODE> handler that is called if the user clicks =
the close=20
      button in the title bar. We also need to handle =
<CODE>WM_INITDIALOG</CODE>=20
      so that the keyboard focus is set properly when the dialog =
appears. Here=20
      is the complete class definition with message =
handlers.</P><PRE><SPAN class=3Dcpp-keyword>class</SPAN> CAboutDlg : =
<SPAN class=3Dcpp-keyword>public</SPAN> CDialogImpl&lt;CAboutDlg&gt;
{
<SPAN class=3Dcpp-keyword>public</SPAN>:
    <SPAN class=3Dcpp-keyword>enum</SPAN> { IDD =3D IDD_ABOUT };
=20
    BEGIN_MSG_MAP(CAboutDlg)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
        COMMAND_ID_HANDLER(IDOK, OnOKCancel)
        COMMAND_ID_HANDLER(IDCANCEL, OnOKCancel)
    END_MSG_MAP()
=20
    LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, =
BOOL&amp; bHandled)
    {
        CenterWindow();
        <SPAN class=3Dcpp-keyword>return</SPAN> TRUE;    <SPAN =
class=3Dcpp-comment>// let the system set the focus</SPAN>
    }
=20
    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; =
bHandled)
    {
        EndDialog(IDCANCEL);
        <SPAN class=3Dcpp-keyword>return</SPAN> <SPAN =
class=3Dcpp-literal>0</SPAN>;
    }
=20
    LRESULT OnOKCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, =
BOOL&amp; bHandled)
    {
        EndDialog(wID);
        <SPAN class=3Dcpp-keyword>return</SPAN> <SPAN =
class=3Dcpp-literal>0</SPAN>;
    }
};</PRE>
      <P>I used one handler for both <I>OK</I> and <I>Cancel</I> to =
demonstrate=20
      the <CODE>wID</CODE> parameter, which is set to either =
<CODE>IDOK</CODE>=20
      or <CODE>IDCANCEL</CODE>, depending on which button is =
clicked.</P>
      <P>Showing the dialog is similar to MFC, you create an object of =
the new=20
      class and call <CODE>DoModal()</CODE>. Let's go back to our main =
window=20
      and add a menu with an <I>About</I> item that shows our new about =
dialog.=20
      We'll need to add two message handlers, one for =
<CODE>WM_CREATE</CODE> and=20
      one for the new menu item <CODE>IDC_ABOUT</CODE>.</P><PRE><SPAN =
class=3Dcpp-keyword>class</SPAN> CMyWindow : <SPAN =
class=3Dcpp-keyword>public</SPAN> CWindowImpl&lt;CMyWindow, CWindow, =
CFrameWinTraits&gt;,
                  <SPAN class=3Dcpp-keyword>public</SPAN> =
CPaintBkgnd&lt;CMyWindow,RGB(<SPAN class=3Dcpp-literal>0</SPAN>,<SPAN =
class=3Dcpp-literal>0</SPAN>,<SPAN class=3Dcpp-literal>255</SPAN>)&gt;
{
<SPAN class=3Dcpp-keyword>public</SPAN>:
    BEGIN_MSG_MAP(CMyWindow)
        MESSAGE_HANDLER(WM_CREATE, OnCreate)
        COMMAND_ID_HANDLER(IDC_ABOUT, OnAbout)
        <SPAN class=3Dcpp-comment>// ...</SPAN>
        CHAIN_MSG_MAP(CPaintBkgndBase)
    END_MSG_MAP()
=20
    LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; =
bHandled)
    {
    HMENU hmenu =3D LoadMenu ( _Module.GetResourceInstance(),
                             MAKEINTRESOURCE(IDR_MENU1) );
=20
        SetMenu ( hmenu );
        <SPAN class=3Dcpp-keyword>return</SPAN> <SPAN =
class=3Dcpp-literal>0</SPAN>;
    }
=20
    LRESULT OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&amp; =
bHandled)
    {
    CAboutDlg dlg;
=20
        dlg.DoModal();
        <SPAN class=3Dcpp-keyword>return</SPAN> <SPAN =
class=3Dcpp-literal>0</SPAN>;
    }
    <SPAN class=3Dcpp-comment>// ...</SPAN>
};</PRE>
      <P>One small difference in modal dialogs is where you specify the =
dialog's=20
      parent window. In MFC you pass the parent to the =
<CODE>CDialog</CODE>=20
      constructor, but in ATL you pass it as the first parameter to=20
      <CODE>DoModal()</CODE>. If you don't specify a window, as in the =
code=20
      above, ATL uses the result of <CODE>GetActiveWindow()</CODE> =
(which will=20
      be our frame window) as the parent.</P>
      <P>The <CODE>LoadMenu()</CODE> call also demonstrates one of the=20
      <CODE>CComModule</CODE> methods, =
<CODE>GetResourceInstance()</CODE>. This=20
      returns the <CODE>HINSTANCE</CODE> of our EXE, similar to=20
      <CODE>AfxGetResourceHandle()</CODE>. (There is also=20
      <CODE>CComModule::GetModuleInstance()</CODE>, which functions like =

      <CODE>AfxGetInstanceHandle()</CODE>.)</P>
      <P>Here is our revised main window and the about dialog:</P>
      <P><IMG height=3D248 alt=3D" [About box - 5K] "=20
      src=3D"http://www.codeproject.com/wtl/WTL4MFC1/firstabout.png" =
width=3D369=20
      align=3Dbottom border=3D0></P>
      <H2><A name=3Dwhereswtlman></A>I'll Get to WTL, I Promise!</H2>
      <P>But it will be in Part 2. Since I'm writing these articles for =
MFC=20
      developers, I felt that it was best to do an intro to ATL first, =
before=20
      diving into WTL. If this has been your first exposure to ATL, now =
might be=20
      a good time to write some simple apps on your own, so you get the =
hang of=20
      message maps and using mix-in classes. You can also experiment =
with=20
      ClassView's support for ATL message maps, as it can add message =
handlers=20
      for you. To get started, right-click on the <I>CMyWindow</I> item =
and pick=20
      <I>Add Windows Message Handler</I> on the context menu.</P>
      <P>In Part II, I will cover the base WTL windowing classes, the =
WTL=20
      AppWizard, and the much nicer message map macros.</P>
      <H2><A name=3Drevisionhistory></A>Revision History</H2>
      <P>March 22, 2003: Article first published.=20
</P><!-- Article Ends --></DIV>
      <H2>About Michael Dunn</H2>
      <TABLE width=3D"100%" border=3D0>
        <TBODY>
        <TR vAlign=3Dtop>
          <TD class=3DsmallText noWrap><IMG=20
            =
src=3D"http://www.codeproject.com/script/profile/images/{2D6F4A37-6FD0-4C=
EF-AC72-EA9D126E611E}.jpg"><BR><BR><IMG=20
            =
src=3D"http://www.codeproject.com/script/images/sitebuild_icon.gif">=20
            Site Builder</TD>
          <TD class=3DsmallText width=3D"100%">Michael lives in sunny =
Los Angeles,=20
            California, and is so spoiled by the weather that he will =
probably=20
            never be able to live anywhere else. He started programming =
with an=20
            Apple //e in 4th grade, graduated from <A=20
            href=3D"http://www.ucla.edu/">UCLA</A> with a math degree in =
1995, and=20
            immediately landed a job as a QA engineer at Symantec, =
working on=20
            the Norton AntiVirus team. He pretty much taught himself =
Windows and=20
            MFC programming, and in 1999 he designed and coded a new =
interface=20
            for Norton AntiVirus 2000.<BR><BR>Mike now works

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产日韩欧美不卡在线| 精品亚洲欧美一区| 精品一区二区三区av| 91在线观看高清| 久久精品视频一区二区三区| 亚洲电影激情视频网站| 国产不卡在线一区| 精品久久久久久久久久久久包黑料| 国产精品久久久久婷婷| 精品一区免费av| 9191国产精品| 亚洲国产一区二区a毛片| 成人午夜电影网站| 久久综合99re88久久爱| 热久久国产精品| 欧美日韩中文字幕一区二区| 国产精品福利在线播放| 国产福利一区二区三区| 精品少妇一区二区三区视频免付费| 亚洲妇熟xx妇色黄| 欧美优质美女网站| 一区二区三区在线视频免费观看| 国产99精品在线观看| 国产夜色精品一区二区av| 久久99精品网久久| 日韩欧美高清一区| 国内精品国产成人国产三级粉色| 日韩欧美亚洲一区二区| 日韩av在线播放中文字幕| 在线不卡中文字幕播放| 亚洲国产视频a| 欧美日韩国产美| 天天亚洲美女在线视频| 欧美剧在线免费观看网站| 亚洲成人av一区二区| 7799精品视频| 久久精品噜噜噜成人88aⅴ| 日韩精品一区二区三区蜜臀| 久久成人羞羞网站| 国产日韩v精品一区二区| 成人动漫在线一区| 亚洲精品久久嫩草网站秘色| 色狠狠色狠狠综合| 日韩电影一区二区三区四区| 欧美一区二区福利视频| 精品一区二区免费看| 国产欧美一区二区三区鸳鸯浴 | 久久国产尿小便嘘嘘尿| 日韩精品一区二区三区四区| 韩国成人福利片在线播放| 国产亚洲一区二区三区四区 | 欧美成人伊人久久综合网| 精品一区二区三区在线观看国产| 久久日一线二线三线suv| 粉嫩久久99精品久久久久久夜| 最新热久久免费视频| 欧美日韩久久久| 激情都市一区二区| 亚洲欧美成人一区二区三区| 91超碰这里只有精品国产| 国产99久久久国产精品免费看| 亚洲色图欧美在线| 日韩手机在线导航| 91在线视频在线| 久久97超碰色| 亚洲黄色在线视频| 欧美精品一区二| 色一情一伦一子一伦一区| 蜜臀av一区二区在线免费观看 | 麻豆国产精品官网| 国产精品美女视频| 91精品国产手机| 成人avav影音| 秋霞影院一区二区| 一区视频在线播放| 精品国产一区二区三区四区四| 91麻豆免费观看| 精品在线免费观看| 亚洲h动漫在线| 国产精品第五页| 欧美xxxx老人做受| 欧美日韩精品是欧美日韩精品| 国产99一区视频免费| 日韩电影免费在线看| 亚洲日韩欧美一区二区在线| 久久先锋影音av鲁色资源| 欧美日韩中字一区| 色婷婷综合在线| 成人小视频在线观看| 蜜桃一区二区三区在线| 亚洲综合网站在线观看| 国产精品久久久久久久浪潮网站| 日韩一区二区在线看片| 在线精品视频免费观看| 97se亚洲国产综合在线| 国产精品主播直播| 久久精品理论片| 蜜臀a∨国产成人精品| 性做久久久久久久免费看| 一区二区三区精品| 亚洲欧美偷拍三级| 国产精品欧美精品| 中文成人综合网| 欧美激情一区在线观看| 久久婷婷色综合| 精品国产免费视频| 日韩欧美国产一区二区三区| 91精品国产91久久综合桃花| 欧美喷潮久久久xxxxx| 欧美视频一区二区| 欧美精品777| 在线成人av网站| 日韩一区二区免费电影| 日韩一区二区精品在线观看| 欧美日韩亚洲高清一区二区| 欧美在线高清视频| 欧美日韩一级黄| 在线播放国产精品二区一二区四区| 色婷婷国产精品| 欧美日韩中文一区| 制服丝袜中文字幕亚洲| 欧美一卡2卡3卡4卡| 欧美一区二区国产| 久久理论电影网| 欧美高清在线一区| 亚洲欧洲综合另类| 亚洲国产精品自拍| 日本sm残虐另类| 国产一区二区在线影院| 国产999精品久久久久久绿帽| 成人激情校园春色| 日本精品一区二区三区四区的功能| 91年精品国产| 欧美日韩国产成人在线免费| 91超碰这里只有精品国产| 久久久久久一级片| 最好看的中文字幕久久| 亚洲精品一二三四区| 青青草成人在线观看| 国产精品综合久久| 日本高清不卡在线观看| 欧美日韩国产精选| 国产片一区二区三区| 亚洲久草在线视频| 麻豆精品精品国产自在97香蕉| 国产精品资源在线看| 欧美中文字幕一二三区视频| 日韩久久久久久| 国产精品亲子乱子伦xxxx裸| 亚洲成人高清在线| 国产不卡视频一区| 91福利精品第一导航| 欧美xfplay| 亚洲综合精品久久| 国产在线国偷精品免费看| 91精品福利视频| 久久久另类综合| 午夜精品视频在线观看| 国产不卡视频一区| 7777精品久久久大香线蕉| 中文字幕欧美国产| 蜜臀av性久久久久av蜜臀妖精 | 波多野结衣中文一区| 欧美巨大另类极品videosbest | 国内精品久久久久影院一蜜桃| 日本韩国精品一区二区在线观看| 日韩精品一区二区三区在线播放| 亚洲欧美日韩一区二区 | 天天亚洲美女在线视频| 顶级嫩模精品视频在线看| 日韩午夜电影av| 亚洲影院久久精品| 91亚洲永久精品| 国产日韩av一区二区| 狠狠色狠狠色合久久伊人| 欧美高清视频不卡网| 中文字幕一区二区三区视频| 国内精品视频一区二区三区八戒| 欧美三级欧美一级| 亚洲欧美日本韩国| 丰满亚洲少妇av| 精品国产sm最大网站| 天天亚洲美女在线视频| 在线日韩国产精品| 亚洲美女精品一区| 99精品视频在线播放观看| 久久久久久久久久美女| 免费成人av在线| 欧美精品在线观看播放| 午夜久久久久久久久久一区二区| 日本道在线观看一区二区| 国产精品网站一区| 国产99一区视频免费| 国产欧美在线观看一区| 国产精品一线二线三线精华| 26uuu国产电影一区二区| 精一区二区三区| www国产精品av| 国产乱国产乱300精品| 久久精品视频一区|