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

📄 300-303.html

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

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="297-300.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="303-305.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>After that, the application is free to create instances of the custom button control by calling <I>CreateWindow</I> with the CUSTOMBUTTON window class name. The CUSTOMBUTTON symbol is defined in the header file CONTROL.H. We will see this definition a little later.</P>
<P>From the point of view of the client application, that&#146;s it. The application can now send window messages or any custom messages defined by the control to <I>hwndExit</I>. The application can also respond to notifications or messages (such as WM_COMMAND) that the button may send it.</P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Implementing the Custom Button Control</FONT></H3>
<P>We now focus our attention on the details of the custom control DLL implementation.
</P>
<P><FONT SIZE="+1"><B>The <I>InitCustomButton</I> Function
</B></FONT></P>
<P>The first part of the custom button control implementation we will look at is the <I>InitCustomButton</I> function. This is the exported function that client applications call to register the control window class. This function also initializes the two fonts used by the control, but this part of the function is left out for brevity.</P>
<!-- CODE //-->
<PRE>
  void InitCustomButton()
  &#123;
    WNDCLASS wndClass;
    wndClass.style     = 0;
    wndClass.lpfnWndProc  = ControlWndProc;
    wndClass.cbClsExtra  = 0;
    wndClass.cbWndExtra  = 8;
    wndClass.hInstance   = NULL;
    wndClass.hIcon     = NULL;
    wndClass.hCursor    = NULL;
    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW&#43;1);
    wndClass.lpszMenuName = NULL;
    wndClass.lpszClassName = CUSTOMBUTTON;
    RegisterClass(&#38;wndClass);
    /* This function also goes on to create the
      two fonts used by the DLL.
     */
  &#125;
</PRE>
<!-- END CODE //-->
<P><I>ControlWndProc</I> is the window procedure of the custom button control. We will discuss this function later. Also notice that the <I>cbWndExtra</I> member of the WNDCLASS structure is 8. This means that every custom button HWND carries around 8 extra bytes. We will see how these bytes are used later as well.</P>
<P>The header file associated with the custom control DLL, CONTROL.H, includes the following definition:</P>
<!-- CODE SNIP //-->
<PRE>
  #define CUSTOMBUTTON (TEXT("CUSTOMBUTTON"))
</PRE>
<!-- END CODE SNIP //-->
<P>This defines the window class name for the control. This name gets assigned to the <I>lpszClassName</I> member of the WNDCLASS structure.</P>
<P>Note that since all window classes are global under Windows CE, the <I>hInstance</I> member of the window class structure can be set to NULL.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>A C<SMALL>USTOM</SMALL> C<SMALL>ONTROL</SMALL> C<SMALL>LASS</SMALL> C<SMALL>AN</SMALL> B<SMALL>E</SMALL> R<SMALL>EGISTERED IN</SMALL> D<SMALL>LL</SMALL>M<SMALL>AIN</SMALL></B>
<P><B>Your custom control implementations can do all of the control window class registration in <I>DllMain</I> in response to the DLL_PROCESS_ATTACH event. This would eliminate the need for implementing an initialization function. Applications would have one less function to call as well. This chapter chooses to implement the initialization function to more fully demonstrate dynamic linking, and the way <I>GetProcAddress </I> is used to obtain pointers to exported functions.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B>Custom Button Control Styles</B></FONT></P>
<P>The custom button control supports three control styles: CBTN_PUSH, CBTN_TOGGLE, and CBTN_LARGEFONT. Refer to Table 11.1 at the beginning of the chapter for a description of these styles.
</P>
<P>In Windows CE, control styles generally occupy the low word of the 32-bit integer that defines the control window styles. The high word is used for the window styles such as WS_CHILD or WS_VISIBLE.</P>
<P>The custom control header file CONTROL.H thus defines the three control styles as the following 16-bit integers:</P>
<!-- CODE SNIP //-->
<PRE>
  #define CBTN_PUSH   0x0000
  #define CBTN_TOGGLE  0x0001
  #define CBTN_LARGEFONT 0x0002
</PRE>
<!-- END CODE SNIP //-->
<P>Assigning CBTN_PUSH a value of zero means that this style is the default custom button control style. Each of the other styles is assigned a unique bit of a 16-bit integer.
</P>
<P>An instance of the custom button control class often needs to test one or more of these style bits to see if it is set. Determining if a particular button is toggle style, for instance, requires that the custom control code check for the CBTN_TOGGLE bit.</P>
<P>A window can check its styles by calling the Windows CE <I>GetWindowLong</I> function. The function extracts a particular 32-bit integer value that is stored with the window:</P>
<!-- CODE SNIP //-->
<PRE>
  GetWindowLong(hWnd, nIndex);
</PRE>
<!-- END CODE SNIP //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="297-300.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="303-305.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 + -