⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wtl for mfc programmers, part v.mht

📁 大家知道wtl是window UI库
💻 MHT
📖 第 1 页 / 共 5 页
字号:
                  =
src=3D"http://www.codeproject.com/script/images/support_icon.gif"=20
                  width=3D16></TD>
                <TD class=3DsmallText><A=20
                  href=3D"http://www.codeproject.com/store/"><B>VS.NET =
2003 from=20
                  $899</B></A></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  =
src=3D"http://www.codeproject.com/script/images/support_icon.gif"=20
                  width=3D16></TD>
                <TD class=3DsmallText><A=20
                  href=3D"http://www.codeproject.com/store/"><B>MSDN =
Univ. from=20
                  $1950</B></A></TD></TR>
              <TR vAlign=3Dtop>
                <TD></TD>
                <TD></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  src=3D"http://www.codeproject.com/images/print.gif" =
width=3D16></TD>
                <TD class=3DsmallText><A=20
                  =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp?print=3Dtrue"=20
                  target=3D_print>Print version</A></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  src=3D"http://www.codeproject.com/images/link.gif" =
width=3D16></TD>
                <TD class=3DsmallText><A=20
                  =
href=3D"http://www.codeproject.com/script/profile/add_bookmark.asp?t=3D0&=
amp;ct=3D%2Fwtl%2Fwtl4mfc5%2Easp&amp;guid=3DWTL4MFC5%2Fwtl4%2F27%2F2003">=
Bookmark=20
                  this</A></TD></TR></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  src=3D"http://www.codeproject.com/images/mail.gif" =
width=3D16></TD>
                <TD class=3DSmallText><A=20
                  =
href=3D"http://www.codeproject.com/script/recommend/form.asp?guid=3DWTL4M=
FC5%2Fwtl4%2F27%2F2003">Send=20
                  to a friend</A></TD></TR>
              <TR vAlign=3Dtop>
                <TD></TD>
                <TD></TD></TR>
              <TR vAlign=3Dtop>
                <TD></TD>
                <TD class=3DInfoBarHeader>My Profile</TD></TR>
              <TR>
                <TD bgColor=3Dblack colSpan=3D2><IMG height=3D1=20
                  src=3D"http://www.codeproject.com/images/space.gif"=20
              width=3D1></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  =
src=3D"http://www.codeproject.com/images/profile_small.gif"=20
                  width=3D16></TD>
                <TD class=3DsmallText><A=20
                  =
href=3D"http://www.codeproject.com/script/profile/modify.asp?ct=3D/wtl/wt=
l4mfc5.asp">My=20
                  Settings</A></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  =
src=3D"http://www.codeproject.com/images/submit_small.gif"=20
                  width=3D16></TD>
                <TD class=3DsmallText><A=20
                  =
href=3D"http://www.codeproject.com/script/articles/list_articles.asp?user=
id=3D273403">My=20
                  Articles</A></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  =
src=3D"http://www.codeproject.com/images/bookmarks.gif"=20
                width=3D16></TD>
                <TD class=3DsmallText><A=20
                  =
href=3D"http://www.codeproject.com/script/profile/bookmark_list.asp">My=20
                  Bookmarks</A></TD></TR>
              <TR vAlign=3Dtop>
                <TD><IMG height=3D16=20
                  =
src=3D"http://www.codeproject.com/images/logoff_small.gif"=20
                  width=3D16></TD>
                <TD class=3DsmallText><A=20
                  =
href=3D"http://www.codeproject.com/script/profile/logoff.asp?ct=3D/wtl/wt=
l4mfc5.asp">Sign=20
                  out</A></TD></TR>
              <TR>
                <TD bgColor=3Dblack colSpan=3D2><IMG height=3D1=20
                  src=3D"http://www.codeproject.com/images/space.gif"=20
              width=3D1></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD>&nbsp;</TD></TR>
        <TR>
          <TD>
            <CENTER><A=20
            =
href=3D"http://www.codeproject.com/script/admentor/admentorredir.asp?id=3D=
407&amp;way=3Dban"=20
            target=3D_blank><IMG height=3D600 alt=3D"SAMS Publishing"=20
            =
src=3D"http://www.codeproject.com/script/admentor/images/SAMS_SkyScraperA=
SPNET.gif"=20
            width=3D120 =
border=3D0></A><BR></CENTER><BR></TD></TR></TBODY></TABLE></TD>
    <TD width=3D5 rowSpan=3D2><IMG height=3D1=20
      src=3D"http://www.codeproject.com/images/space.gif" width=3D5> =
</TD>
    <TD align=3Dright width=3D"100%" bgColor=3Dwhite>
      <TABLE width=3D"100%">
        <TBODY>
        <TR>
          <TD class=3DsmallText vAlign=3Dtop noWrap></TD>
          <TD noWrap align=3Dright><A name=3D__top></A>
            <TABLE>
              <TBODY>
              <TR>
                <TD class=3DsmallText align=3Dright>39 members have =
