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

📄 078-080.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<td rowspan="8" align="right" valign="top"><img src="/images/iswbls.gif" width=1 height=400 alt="" border="0"></td>
<td><img src="/images/white.gif" width="5" height="1" alt="" border="0"></td>
<!-- end of ITK left NAV -->

<!-- begin main content -->
<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=078-080//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="075-078.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="080-083.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading6"></A><FONT COLOR="#000077">Inserting a Menu into a Command Bar</FONT></H3>
<P>An application adds a menu to a command bar with the function <I>CommandBar_InsertMenubar</I>. After all the caveats about how Windows CE does not support menu bars, the command bar API still thinks it is inserting a menu bar. In any of its incarnations, consistency in function naming has never been a strong point with Windows.</P>
<P><I>CommandBar_InsertMenubar</I> takes four parameters:</P>
<!-- CODE SNIP //-->
<PRE>
    CommandBar_InsertMenubar(hwndCB, hInst, idMenu, iButton);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hwndCB</I> is the HWND of the command bar into which the menu is inserted. <I>hInst</I> is the application instance. <I>idMenu</I> is the resource identifier of the menu to insert.</P>
<P><I>iButton</I> identifies where in the command bar the menu is to be inserted. A command bar can contain buttons and command bars as well as a menu. <I>iButton</I> is the zero-based index of the control to the left of which the menu is inserted. Since controls are typically inserted into command bars after the menu, <I>iButton</I> for menus is typically zero, putting the menu at the very left of the command bar.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B><B>M<SMALL>AKING</SMALL> S<SMALL>ENSE OF <I>I</SMALL>B<SMALL>UTTON</SMALL></I></B>
<P><B>iButton is best thought of as the position index of a control in a command bar. In the example shown in Figure 4.1, the menu has index 0, the combo box index 1, and so forth.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><I>CommandBar_InsertMenubar</I> internally loads the menu resource corresponding to <I>idMenu</I> from the module identified by <I>hInstance</I>. <I>CommandBar_InsertMenubar</I> returns TRUE if successful. Otherwise it returns FALSE.</P>
<P>An alternative way to insert a menu into a command bar is with <I>CommandBar_InsertMenubarEx</I>. This function is exactly the same as <I>CommandBar_InsertMenubar</I>, except that the third parameter is not a menu resource identifier. Instead, this parameter can be passed the menu resource name, or a menu handle.</P>
<P>Here&#146;s an example of how you might insert a menu into a command bar. In this example, IDR_MENU is the resource identifier of a menu resource, defined in the file RESOURCE.H:</P>
<!-- CODE //-->
<PRE>
  #define IDCB_MAIN   0  //Command bar control command ID
  int WINAPI WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)
  &#123;
    HWND hwndCB;  //Command bar window
    HWND hwndMain; //Main application window
    /* Register main window class and create main window here
    ... */
    /* Create the command bar control */
    hwndCB = CommandBar_Create(hInstance, hwndMain, IDCB_MAIN);
    /* Insert the menu into the command bar */
    if (hwndCB)
    &#123;
     CommandBar_InsertMenubar(hwndCB, hInstance,IDR_MENU,0);
    &#125;
    /* The rest of the WinMain code here
    ... */
  &#125;
</PRE>
<!-- END CODE //-->
<H3><A NAME="Heading7"></A><FONT COLOR="#000077">Adding Controls to a Command Bar</FONT></H3>
<P>The example in Figure 4.1 shows a command bar with a menu as well as a combo box and a set of buttons. Also, at the right of the command bar you can see a small Close button and Help button. How did the Windows CE child controls get there?
</P>
<P>This section presents the command bar API functions that are used to insert controls into the command bar. It also describes how to add adornments, the Close, Help, and OK buttons that often appear in command bars. Adding tool tips to command bar buttons is also described.</P>
<P>As a quick reference, Table 4.1 lists these functions and their use.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 4.1</B> Command Bar Functions for Adding Controls and Adornments
<TR>
<TH WIDTH="40%" ALIGN="LEFT">FUNCTION
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD>CommandBar_AddAdornments
<TD>Used to add OK, Close, and/or Help buttons to a command bar.
<TR>
<TD>CommandBar_AddBitmap
<TD>Adds images to a command bar to use with command bar buttons.
<TR>
<TD>CommandBar_AddButtons
<TD>Inserts one or more buttons (not adornments) to a command bar.
<TR>
<TD VALIGN="TOP">CommandBar_AddTooltips
<TD>Inserts tool tip strings into a command bar for use with command bar buttons.
<TR>
<TD>CommandBar_InsertButton
<TD>Inserts a single button into a command bar.
<TR>
<TD>CommandBar_InsertComboBox
<TD>Inserts a combo box into a command bar.
</TABLE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="075-078.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="080-083.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 + -