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

📄 140-144.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!--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=5//-->
<!--PAGES=140-144//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="137-140.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch06/145-147.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B><I>Inserting Bands into Rebar Controls</I></B></FONT></P>
<P>Now that we understand how Windows CE represents bands, adding bands to a rebar control is straightforward.
</P>
<P>Bands are inserted by sending the message RB_INSERTBAND to the rebar control. The <I>wParam</I> of this message is a UINT specifying the zero-based index of the band. The <I>lParam</I> is a pointer to a REBARBANDINFO structure which contains all the characteristics of the band to be inserted.</P>
<P>For example, to create the band containing the Exit button shown in Figure 5.4, the application includes the following code. <I>hwndRebar</I> is the HWND of the rebar control created previously:</P>
<!-- CODE //-->
<PRE>
  HWND hwndExit;
  REBARBANDINFO rbbi;
  hwndExit = CreateWindow(TEXT("BUTTON"),
    TEXT("Exit"),...);
  memset(&rbbi, 0, sizeof(rbbi));
  rbbi.cbSize = sizeof(rbbi);
  rbbi.fMask = (RBBIM_CHILD|RBBIM_CHILDSIZE|
    RBBIM_STYLE|RBBIM_SIZE);
  rbbi.fStyle = (RBBS_GRIPPERALWAYS);
  rbbi.hwndChild = hwndExit;
  rbbi.cxMinChild = 30; //Band, button min width
  rbbi.cyMinChild = 65; //Band, button min height
  rbbi.cx = 100;     //Band width
  SendMessage(hwndRebar, RB_INSERTBAND,0, (LPARAM)&rbbi);
