?? 066-068.html
字號:
<option value="">-----------
<option value="/reference/whatsnew.html">New Titles
<option value="">-----------
<option value="/reference/dir.archive1.html">Free Archive
</SELECT>
</font></td>
</tr>
</table>
</form>
<!-- LEFT NAV SEARCH END -->
</td>
<!-- PUB PARTNERS END -->
<!-- END LEFT NAV -->
<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=""> <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=3//-->
<!--PAGES=066-068//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="063-066.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch04/069-072.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>Assigning a string to <I>ofn.lpstrFile</I> means that the File Open dialog will be initialized with that string in the Name field of the dialog box. In this case, the file name “sample.txt” will initialize this field.</P>
<P>Finally, the string “Open a Text File” will be the File Open dialog box title, and “txt” will be used as the default file name extension. If a user types a file name in the name field without an extension, .txt will be automatically appended.</P>
<P>This is all the hard work. To display the dialog box, the application simply calls <I>GetOpenFileName</I>. When <I>GetOpenFileName</I> returns, the <I>lpstrFile</I> member of <I>ofn</I> contains the fully qualified file name of the selected file.</P>
<P><I>OnFileOpen</I> doesn’t do anything once a user selects a file. It just shows you how to use the File Open dialog. A real application would proceed by, for example, reading the file and displaying the contents in the main application window.</P>
<P>Programming the Save As common dialog is very similar. An OPENFILENAME structure is filled as in this example. The application then simply calls <I>GetSaveFileName</I> to display the dialog.</P>
<P><FONT SIZE="+1"><B>The Color Dialog</B></FONT></P>
<P>Now we take a very brief look at using the Color dialog. Figure 3.5 shows an example of the Color dialog. Applications use this dialog as a user interface for making color selections. Pressing the Define button causes the dialog to expand into the form shown in Figure 3.6.
</P>
<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/03-05.jpg',480,240 )"><IMG SRC="images/03-05t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/03-05.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 3.5</B></FONT></A> The Color common dialog.</P>
<P><A NAME="Fig6"></A><A HREF="javascript:displayWindow('images/03-06.jpg',480,240 )"><IMG SRC="images/03-06t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/03-06.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 3.6</B></FONT></A> A fully expanded Color dialog.</P>
<P>This dialog box is created with one function call, just like all the other common dialogs. In the case of the Color dialog, you call the <I>ChooseColor</I> function:</P>
<!-- CODE SNIP //-->
<PRE>
ChooseColor(lpcc);
</PRE>
<!-- END CODE SNIP //-->
<P>The single argument in this case is a pointer to a CHOOSECOLOR structure. The various members of this structure are initialized to control the appearance of the Color dialog.
</P>
<P>To create the Color dialog in Figure 3.5, an application only needs six lines of code:</P>
<!-- CODE SNIP //-->
<PRE>
CHOOSECOLOR cc;
COLORREF cr[16];
memset(&cc, 0, sizeof(cc));
cc.lStructSize = sizeof(cc);
cc.lpCustColors = cr;
ChooseColor(&cc);
</PRE>
<!-- END CODE SNIP //-->
<P>The <I>lpCustColors</I> member of the CHOOSECOLOR structure can be used to specify the 16 colors displayed in the custom colors fields at the bottom of the dialog box in Figure 3.5. This allows the application to specify colors of its own for users to choose from other than the basic colors at the top.</P>
<P>Note that <I>lpCustColors</I> cannot be NULL. Since this member is used to return any custom colors specified by the user, it must be initialized with a valid COLORREF array.</P>
<P>These custom colors can also be changed by the user. If the Define button is pressed, the user sees the fully expanded Color dialog like the one in Figure 3.6. Colors can be entered in the Red, Green, and Blue edit boxes. Or the user can tap points on the large field above the Add To Custom Colors button to select colors. The hue, saturation, and luminance of the colors in this field can also be changed via the corresponding edit boxes.</P>
<P>The point of all of this is that if the user taps the Add To Custom Colors button, the color currently selected in the right half of the dialog is added to the <I>lpCustColors</I> array. This provides a mechanism for the application to store the user’s custom color selections and put them in the custom color fields the next time the dialog is created.</P>
<P>When the user presses the OK button to close the Color dialog, the color selected by the user is returned to the application in the <I>rgbResult</I> member of the CHOOSECOLOR structure. This member can also be assigned before calling <I>ChooseColor</I> to specify which color is initially selected in the dialog.</P>
<H3><A NAME="Heading7"></A><FONT COLOR="#000077">Concluding Remarks</FONT></H3>
<P>The two chapters you have just finished reading have presented an introduction to programming some the most basic building blocks of any Windows CE application. We have seen how to write the fundamental message processing infrastructure of an application. We know how to add child and common controls, as well as various types of dialog boxes.
</P>
<P>In the rest of Part I, we add to this knowledge by investigating how menus are added to Windows CE applications. And we look at how to program some of the common controls that are of particular interest to Windows CE applications.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="063-066.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch04/069-072.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 + -