rated this=20
                  article. Result:</TD>
                <TD>
                  <TABLE cellSpacing=3D0 cellPadding=3D0 border=3D2>
                    <TBODY>
                    <TR>
                      <TD><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/red.gif"=20
                        width=3D20 border=3D0></TD>
                      <TD><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/red.gif"=20
                        width=3D20 border=3D0></TD>
                      <TD><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/red.gif"=20
                        width=3D20 border=3D0></TD>
                      <TD><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/red.gif"=20
                        width=3D20 border=3D0></TD>
                      <TD><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/red.gif"=20
                        width=3D18 border=3D0><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/white.gif"=20
                        width=3D2 =
border=3D0></TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD class=3DsmallText align=3Dright colSpan=3D2><A=20
                  title=3D"Calculated as rating x Log10(# votes)"=20
                  =
href=3D"http://www.codeproject.com/script/articles/top_articles.asp?st=3D=
2">Popularity:=20
                  7.81</A>. Rating: <B>4.91</B> out of=20
        5.</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD vAlign=3Dtop width=3D"100%">
      <DIV id=3Dcontentdiv><!-- Article Starts -->
      <UL class=3Ddownload>
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/WTL4MFC5/WTL4MFC5_demo.zip">Downlo=
ad=20
        demo project - 81 KB</A> </LI></UL><!-- Add the rest of your =
HTML here -->
      <H2>Contents</H2>
      <UL>
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#intro">Introduction =
to=20
        Part V</A>=20
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#specialized">Speciali=
zed=20
        Owner Draw and Custom Draw Classes</A>=20
        <UL>
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#cownerdraw">COwnerDra=
w</A>=20

          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#ccustomdraw">CCustomD=
raw</A>=20
          </LI></UL>
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#newwtlctrls">New WTL =

        Controls</A>=20
        <UL>
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#newcbitmapbutton">CBi=
tmapButton</A>=20

          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#cchecklist">CCheckLis=
tViewCtrl</A>=20

          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#treeex">CTreeViewCtrl=
Ex=20
          and CTreeItem</A>=20
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#chyperlink">CHyperLin=
k</A>=20
          </LI></UL>
        <LI><A =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#uiupdctrl">UI=20
        Updating Dialog Controls</A>=20
        <LI><A =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#ddv">DDV</A>=20
        <UL>
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#ddvfail">Handling=20
          DDV failures</A> </LI></UL>
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#resizing">Resizing=20
        Dialogs</A>=20
        <LI><A =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#upnext">Up=20
        Next</A>=20
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#references">Reference=
s</A>=20

        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#revisionhistory">Revi=
sion=20
        History</A> </LI></UL>
      <H2><A name=3Dintro></A>Introduction to Part V</H2>
      <P>In the last article, we saw some of WTL's features relating to =
dialogs=20
      and controls that worked like the corresponding MFC classes. In =
this one,=20
      we'll cover some new WTL classes that implement some more advanced =
UI=20
      features: Owner draw and custom draw, new WTL controls, UI =
updating, and=20
      dialog data validation (DDV).</P>
      <H2><A name=3Dspecialized></A>Specialized Owner Draw and Custom =
Draw=20
      Classes</H2>
      <P>Since owner drawn and custom drawn controls are so common in =
GUI work,=20
      WTL provides mix-in classes that handle some of the grunt work. =
We'll=20
      cover each of them next, as we start on the sequel to the last =
sample=20
      project, ControlMania2. If you are following along by creating a =
project=20
      with the AppWizard, be sure to make this dialog modeless. It has =
to be=20
      modeless in order for UI updating to work properly. I'll give more =
details=20
      on this in the <A=20
      =
href=3D"http://www.codeproject.com/wtl/wtl4mfc5.asp#uiupdctrl">section =
on UI=20
      updating</A>.</P>
      <H3><A name=3Dcownerdraw></A>COwnerDraw</H3>
      <P>Owner drawing involves handling up to four messages:=20
      <CODE>WM_MEASUREITEM</CODE>, <CODE>WM_DRAWITEM</CODE>,=20
      <CODE>WM_COMPAREITEM</CODE>, and <CODE>WM_DELETEITEM</CODE>. The=20
      <CODE>COwnerDraw</CODE> class, defined in atlframe.h, simplifies =
your code=20
      since you don't need messages handlers for all those messages. =
Instead,=20
      you chain messages to <CODE>COwnerDraw</CODE>, and it calls =
overridable=20
      functions that you implement in your class.</P>
      <P>How you chain messages depends on whether you are reflecting =
messages=20
      to the control or not. Here is the <CODE>COwnerDraw</CODE> message =
map,=20
      which will make the distinction clear:</P><PRE><SPAN =
class=3Dcpp-keyword>template</SPAN> &lt;<SPAN =
class=3Dcpp-keyword>class</SPAN> T&gt; <SPAN =
class=3Dcpp-keyword>class</SPAN> COwnerDraw
{
<SPAN class=3Dcpp-keyword>public</SPAN>:
  BEGIN_MSG_MAP(COwnerDraw&lt;T&gt;)
    MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
    MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
    MESSAGE_HANDLER(WM_COMPAREITEM, OnCompareItem)
    MESSAGE_HANDLER(WM_DELETEITEM, OnDeleteItem)
  ALT_MSG_MAP(<SPAN class=3Dcpp-literal>1</SPAN>)
    MESSAGE_HANDLER(OCM_DRAWITEM, OnDrawItem)
    MESSAGE_HANDLER(OCM_MEASUREITEM, OnMeasureItem)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -