?? 099-104.html
字號:
<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=""> <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=099-104//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="097-099.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch05/105-109.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><I>uFlags</I> must be either MF_BYCOMMAND or MF_BYPOSITION, combined with at least one of the values in Table 4.8. MF_BYCOMMAND means that <I>uPosition</I> gives the identifier of the menu item to be inserted. MF_BYPOSITION says that <I>uPosition</I> is the zero-based index of the new item. MF_BYCOMMAND is the default.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 4.8</B> InsertMenu Flags
<TR>
<TH WIDTH="35%" ALIGN="LEFT">FLAG
<TH WIDTH="65%" ALIGN="LEFT">MEANING
<TR>
<TD>MF_CHECKED
<TD>Draws a check mark to the left of the menu item text.
<TR>
<TD VALIGN="TOP">MF_ENABLED
<TD>Enabled the menu item. Item can be selected and the item text is not grayed.
<TR>
<TD>MF_GRAYED
<TD>Disables the menu item and grays the item text.
<TR>
<TD>MF_MENUBREAK
<TD>Places the item in a new column.
<TR>
<TD VALIGN="TOP">MF_MENUBARBREAK
<TD>Same as MF_MENUBREAK , except columns are separated by a vertical line.
<TR>
<TD>MF_OWNERDRAW
<TD>Specifies the menu item as owner draw.
<TR>
<TD>MF_POPUP
<TD>Indicates that the menu item is a submenu.
<TR>
<TD>MF_SEPARATOR
<TD>The item inserted is a horizontal menu item separator.
<TR>
<TD>MF_STRING
<TD>Indicates that the lpNewItem parameter is a string.
<TR>
<TD VALIGN="TOP">MF_UNCHECKED
<TD>Opposite of MF_CHECKED, i.e., a check mark is not drawn next to the item text. This flag is set by default.
</TABLE>
<P><I>uIDNewItem</I> indicates the command identifier of the new menu item. If <I>uFlags</I> includes the MF_POPUP flag, <I>uIDNewItem</I> is the menu handle of the menu or submenu to be inserted.</P>
<P><I>lpNewItem</I> specifies the contents of the new menu item. Generally <I>lpNewItem</I> points to a null-terminated Unicode string used as the menu item text. This parameter can also contain information for drawing owner draw menu items. But as we are not covering owner draw menus in this book, we don’t discuss this.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B><B>I<SMALL>NSERT</SMALL>M<SMALL>ENU</SMALL>I<SMALL>TEM</SMALL></B>
<P><B>The function <I>InsertMenuItem</I> is not supported under Windows CE.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B><I>Enabling and Disabling Menu Items</I></B></FONT></P>
<P>We have described the pop-up menus that were added to the CMDBAR application as context-specific. That means that the particular pop-up menu that is displayed depends on the state of the application at the time the menu is displayed.
</P>
<P>Individual menu items can also be displayed differently depending on the state of an application. For example, a word processor typically grays out the Cut and Copy menu items in the Edit menu if no text is selected in a document. But when text is selected, those menu items become enabled.</P>
<P>The CMDBAR.EXE application pop-up menus have a Revert To White menu item that is only enabled when the main window background is not already painted white. Menu items are enabled or disabled with the <I>EnableMenuItem</I> function:</P>
<!-- CODE SNIP //-->
<PRE>
EnableMenuItem(hMenu, uIDEnableItem, uEnable);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hMenu</I> is the menu handle of the menu or submenu that contains the item to disable or enable.</P>
<P><I>uEnable</I> is similar to the <I>uFlags</I> parameter of the <I>InsertMenu</I> function. It is a combination of one of the flags MF_COMMAND or MF_BYPOSITION, and one of the flags MF_GRAYED or MF_ENABLED. These flags have the same meanings as in the <I>InsertMenu</I> function.</P>
<P><I>uIDEnableItem</I> indicates which menu item to enable or disable. As with the <I>uFlags</I> parameter of <I>InsertMenu</I>, <I>uIDEnableItem</I> specifies the command identifier of the menu item if <I>uEnable</I> includes the MF_COMMAND flag. If <I>uEnable</I> instead contains MF_BYPOSITION, <I>uIDEnableItem</I> is the zero-based index of the menu item to enable or disable.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B><B>MF_DISABLED N<SMALL>OT</SMALL> S<SMALL>UPPORTED</SMALL></B>
<P><B>Under Windows CE, the menu flag MF_DISABLED is not supported. To disable menu items using functions like <I>InsertMenu</I> and <I>EnableMenuItem</I>, applications must use the MF_GRAYED flag.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B>The Complete Windows CE Menu API</B></FONT></P>
<P>The Windows CE menu API includes many more functions than those few detailed above. However, their usage is generally similar to those functions which we have discussed in detail.
</P>
<P>Table 4.9 can be used as a quick reference for the menu operations provided by the operating system. Now that you have a good understanding of Windows CE menu basics, understanding how to use these functions when needed should be straightforward with the help of the Windows CE on-line documentation.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 4.9</B> The Windows CE Menu Functions
<TR>
<TH WIDTH="35%" ALIGN="LEFT">FUNCTION
<TH WIDTH="65%" ALIGN="LEFT">MEANING
<TR>
<TD>AppendMenu
<TD>Inserts a new menu item at the end of the specified menu.
<TR>
<TD>CheckMenuItem
<TD>Used to add or remove a check mark from a menu item.
<TR>
<TD VALIGN="TOP">CheckMenuRadioItem
<TD>Draws a bullet next to the specified menu item and removes any previously drawn bullets from all other items in the menu item group.
<TR>
<TD>CreateMenu
<TD>Creates an empty menu.
<TR>
<TD>CreatePopupMenu
<TD>Creates an empty pop-up menu.
<TR>
<TD>DeleteMenu
<TD>Deletes an item from the specified menu.
<TR>
<TD VALIGN="TOP">DestroyMenu
<TD>Destroys the specified menu and frees any memory used by the menu resource. The menu analogue of DestroyWindow.
<TR>
<TD VALIGN="TOP">DrawMenuBar
<TD>Redraws the menu in the specified window. The window is a command bar window.
<TR>
<TD>EnableMenuItem
<TD>Enables or disables the specified menu item.
<TR>
<TD VALIGN="TOP">GetMenuItemInfo
<TD>Gets information about the specified menu item in the form of a MENUITEMINFO structure.
<TR>
<TD>GetSubMenu
<TD>Gets a handle to the specified submenu.
<TR>
<TD VALIGN="TOP">GetSystemMenu
<TD>Gets a handle to the window menu (system menu) in the specified window.
<TR>
<TD>InsertMenu
<TD>Inserts a new menu item into the specified menu.
<TR>
<TD>LoadMenu
<TD>Loads the specified menu resource.
<TR>
<TD>RemoveMenu
<TD>Deletes a menu item from the specified menu.
<TR>
<TD>SetMenuItemInfo
<TD>Changes menu item information.
<TR>
<TD>TrackPopupMenu
<TD>Displays a pop-up menu and tracks user selections.
<TR>
<TD VALIGN="TOP">TrackPopupMenuEx
<TD>Similar to TrackPopupMenu, but passes the exclusion RECT in a TPMPARAMS structure instead of as an individual LPRECT.
<H3><A NAME="Heading13"></A><FONT COLOR="#000077">The Complete CMDBAR Sample Application</FONT></H3>
<P>All of the concepts presented in this chapter are pulled together in the sample application, CMDBAR.EXE. Complete source code for this application is included on the companion CD under the directory \Samples\cmdbar. The command bar button bitmap file and all of the project files needed to build the application are included there as well.
</P>
<H3><A NAME="Heading14"></A><FONT COLOR="#000077">Concluding Remarks</FONT></H3>
<P>In this chapter, we discussed how to add menus and accelerators to Windows CE applications. We introduced the Windows CE command bar control, and showed how menus, controls, and tool tips can be added to command bars. This chapter also presented the Windows CE menu API.
</P>
<P>At this point, you should be able to write some fairly complex applications that include menus, modal and modeless dialogs, and the standard Windows CE child controls. In the next chapter, we will explore programming the Windows CE common control library in greater detail. You will then be able to add even more rich features, such as calendar functionality, to your applications very easily.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="097-099.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch05/105-109.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> | <a href="/contactus.html"><font color="#006666">Contact Us</font></a> | <a href="/aboutus.html"><font color="#006666">About Us</font></a> | <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> | <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> | <a href="/"><font color="#006666">Home</font></a></b>
<br><br>
Use of this site is subject to certain <a href="/agreement.html">Terms & Conditions</a>, <a href="/copyright.html">Copyright © 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 + -