</PRE>
<!-- END CODE //-->
<P>The <I>fMask</I> member of <I>rbbi</I> indicates that the band will have a child control (RBBIM_CHILD) and that the <I>cxMinChild</I> and <I>cyMinChild</I> members of <I>rbbi</I> are valid (RBBIM_CHILDSIZE.) <I>rbbi.fStyle</I> is also valid, as indicated by the RBBIM_STYLE mask bit. RBBIM_SIZE indicates that the <I>cx</I> member of <I>rbbi</I> is used to specify the width of the band.</P>
<P>The <I>fStyle</I> member of <I>rbbi</I> specifies that the band to be inserted will always display a gripper bar.</P>
<P>The band will contain the &#147;Exit&#148; button because <I>rbbi.hwndChild</I> is set to the HWND of that button. The code goes on to specify that this button (and therefore the band) cannot be smaller than 30 pixels high and 65 pixels wide, and that the band will be 100 pixels wide.</P>
<P>That&#146;s all there is to it. With this brief introduction, and a quick look at the sample application to familiarize yourself with rebar control messages and notifications, you are well on your way to enhancing your Windows CE applications with rebar controls.</P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Command Bands</FONT></H3>
<P>A command band control is a fancy rebar control that can contain OK, Close, and Help buttons, called <I>adornments</I>, which rebar controls alone do not support (Figure 5.5). Like command bars, command bands can contain child controls (Figure 5.6). In addition, each band in a command band control contains a command bar control by default. This means that a programmer can use command bands to construct windows containing multiple menus (Figure 5.6). In the Windows CE control hierarchy, we can think of command band controls as a superset of command bar controls.</P>
<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/05-05.jpg',480,239 )"><IMG SRC="images/05-05t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/05-05.jpg',480,239)"><FONT COLOR="#000077"><B>Figure 5.5</B></FONT></A>&nbsp;&nbsp;Command band with adornments.</P>
<P><A NAME="Fig6"></A><A HREF="javascript:displayWindow('images/05-06.jpg',479,240 )"><IMG SRC="images/05-06t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/05-06.jpg',479,240)"><FONT COLOR="#000077"><B>Figure 5.6</B></FONT></A>&nbsp;&nbsp;Command band with adornments and child control bands.</P>
<P>All of the operations you might want to perform with command band controls have been wrapped into command band API functions. Instead of sending messages to the control explicitly, your application calls these functions in order to use command bands.
</P>
<P>Many of these functions will remind you of the command band&#146;s sibling, the command bar. In fact, the application programming interface for creating and using command bands is almost identical to that for command bars.</P>
<P>Since we have already looked at how rebar controls work, and using the command band API will be nothing new because of our familiarity with command bars, this section will quickly introduce command band concepts and then move on.</P>
<P><FONT SIZE="+1"><B>Command Band Functions</B></FONT></P>
<P>The command band API is very similar to the command bar API in both form and usage. For example, usage of <I>CommandBands_AddAdornments</I> is the same as <I>CommandBar_AddAdornments</I>.</P>
<P>In all of the functions that follow, the <I>hinst</I> parameter (if present) is the application HINSTANCE.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_AddAdornments(hwndCmdBands,hinst,dwFlags,prbbi);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_AddAdornments</I> inserts the Close button into the command band control specified by the <I>hwndCmdBands</I> parameter. Additionally, a Help or OK button (or both) can be inserted by specifying the appropriate values in <I>dwFlags</I>: CMDBAR_HELP adds the Help button, and CMDBAR_OK adds the OK button. <I>prbbi</I> points to a REBARBANDINFO structure. This structure can be used to customize the properties of the band that contains the adornment buttons. <I>prbbi</I> can also be NULL.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_AddBands(hwndCmdBands, hinst, cBands, prbbi);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_AddBands</I> inserts bands into the command band control specified by <I>hwndCmdBands</I>. The number of bands to be inserted is in <I>cBands</I>. <I>prbbi</I> is an array of REBARBANDINFO structures defining the bands to be inserted. Both <I>CommandBands_AddAdornments</I> and <I>CommandBands_AddBands</I> return TRUE if successful and FALSE if they fail.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_Create(hinst, hwndParent, wID, dwStyles, himl);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_Create</I> creates a new command band control. <I>hwndParent</I> is the parent of the control. <I>wID</I> is the command band control identifier. <I>dwStyles</I> contains the command band control styles. Command bands use the same style specifiers as rebar controls. <I>himl</I> is the handle of an image list containing the images to be used with the bands. This parameter can be NULL.</P>
<P>If successful, <I>CommandBands_Create</I> returns the HWND of the newly created command band control. Otherwise it returns NULL.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_GetCommandBar(hwndCmdBands, uBand);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_GetCommandBar</I> is the poorly named function that retrieves the HWND of the band specified by the zero-based index <I>uBand</I>. If unsuccessful, this function returns NULL.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_Height(hwndCmdBands);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_Height</I> returns the height in pixels of the specified command band control.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_IsVisible(hwndCmdBands);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_IsVisible</I> determines whether the specified control is visible. The function returns TRUE if the control is visible and FALSE if not.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_GetRestoreInformation(hwndCmdBands, uBand, pcbr);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_GetRestoreInformation</I> gets a COMMANDBANDSRESTOREINFO structure for the band specified by <I>uBand</I>. This structure, returned in the <I>pcbr</I> parameter, contains size, maximized/minimized state information, and the like for the band. This information is usually obtained by an application before it closes. This information can then be held in persistent storage so that the next time the application starts, command bands can be restored to their previous states. The function returns TRUE if successful and FALSE if it fails.</P>
<!-- CODE SNIP //-->
<PRE>
  CommandBands_Show(hwndCmdBands, fShow);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CommandBands_Show</I> is used to show or hide the specified command band control. <I>fShow</I> is TRUE to make the control visible, FALSE to hide it. The previous state of the control is returned.</P>
<H3><A NAME="Heading6"></A><FONT COLOR="#000077">Concluding Remarks</FONT></H3>
<P>The discussion of command band controls concludes our introduction of Windows CE application building blocks. At this point, you have enough background to build the framework for a huge number of useful Windows CE programs.
</P>
<P>Part II of this book shows you how to take advantage of the various persistent storage options available in Windows CE. We will look at the Windows CE file system and registry, as well as how to use Windows CE database technology. These components give you a wide variety of options for storing, retrieving, and organizing the information used by your Windows CE applications.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="137-140.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch06/145-147.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 + -