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

📄 282-285.html

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

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="278-282.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="285-287.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>We first list all of the defined custom draw notification return values, and then discuss some examples of their use. The values that an application can return in response to an NM_CUSTOMDRAW notification are:
</P>
<DL>
<DD><B>CDRF_DODEFAULT.</B> Tells the control to perform default processing for the particular draw stage.
<DD><B>CDRF_SKIPDEFAULT.</B> Tells the control not to perform default processing for the particular draw stage.
<DD><B>CDRF_NEWFONT.</B> Tells the control that a new font has been selected into the HDC indicated by the <I>hdc</I> member of the NMCUSTOMDRAW structure sent with the custom draw notification.
<DD><B>CDRF_NOTIFYPOSTPAINT.</B> Tells the control to send a CDDS_ITEMPOSTPAINT notification after painting an item. This is returned in response to the CDDS_ITEMPREPAINT notification.
<DD><B>CDRF_NOTIFYITEMDRAW.</B> Tells the control to send all item-specific custom draw notifications. NM_CUSTOMDRAW notifications will be sent before and after items are drawn, i.e., CDDS_ITEMPREPAINT and CDDS_ITEMPOSTPAINT notifications will be sent.
<DD><B>CDDS_NOTIFYPOSTERASE.</B> In theory, tells the control to send the parent window post-erase notifications. In reality, this is currently not supported.
</DL>
<P>The CDDS_NOTIFYITEMDRAW return value is in many ways the most important. An application returns this value in response to the CDDS_PREPAINT notification to request that the control send subsequent notifications for the rest of the current paint cycle.
</P>
<P>If, on the other hand, the parent window returns CDRF_DODEFAULT in response to the CDDS_PREPAINT notification, the control will not send any more custom draw notifications for the rest of the current paint cycle.</P>
<P>If your application wants to use a different font to draw a control, select the desired font into the <I>hdc</I> member of the NMCUSTOMDRAW structure. You must return CDRF_NEWFONT in that case so that the control knows a new font was selected.</P>
<P>A typical NM_CUSTOMDRAW notification handler looks something like this:</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD><FONT SIZE="+1"><B>How Are Custom Draw Notifications Ignored by Default?</B></FONT>
<P>If you dig through COMMCTRL.H, you&#146;ll find the definitions for the various custom draw notification return values. One of these is:
</P>
<!-- CODE SNIP //-->
<PRE>
#define CDRF_DODEFAULT   0x00000000
</PRE>
<!-- END CODE SNIP //-->
<P>In the typical window procedure, messages that are not handled are passed to <I>DefWindowProc</I> to let Windows CE perform default processing in response to those messages. If a parent window does not respond to custom draw notifications, <I>DefWindowProc</I> is called. For WM_NOTIFY messages containing the NM_CUSTOMDRAW notification code, <I>DefWindowProc</I> returns 0.</P>
<P>So, by default a control that sends a CDDS_PREPAINT notification at the beginning of its paint cycle will get back 0 if the notification is handled by <I>DefWindowProc</I>. Therefore, no more custom draw notifications get sent.</P>
</TABLE>

<!-- CODE //-->
<PRE>
   case WM_NOTIFY:
     LPNMHDR lpnmhdr;
     lpnmhdr = (LPNMHDR)lParam;
     switch(lpnmhdr-&gt;code)
     &#123;
     case NM_CUSTOMDRAW:
      LPNMCUSTOMDRAW lpnmcd;
      lpnmcd = (LPNMCUSTOMDRAW)lParam;
      switch(lpnmcd-&gt;dwDrawStage)
     &#123;
     case CDDS_PREPAINT:
      return (CDRF_NOTIFYITEMDRAW);
     case CDDS_ITEMPREPAINT:
     /* Do item-specific painting and
       return a CDRF_ value depending
       on how you want the item painting
       to proceed.
      */
     default:
      return (CDDS_DODEFAULT);
    &#125;     //End of switch(dwDrawStage) block
    default:
     return (0);
    &#125;     //End of switch(code) block
</PRE>
<!-- END CODE //-->
<P>This short code sample is the parent window&#146;s WM_NOTIFY message handler. It tells the custom draw controls to send all custom draw notifications by returning CDRF_NOTIFYITEMDRAW in response to the CDDS_PREPAINT notification. The CDDS_ITEMPREPAINT handler then performs the custom drawing. The value returned when this is done depends on whether the application wants the control to continue with default item drawing or not.
</P>
<P>A parent window can of course respond to custom draw notifications from various controls in different ways. In that case, the WM_NOTIFY handler would have to look at the <I>hwndFrom</I> or <I>idFrom</I> member of the NMHDR passed with the NMCUSTOMDRAW structure to determine which control is sending a particular notification.</P>
<H3><A NAME="Heading4"></A><FONT COLOR="#000077">Other NMCUSTOMDRAW Info Structures</FONT></H3>
<P>Earlier we said that list view and tree view custom draw controls conveyed information about themselves in custom draw notifications with structures other than NMCUSTOMDRAW. This section describes those control-specific structures.
</P>
<P>When list view controls and tree view controls send custom draw notifications, the <I>lParam</I> of the corresponding WM_NOTIFY message is a pointer to an NMLVCUSTOMDRAW or NMTVCUSTOMDRAW structure. These structures are identical, so we will discuss just the first. The NMLVCUSTOMDRAW structure is defined as:</P>
<!-- CODE SNIP //-->
<PRE>
   typedef struct tagNMLVCUSTOMDRAW
   &#123;
     NMCUSTOMDRAW nmcd;
     COLORREF clrText;
     COLORREF clrTextBk;
   &#125;  NMLVCUSTOMDRAW, *LPNMLVCUSTOMDRAW;
</PRE>
<!-- END CODE SNIP //-->
<P>This structure is very similar to the NMCUSTOMDRAW structure that is sent by other custom draw controls with their custom draw notifications. In fact, the first member of the NMLVCUSTOMDRAW structure, <I>nmcd</I>, is an NMCUSTOMDRAW structure.</P>
<P>The NMLVCUSTOMDRAW structure contains two additional members. <I>clrText</I> is the color to be used as the foreground color when the particular list view or tree view item&#146;s text is drawn. <I>clrTextBk</I> is the item&#146;s text background color.</P>
<P>These values are useful if an application wants to change the text or background colors that are used when list view or tree view items are drawn. An application can assign new colors to these members and return CDRF_DODEFAULT in response to CDDS_ITEMPREPAINT notifications. The control will then paint its items with the new colors.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="278-282.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="285-287.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 + -