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

📄 083-087.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<td width="100%" valign="top" align="left">


<!-- END SUB HEADER -->

<!--Begin Content Column -->

<FONT FACE="Arial,Helvetica" SIZE="-1">
To access the contents, click the chapter and section titles.
</FONT>
<P>
<B>Essential Windows CE Application Programming</B>
<FONT SIZE="-1">
<BR>
<I>(Publisher: John Wiley & Sons, Inc.)</I>
<BR>
Author(s): Robert Burdick
<BR>
ISBN: 0471327476
<BR>
Publication Date: 03/01/99
</FONT>
<P>
<form name="Search" method="GET" action="http://search.earthweb.com/search97/search_redir.cgi">

<INPUT TYPE="hidden" NAME="Action" VALUE="Search">
<INPUT TYPE="hidden" NAME="SearchPage" VALUE="http://search.earthweb.com/search97/samples/forms/srchdemo.htm">
<INPUT TYPE="hidden" NAME="Collection" VALUE="ITK">
<INPUT TYPE="hidden" NAME="ResultTemplate" VALUE="itk-simple-intrabook.hts">
<INPUT TYPE="hidden" NAME="ViewTemplate" VALUE="view.hts">

<font face="arial, helvetica" size=2><b>Search this book:</b></font><br>
<INPUT NAME="queryText" size=50 VALUE="">&nbsp;<input type="submit" name="submitbutton" value="Go!">
<INPUT type=hidden NAME="section_on" VALUE="on">
<INPUT type=hidden NAME="section" VALUE="http://www.itknowledge.com/reference/standard/0471327476/">

</form>


<!-- Empty Reference Subhead -->

<!--ISBN=0471327476//-->
<!--TITLE=Essential Windows CE Application Programming//-->
<!--AUTHOR=Robert Burdick//-->
<!--PUBLISHER=John Wiley & Sons, Inc.//-->
<!--IMPRINT=Wiley Computer Publishing//-->
<!--CHAPTER=4//-->
<!--PAGES=083-087//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="080-083.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="087-090.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>The second parameter specifies the number of buttons to be added. <I>lpButtons</I> is a pointer to the array of TBBUTTON structures that define the command bar buttons.</P>
<P>Note that no matter how many buttons are added to a command bar control, only one bitmap resource is specified in the call to <I>CommandBar_AddBitmap</I>. Each command bar button bitmap is expected to be 16 by 16 pixels, and <I>iNumImages</I> specifies the number of such images. The <I>iBitmap</I> value in a given TBBUTTON description can then reliably identify which 16-by-16 bitmap to associate with the particular button.</P>
<P>When a button is added with <I>CommandBar_AddButtons</I> or <I>CommandBar_InsertButton</I>, the command bar looks at the <I>iBitmap</I> member of the button&#146;s TBBUTTON definition. If this value is 2, for example, the command bar uses the second 16-by-16 section of bits from the bitmap resource added to the control by the <I>CommandBar_AddBitmap</I> call as the button image.</P>
<P><FONT SIZE="+1"><B>Inserting Combo Boxes</B></FONT></P>
<P>Combo boxes can be inserted into command bar controls using the function <I>CommandBar_InsertComboBox</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBar_InsertComboBox(hwndCB, hInst, iWidth, dwStyle,
    idComboBox, iButton);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hwndCB</I> and <I>hInst</I> are the same as with the other command bar functions we&#146;ve seen. <I>iWidth</I> specifies the width, in pixels, of the combo box control to be inserted. <I>dwStyle</I> defines the style of the combo box. This value can be one or more of the styles used for other combo box controls. <I>idComboBox</I> is the control identifier of the combo box, and <I>iButton</I> specifies where to put the control.</P>
