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

📄 272-274.html

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

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="269-272.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch10/275-278.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
</P>
<P>When the options window draws the buttons in response to the various WM_DRAWITEM messages it is sent, it uses the control identifier of the button sending the WM_DRAWITEM message to determine which set of images to use from the button image bitmap.
</P>
<!-- CODE //-->
<PRE>
  #define BMP_WIDTH  48
  LRESULT CALLBACK OptionsWndProc(
    HWND hwnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
  &#123;
    HDC hdc;
    UINT nID;
    RECT rc;
    switch(message)
    &#123;
    //Other message handlers
    //&#133;
    case WM_DRAWITEM:
    LPDRAWITEMSTRUCT lpdis;
    int xBmp, xBmpPressed;
    nID = (UINT)wParam;
    lpdis = (LPDRAWITEMSTRUCT)lParam;
    rc = lpdis-&gt;rcItem;
    hdc = lpdis-&gt;hDC;
    xBmp = 0;
    xBmpPressed = BMP_WIDTH;
    switch(nID)
    &#123;
     case IDC_DEPOSIT:
      xBmp &#43;= 2*BMP_WIDTH;
      xBmpPressed &#43;= 2*BMP_WIDTH;
      break;
     case IDC_WITHDRAW:
      xBmp &#43;= 4*BMP_WIDTH;
      xBmpPressed &#43;= 4*BMP_WIDTH;
      break;
     default:
      break;
    &#125;  //End of switch(nID) block
</PRE>
<!-- END CODE //-->
<P>The WM_DRAWITEM handler first extracts the information it needs to draw the button bitmaps such as the device context of the button and the button&#146;s bounding rectangle. Next, it initializes the two offset variables, <I>xBmp</I> and <I>xBmpPressed</I>, to the x pixel offsets of the first unpressed and pressed button images.</P>
<P>The <I>nID</I> switch statement then adjusts these values to correspond to the left edge of the appropriate button bitmaps depending on which button sent the WM_DRAWITEM message.</P>
<P>For example, if the WM_DRAWITEM message was sent by the IDC_DEPOSIT button, <I>xBmp</I> and <I>xBmpPressed</I> are set to the values 96 and 120, respectively. These values correspond to the leftmost pixels of the images to be used to draw the pressed and unpressed states of the IDC_DEPOSIT button.</P>
<P>Finally, the WM_DRAWITEM handler checks the <I>itemState</I> of the button, and displays the proper image with a call to <I>BitBlt</I>:</P>
<!-- CODE //-->
<PRE>
   /* If the button is pressed&#133; */
  if (lpdis-&gt;itemState &#38; ODS_SELECTED)
  &#123;
    BitBlt(hdc, rc.left,rc.top,
    (rc.right-rc.left),
    (rc.bottom-rc.top),
    hdcButtons,
    xBmpPressed,0,SRCCOPY);
  &#125;
  /* If the button is not pressed&#133; */
  else
  &#123;
    BitBlt(hdc, rc.left,rc.top,
    (rc.right-rc.left),
    (rc.bottom-rc.top),
    hdcButtons,
    xBmp,0,SRCCOPY);
  &#125;
  return (TRUE);
</PRE>
<!-- END CODE //-->
<H3><A NAME="Heading8"></A><FONT COLOR="#000077">Concluding Remarks</FONT></H3>
<P>In this chapter, you have been introduced to some of the more common techniques for programming custom Windows CE user interfaces. But owner draw controls and offscreen bitmaps are but a few of the many ways that you can create user interfaces for your applications that are different from the Windows CE standard.
</P>
<P>The next chapter expands on the owner draw concept with the more general subject of the Windows CE custom draw service. The custom draw service, like owner draw controls, allows you to dramatically influence the look and feel of various Windows CE controls&#151;but with much more flexibility.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="269-272.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="../ch10/275-278.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 + -