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

📄 025-028.html

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

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="022-025.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="028-031.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>As an application programmer, you will be implementing window procedures of your own. These will often be for application main windows, but you will also implement them for custom controls and other Windows CE window classes that you design. It would seem that it would be quite a challenge to implement responses for all of the hundreds of Windows CE messages that might be sent to your windows.
</P>
<P>Luckily, Windows CE takes care of a lot of the default message handling for you. The function <I>DefWindowProc</I> is used to call Windows CE and have the operating system provide default behavior for any specified message:</P>
<!-- CODE SNIP //-->
<PRE>
  DefWindowProc(hWnd, uMsg, wParam, lParam);
</PRE>
<!-- END CODE SNIP //-->
<P><I>DefWindowProc</I> has the same arguments as any window procedure. You pass it the corresponding parameters from your window procedure, and Windows CE performs the default processing for the given message. This greatly simplifies the implementation of window behavior. It allows you to concentrate on the messages that have a unique or specific meaning to your particular window classes, and not think about the rest.</P>
<P>For example, in the template application, the only message that we handle ourselves is WM_LBUTTONDOWN. We want the template application to shut down whenever the user taps in the client area of the main window. The window procedure for the main application window class therefore look like this:</P>
<!-- CODE //-->
<PRE>
  LRESULT CALLBACK WndProc(
    HWND hwnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
  &#123;
    switch(message)
    &#123;
     case WM_LBUTTONDOWN:
      DestroyWindow(hwnd);
      PostQuitMessage(0);
      return (0);
     default:
      return (DefWindowProc(hwnd, message, wParam,lParam));
    &#125;
  &#125;
</PRE>
<!-- END CODE //-->
<P>All of the several hundred Windows CE messages that can possibly be sent or posted to this window are handled by these few lines of code. All but one are handled by <I>DefWindowProc</I>.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>E<SMALL>ACH</SMALL> M<SMALL>ESSAGE</SMALL> R<SMALL>ETURNS A</SMALL> V<SMALL>ALUE</SMALL></B>
<P><B>For every message handled by a window procedure, some appropriate value must be returned. The Windows CE on-line documentation specifies the values to return for each message under various circumstances.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P>Windows implement their specific behavior by responding to the various Windows CE messages. There are literally hundreds of messages in Windows CE, representing user input, window painting, and updating, and all of the other interactions that go on in Windows CE applications. In some sense, the essence of Windows CE programming is mastering these messages and their meanings, and implementing the responses to them to enable your applications to behave in the ways that make them unique and interesting. This book is full of sample applications that will help you get started.</P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Creating Windows</FONT></H3>
<P>So much for the window theory. How does an application actually create windows?
</P>
<P>Windows CE provides two functions, <I>CreateWindow</I> and <I>CreateWindowEx</I>, for this purpose. These functions are used extensively in Windows CE applications to create everything from main application windows to child and common controls.</P>
<P><I>CreateWindow</I> has the following form:</P>
<!-- CODE SNIP //-->
<PRE>
  CreateWindow(lpClassName, lpWindowName, dwStyle, x, y,
    nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
</PRE>
<!-- END CODE SNIP //-->
<P><I>CreateWindow</I> creates an instance of a particular window class. <I>lpClassName</I> specifies the window class to use. This parameter is the Unicode string name of the class that was used to register the window class (i.e., the <I>lpszClassName</I> member of the WNDCLASS structure).</P>
<P><I>lpWindowName</I> points to a null-terminated Unicode string that contains the window text. For example, in a window with a caption, this string is used as the caption text. For a button, the string is the button text.</P>
<P><I>dwStyle</I> is a set of one or more window styles. (See Table 2.3 later for a complete list of window styles supported under Windows CE.)</P>
<P><I>x</I>, <I>y</I>, <I>nWidth,</I> and n<I>Height</I> specify the position and dimensions of the window: <I>x</I> and <I>y</I> are the x and y coordinates of the upper left corner of the window in screen coordinates. <I>nWidth</I> and <I>nHeight</I> are the width and height in screen coordinates.</P>
<P><I>hWndParent</I> is the parent window of the window being created.</P>
<P><I>hMenu</I> should be NULL for top-level windows. For child windows, such as Windows CE controls, this parameter specifies the child window identifier. This is the value used, for example, to identify the control sending a WM_COMMAND message.</P>
<P><I>hInstance</I> is the HINSTANCE of the module in which the window is created.</P>
<P>Finally, <I>lpParam</I> is the value sent as the <I>lpCreateParams</I> member of the CREATESTRUCT sent with the WM_CREATE message that is triggered by the <I>CreateWindow</I> call. This parameter can be NULL. We take a closer look at the WM_CREATE message in the next section.</P>
<P>I should point out here that all text in Windows CE is Unicode, not ANSI. Therefore, any string function parameter will be Unicode for Windows CE. All text rendered in any application is Unicode. In short, if it&#146;s text, it&#146;s Unicode.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>C<SMALL>REATE</SMALL>W<SMALL>INDOW AND</SMALL> C<SMALL>REATE</SMALL>W<SMALL>INDOW</SMALL>E<SMALL>X</SMALL> A<SMALL>RE</SMALL> N<SMALL>OT</SMALL> R<SMALL>EALLY</SMALL> F<SMALL>UNCTIONS</SMALL></B>
<P><B><I>CreateWindow</I> and <I>CreateWindowEx</I> are macros that call the <I>CreateWindowExW</I> function, the Unicode-based window creation function. Applications should never call <I>CreateWindowExW</I> directly, since porting this code to other versions of Windows may be problematic. For example, as Windows NT applications can be built with Unicode support disabled, CreateWindowExW may not be defined. The <I>CreateWindow</I> and <I>CreateWindowEx</I> macros, however, are guaranteed to resolve to the correct supported API.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><I>CreateWindowEx</I> is the same as <I>CreateWindow</I> except that it allows you to specify various <I>extended window styles</I> in the first parameter. The rest of the parameters are the same. The extended window styles supported under Windows CE are listed in Table 2.4 (shown later).</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="022-025.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="028-031.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 + -