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

📄 303-305.html

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

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="300-303.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="305-310.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><I>hWnd</I> specifies the window, and <I>nIndex</I> is a value specifying which 32-bit value to retrieve. This parameter can be any one of the values shown in Table 11.4.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 11.4</B> GetWindowLong and SetWindowLong Index Values
<TR>
<TH WIDTH="30%" ALIGN="LEFT">VALUE
<TH WIDTH="70%" ALIGN="LEFT">MEANING
<TR>
<TD>GWL_EXSTYLE
<TD>Retrieves/sets the window extended style.
<TR>
<TD>GWL_STYLE
<TD>Retrieves/sets the window style.
<TR>
<TD>GWL_WNDPROC
<TD>Retrieves/sets the window procedure.
<TR>
<TD>GWL_ID
<TD>Retrieves/sets the window identifier.
<TR>
<TD>DWL_DLGPROC
<TD>Retrieves/sets the dialog procedure for a specified dialog box.
<TR>
<TD VALIGN="TOP">DWL_MSGRESULT
<TD>Retrieves/sets the return value of a message processed in the dialog box procedure.
<TR>
<TD VALIGN="TOP">DWL_USER
<TD>Retrieves/sets an application-specific 32-bit value associated with the specified dialog box.
</TABLE>
<P>As an example, an application can check to see if an instance of the custom button control class has the CBTN_LARGEFONT style with the following code:
</P>
<!-- CODE //-->
<PRE>
  HWND hwndButton;  //The custom button control HWND
   DWORD dwStyle;

   dwStyle = GetWindowLong(
     hwndButton,
     GWL_STYLE);
  if (dwStyle &#38;    CBTN_LARGEFONT)
  &#123;
    //Do something
  &#125;
</PRE>
<!-- END CODE //-->

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD><FONT SIZE="+1"><B>Performing a Window Brain Transplant: Window Subclassing</B></FONT>
<P>The Windows CE functions <I>GetWindowLong</I> and <I>SetWindowLong</I> provide some very powerful possibilities when used with the GWL_WNDPROC index. With these functions, an application can <I>subclass</I> any Windows CE window.</P>
<P>Window subclassing in this sense means replacing the window procedure of a window with a different window procedure. With this technique, an application can give custom behavior to a window on the fly.</P>
<P>This becomes most significant when subclassing Windows CE controls. Subclassing a control lets you take full advantage of the default functionality of the control while adding custom behavior only where needed.</P>
<P>To subclass a control or any other window, you write a window procedure for that control which contains your custom responses to the various Windows CE messages you wish to override. You then make the control use this window procedure by calling <I>SetWindowLong</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  LRESULT CALLBACK myWndProc(HWND hwnd,
    UINT message.
    WPARAM wParam,
    LPARAM lParam);
  HWND hwndControl;
   WNDPROC wndProcOld;
   wndProcOld = (WNDPROC)SetWindowLong(
     hwndControl, GWL_WNDPROC, (LONG)myWndProc);
</PRE>
<!-- END CODE SNIP //-->
<P>In one step, <I>SetWindowLong</I> changes the window procedure to be used by the control <I>hwndControl</I> and stores the original control window procedure in <I>wndProcOld</I>.</P>
</TABLE>

<P><I>GetWindowLong</I> has a counterpart, <I>SetWindowLong</I>, which can be used to set any of the values described in Table 11.4.</P>
<!-- CODE SNIP //-->
<PRE>
  SetWindowLong(hWnd, nIndex, dwNewLong);
</PRE>
<!-- END CODE SNIP //-->
<P>This function sets the window value indicated by <I>nIndex</I> to the value specified by <I>dwNewLong</I>. The previous value that the window stored for that index is returned by the function.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>U<SMALL>NSUPPORTED</SMALL> I<SMALL>NDICES</SMALL></B>
<P><B>Under Windows CE, <I>GetWindowLong</I> and <I>SetWindowLong</I> do not support the GWL_HINSTANCE, GWL_HWNDPARENT, or GWL_USERDATA indices.</B><HR></FONT>
</BLOCKQUOTE>
</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<P>Saving the old window procedure makes it easy for your custom window procedure to implement the original default behavior for messages you do not want to override. This is done by calling <I>CallWindowProc</I>:</P>
<!-- CODE SNIP //-->
<PRE>
  CallWindowProc(wndprcPrev, hwnd, uMsg, wParam, lParam);
</PRE>
<!-- END CODE SNIP //-->
<P>This function passes handling of the message <I>uMsg</I> to the window procedure specified by <I>wndprcPrev</I>. In other words, <I>CallWindowProc</I> allows an application to directly call into a specified window procedure.</P>
<P>As an example, let&#146;s say that you only wish to customize the stylus tap logic for a list box control. You could write the custom list box window procedure as follows. <I>ListWndProcOld</I> is the original list box window procedure extracted by a call to <I>SetWindowLong</I> like the one shown above.</P>
<!-- CODE //-->
<PRE>
  LRESULT CALLBACK myWndProc(
    HWND hwnd,
    UINT message.
    WPARAM wParam,
    LPARAM lParam)
  &#123;
    switch(message)
    &#123;
     case WM_LBUTTONDOWN:
      //Custom logic here
      return (0);
     default:
      return (CallWindowProc(ListWndProcOld,
       hwnd, message, wParam, lParam));
     &#125;
  &#125;
</PRE>
<!-- END CODE //-->
</TABLE>

<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="300-303.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="305-310.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 + -