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

📄 wtl for mfc programmers, part iii.mht

📁 大家知道wtl是window UI库
💻 MHT
📖 第 1 页 / 共 5 页
字号:
                <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/wtl4mfc3.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%2Fwtl4mfc3%2Easp&amp;guid=3DWTL4MFC3%2Fwtl4%2F12%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=
FC3%2Fwtl4%2F12%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=
l4mfc3.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=
l4mfc3.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>
            <SCRIPT language=3Djavascript=20
            =
src=3D"http://media.adcentriconline.com/adcentric/tag/618/685/6791">
</SCRIPT>
            <NOSCRIPT><A=20
            =
href=3D"http://media.adcentriconline.com/adcentric/click/618/685/6791"><I=
MG=20
            src=3D"" border=3D0></A>=20
    </NOSCRIPT><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>44 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=3D15 border=3D0><IMG height=3D5=20
                        =
src=3D"http://www.codeproject.com/script/images/white.gif"=20
                        width=3D5 =
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.75</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/WTL4MFC3/WTL4MFC3_demo.zip">Downlo=
ad=20
        demo project - 60 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/wtl4mfc3.asp#intro">Introduction</=
A>=20

        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#barsinframe">Toolbars=
=20
        and Status Bars in a Frame</A>=20
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#appwiztb">AppWizard=20
        Code for Toolbars and Status Bars</A>=20
        <UL>
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#createbars">How=20
          CMainFrame creates the bars</A>=20
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#barsshowhide">Showing=
=20
          and hiding the bars</A>=20
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#builtins">Built-in=20
          features of the bars</A>=20
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#diffstyles">Creating =

          a toolbar with a different style</A> </LI></UL>
        <LI><A =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#tbeditor">The=20
        Toolbar Editor</A>=20
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#uiudpatebtns">UI=20
        Updating Toolbar Buttons</A>=20
        <UL>
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#enabletbupdate">Enabl=
ing=20
          toolbar UI updating</A> </LI></UL>
        <LI><A =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#userebar">Using=20
        a Rebar Instead of a Plain Toolbar</A>=20
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#multipanesb">Multi-Pa=
ne=20
        Status Bars</A>=20
        <UL>
          <LI><A=20
          =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#uiupdatesb">UI=20
          updating the panes</A> </LI></UL>
        <LI><A =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#upnext">Up=20
        Next: All About Dialogs</A>=20
        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#references">Reference=
s</A>=20

        <LI><A=20
        =
href=3D"http://www.codeproject.com/wtl/wtl4mfc3.asp#revisionhistory">Revi=
sion=20
        History</A> </LI></UL>
      <H2><A name=3Dintro></A>Introduction to Part III</H2>
      <P>Ever since they were made into common controls in Windows 95, =
toolbars=20
      and status bars have become commonplace. MFC's support for =
multiple=20
      floating toolbars also helped their popularity. In later common =
controls=20
      updates, rebars (or coolbars as they were originally called) added =
another=20
      way to present toolbars. In Part III, I will cover how WTL =
supports these=20
      kinds of control bars and how to use them in your own apps.</P>
      <H2><A name=3Dbarsinframe></A>Toolbars and Status Bars in a =
Frame</H2>
      <P><CODE>CFrameWindowImpl</CODE> has three <CODE>HWND</CODE> =
members that=20
      are set when the frame window is created. We've already seen=20
      <CODE>m_hWndClient</CODE>, which is the handle of the "view" =
window in the=20
      frame's client area. Now we'll encounter two others:</P>
      <UL>
        <LI><CODE>m_hWndToolBar</CODE>: <CODE>HWND</CODE> of the toolbar =
or=20
        rebar=20
        <LI><CODE>m_hWndStatusBar</CODE>: <CODE>HWND</CODE> of the =
status bar=20
        </LI></UL>
      <P><CODE>CFrameWindowImpl</CODE> only supports one toolbar, and =
there is=20
      no equivalent to the MFC system of multiple dockable toolbars. If =
you need=20
      more than one toolbar, and don't want to hack around in=20
      <CODE>CFrameWindowImpl</CODE> internals, then you will need to use =
a=20
      rebar. I will cover both of these options and show how to select =
from them=20
      in the AppWizard.</P>
      <P>The <CODE>CFrameWindowImpl::OnSize()</CODE> handler calls=20
      <CODE>UpdateLayout()</CODE>, which does two things: position the =
bars, and=20
      resize the view window to fill the client area.=20
      <CODE>UpdateLayout()</CODE> calls =
<CODE>UpdateBarsPosition()</CODE> which=20
      does the actual work. The code is quite simple, it just sends a=20
      <CODE>WM_SIZE</CODE> message to the toolbar and status bar, if =
those bars=20
      have been created. The bars' default window procedures take care =
of moving=20
      the bars to the top or bottom of the frame window.</P>
      <P>When you tell the AppWizard to give your frame a toolbar and =
status=20
      bar, the wizard puts code to create the bars in=20
      <CODE>CMainFrame::OnCreate()</CODE>. Let's take a closer look at =
that code=20
      now, as we write yet another clock app.</P>
      <H2><A name=3Dappwiztb></A>AppWizard Code for Toolbars and Status =
Bars</H2>
      <P>We'll start a new project and have the wizard create a toolbar =
and=20
      status bar for our frame. Start a new WTL project called =
WTLClock2. On the=20
      first AppWizard page, choose an SDI app and check <I>Generate CPP=20
      files</I>:</P>
      <P><IMG height=3D387 alt=3D" [AppWizard pg 1 - 22K] "=20
      src=3D"http://www.codeproject.com/wtl/WTL4MFC3/appwiz1.png" =
width=3D477=20
      align=3Dbottom border=3D0></P>

⌨️ 快捷键说明

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