<P>If <I>CommandBar_InsertComboBox</I> is successful, it returns the HWND of the combo box that is created. If the function fails, the return value is NULL.</P>
<P>Applications interact with combo boxes in command bars just as they do with other combo box controls. All messages and notifications that are generated by a command bar combo box are sent to the command bar control&#146;s parent window. The application&#146;s main window procedure therefore handles these events in its WM_COMMAND handler.</P>
<P><FONT SIZE="+1"><B>Inserting Adornments</B></FONT></P>
<P>Adornments are the Help, OK, and Close buttons that are often found in command bars. The Help button is used as a standard way to invoke help features in an application. The Close button closes the window that contains the command bar. The OK button sends a WM_COMMAND message to the parent of the command bar. The control identifier sent with this message (i.e., the LOWORD of <I>wParam</I>) in this case is IDOK.</P>
<P>A command bar can include one or more adornment buttons. Any command bar that has adornments must have a Close button. You have no choice in this, and Windows CE will add it for you automatically. The Help and OK buttons can be specified optionally.</P>
<P>The function for doing all of this is <I>CommandBar_AddAdornments</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBar_AddAdornments(hwndCB, dwFlags, dwReserved);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hwndCB</I> identifies the command bar, and <I>dwReserved</I> is reserved and must be set to zero.</P>
<P>That leaves the <I>dwFlags</I> parameter. This parameter is used to specify which optional adornment buttons to add to the command bar. This parameter can be CMDBAR_HELP, CMDBAR_OK, or both. CMDBAR_HELP adds the Help button, and CMDBAR_OK adds the OK button.</P>
<P>As an example, here&#146;s how an application would add the Help and OK buttons to a command bar with an HWND identified by <I>hwndMyCB</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBar_AddAdornments(hwndMyCB,(CMDBAR_HELP|CMDBAR_OK), 0);
</PRE>
<!-- END CODE SNIP //-->
<P>If the function is successful, it returns TRUE. Otherwise it returns FALSE.
</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>C<SMALL>OMMAND</SMALL>B<SMALL>AR</SMALL>_A<SMALL>DD</SMALL>A<SMALL>DORNMENTS</SMALL> M<SMALL>UST</SMALL> B<SMALL>E</SMALL> L<SMALL>AST</SMALL>!</B>
<P><B>Any call to <I>CommandBar_AddAdornments</I> must come after all other functions that insert menus or controls into a particular command bar.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P>Table 4.4 summarizes the Windows CE messages generated when the various adornment buttons are pressed. These messages are sent to the command bar control&#146;s parent window.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 4.4</B> Adornment Button Messages
<TR>
<TH WIDTH="25%" ALIGN="LEFT">BUTTON
<TH WIDTH="75%" ALIGN="LEFT">MESSAGE GENERATED
<TR>
<TD>Help
<TD>WM_HELP
<TR>
<TD>OK
<TD>WM_COMMAND, with IDOK as the command identifier
<TR>
<TD>Close
<TD>WM_CLOSE
</TABLE>
<H3><A NAME="Heading8"></A><FONT COLOR="#000077">Adding Tool Tips to Command Bar Buttons</FONT></H3>
<P>Windows CE supports tool tips in command bar buttons (see Figure 4.4). A tool tip is a little pop-up window that is displayed when a user presses a command bar button and holds it down for more than half of a second. The tool tip contains an application-specified Unicode string that is used as a description of the command bar button. Tool tips are a good way to provide users of your Windows CE applications with a description of what action is performed by command bar buttons without taking up a lot of valuable screen space.
</P>
<P><A NAME="Fig4"></A><A HREF="javascript:displayWindow('images/04-04.jpg',479,46 )"><IMG SRC="images/04-04t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/04-04.jpg',479,46)"><FONT COLOR="#000077"><B>Figure 4.4</B></FONT></A>&nbsp;&nbsp;A command bar with Help, OK, and Close button adornments.</P>
<P>Tool tips are inserted with the function <I>CommandBar_AddToolTips</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBar_AddToolTips(hwndCB, uNumToolTips, lpToolTips);
</PRE>
<!-- END CODE SNIP //-->
<P><I>uNumToolTips</I> specifies the number of tool tip strings in <I>lpToolTips</I>. <I>lpToolTips</I> is an array of null-terminated Unicode strings. One of these strings is displayed for each command bar button.</P>
<P>This sounds pretty simple, but there is a catch. Windows CE does not allow tool tips for menus or combo boxes in command bars. However, it does assume that <I>lpToolTips</I> contains a string pointer for each item in the command bar. This is strange indeed. In order to add tool tips to two command bar buttons that come after a menu and combo box, <I>uNumToolTips</I> would have to be 4, and <I>lpToolTips</I> would have to contain two NULL pointers for the menu and combo box.</P>
<P>To be more specific, here&#146;s how the sample application for this chapter (shown in Figure 4.1) defines the tool tips it uses:</P>
<!-- CODE SNIP //-->
<PRE>
  TCHAR* pszTips[] = &#123;NULL,
    NULL,
    TEXT("Paint Window Black"),
    TEXT("Paint Window Dark Gray")&#125;;
</PRE>
<!-- END CODE SNIP //-->
<P>The first two string pointers are NULL. These correspond to the menu and combo box. The next two strings are the command bar button tool tip strings. If not defined this way, <I>CommandBar_AddToolTips</I> will produce unexpected results.</P>
<P>With this definition for <I>pszTips</I>, the application adds the tool tips with this function call:</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBar_AddToolTips(hwndCB, 4, pszTips);
</PRE>
<!-- END CODE SNIP //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="080-083.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="087-090.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- BEGIN SUB FOOTER -->
		<br><br>
		</TD>
    </TR>
	</TABLE>

		
	<table width="640" border=0 cellpadding=0 cellspacing=0>
		<tr>
		<td align="left" width=135><img src="/images/white.gif" width=100 height="1" alt="" border="0"></td>
		
		
<!-- END SUB FOOTER -->

<!-- all of the books have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- FOOTER -->
			
		<td width="515" align="left" bgcolor="#FFFFFF">
<font face="arial, helvetica" size="1"><b><a href="/products.html"><font color="#006666">Products</font></a>&nbsp;|&nbsp; <a href="/contactus.html"><font color="#006666">Contact Us</font></a>&nbsp;|&nbsp; <a href="/aboutus.html"><font color="#006666">About Us</font></a>&nbsp;|&nbsp; <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> &nbsp;|&nbsp; <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> &nbsp;|&nbsp; <a href="/"><font color="#006666">Home</font></a></b>
		<br><br>
		
		Use of this site is subject to certain <a href="/agreement.html">Terms &amp; Conditions</a>, <a href="/copyright.html">Copyright &copy; 1996-1999 EarthWeb Inc.</a><br> 
All rights reserved.  Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.</font><p>
</td>
		</tr>
</table>
</BODY>
</HTML>

<!-- END FOOTER -->

⌨️ 快捷键说明

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