📄 022-025.html
字号:
</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=2//-->
<!--PAGES=022-025//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="019-022.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="025-028.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><I>lpfnWndProc</I> is a pointer to the <I>window procedure</I> for this window class. The subject of window procedures is discussed later.</P>
<P><I>cbClsExtra</I> specifies the number of extra bytes that Windows CE is to allocate for the WNDCLASS structure. These bytes can be used to define additional class attributes over and above those provided for in the WNDCLASS structure. If used, this value must be a multiple of four. This means that any value stored as an extra class word must be a 32-bit integer.</P>
<P>Extra class words are accessed and set using the Windows CE functions <I>GetClassLong</I> and <I>SetClassLong</I>. A value assigned to a particular extra class word is the same for all instances of the class.</P>
<P>For example, let’s say that every window based on a particular window class needs to have the same caption. This window caption is an attribute that is constant across all instances of the window class. A pointer to the window caption string could therefore be stored as an extra window class word.</P>
<P>Similarly, <I>cbWndExtra</I> can be used to specify extra bytes to be allocated for each instance of a window class. In this way, applications can assign unique attributes to each window using the <I>GetWindowLong</I> and <I>SetWindowLong</I> functions. Each instance of a window class can thus have different values for a particular extra window word. <I>cbWndExtra</I>, like <I>cbClsExtra</I>, must be a multiple of four.</P>
<P><I>hInstance</I> identifies the HINSTANCE of the Windows CE module that contains the window procedure of the class.</P>
<P><I>hIcon</I> and <I>hCursor</I> are the icon and mouse cursor to use with instances of the class, respectively. These members can be NULL.</P>
<P><I>hbrBackground</I> is used to represent the background color of windows based on the particular window class.</P>
<P>The <I>lpszMenuName</I> member of WNDCLASS is not supported under Windows CE and therefore must be NULL. This does not exactly mean that Windows CE windows cannot have menus. But menus are added to windows quite differently under Windows CE than under other Windows platforms. Menus in Windows CE are included in <I>command bar controls</I>. Command bars are the subject of Chapter 4.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B><B>A<SMALL>LL</SMALL> W<SMALL>INDOW</SMALL> C<SMALL>LASSES</SMALL> A<SMALL>RE</SMALL> G<SMALL>LOBAL</SMALL></B>
<P><B>Under Windows CE, all window classes are global by default. The CS_GLOBALCLASS style is included for compatibility with other Windows platforms.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B><I>Registering a Window Class</I></B></FONT></P>
<P>Simply defining a window class with a WNDCLASS structure does not mean that the class can be used to make instances of that class. Before a Windows CE application can create a window of a particular window class, the window class must be registered.
</P>
<P>Window class registration is the mechanism by which the class is made available to the Windows CE operating system. <I>CreateWindow</I> requires the window class description in order to successfully create a window instance.</P>
<P>The function used to register a window class is <I>RegisterClass</I>:</P>
<!-- CODE SNIP //-->
<PRE>
RegisterClass(const WNDCLASS *lpWndClass);
</PRE>
<!-- END CODE SNIP //-->
<P><I>RegisterClass</I> takes one argument, a pointer to the WNDCLASS structure representing the window class to be registered. If the function succeeds, it returns an atom representing the registered class. Otherwise it returns zero. An atom is an integer that uniquely identifies a string. In this case, the string identified is the name of the window class, specified in the <I>lpszClassName</I> member of the <I>lpWndClass</I> parameter.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B><B><I>R<SMALL>EGISTER</SMALL>C<SMALL>LASS</SMALL>E<SMALL>X</SMALL></I> I<SMALL>S</SMALL> N<SMALL>OT</SMALL> S<SMALL>UPPORTED</SMALL></B>
<P><B>The function <I>RegisterClassEx</I> is not supported under Windows CE.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B>The Window Procedure</B></FONT></P>
<P>Windows CE uses the same message-based architecture that the desktop Windows platforms such as Windows NT use. This means that the Windows CE operating system interacts with the windows in the various applications it is running by sending Windows CE messages.
</P>
<P>The window procedure for a given window class is the function that implements the response of each instance of that class to every Windows CE message that it receives. Every window class has a window procedure. It can be implemented by the application programmer, in the case of application-defined window classes. In other cases the window procedure is part of Windows CE. For example, all of the child control window classes such as buttons and list boxes have window procedures that are implemented in the Graphics, Windowing, and Events Subsystem of Windows CE.</P>
<P>Window procedures have the following function signature:</P>
<!-- CODE SNIP //-->
<PRE>
LRESULT CALLBACK WndProc(hwnd, uMsg, wParam, lParam);
</PRE>
<!-- END CODE SNIP //-->
<P>The first parameter is the HWND of the window to which a specific Windows CE message is sent. <I>uMsg</I> is a UINT containing the message identifier of the message. <I>wParam</I> and <I>lParam</I> are 32-bit parameters whose values depend on the message being sent.</P>
<P>A window procedure is a <I>callback function</I> (as indicated by the CALLBACK specifier in the function prototype). This means that the function is called by Windows CE, instead of being called directly by an application.</P>
<P>For example, if an application wants to get the font being used by a particular window, it does so by sending the WM_GETFONT message to the window in question. Windows CE then calls the window procedure of the window class from which the window is derived:</P>
<!-- CODE SNIP //-->
<PRE>
HFONT hFont;
hFont = (HFONT)SendMessage(hwndSomeWindow, WM_GETFONT,
0,0L);
</PRE>
<!-- END CODE SNIP //-->
<P>Window procedures return an LRESULT, which is simply a LONG integer. This return value allows a window procedure to return message-specific information for any message posted or sent to it. If the message is sent via <I>PostMessage</I> or <I>SendMessage</I>, this result is passed back to the sender through the return value of these functions. The <I>SendMessage</I> and <I>PostMessage</I> functions are discussed in detail later in this chapter.</P>
<P>Window procedure return values can indicate success or failure of a message, or return requested information. In the WM_GETFONT example above, the value returned from the window procedure of <I>hwndSomeWindow</I> is the current window font.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="019-022.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="025-028.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 + -