📄 289-291.html
字号:
</font></td>
</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=11//-->
<!--PAGES=289-291//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch10/287-288.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="291-294.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 11<BR>Designing Windows CE Custom Controls
</FONT></H2>
<P><BIG><BIG>W</BIG></BIG>indows CE provides a lot of flexibility in designing user interfaces for applications. The child controls and common controls give programmers and designers a wide selection of user input and data presentation options. When the standard controls are not sufficient, Windows CE features such as owner draw buttons and the custom draw service provide ways to customize many of the more commonly used controls.</P>
<P>But sometimes even these options are not flexible enough to implement applications whose user interfaces deviate significantly from the standard Windows CE look and feel. In such cases, application programmers may be compelled to write user interface components from scratch. A <I>custom control</I> is any control used in an application that is not part of the Window CE operating system.<SUP><SMALL><B>1</B></SMALL></SUP></P>
<BLOCKQUOTE>
<HR>
<SUP><SMALL><B>1</B></SMALL></SUP><FONT SIZE="-1">This definition would imply that other types of controls completely defined by an application programmer, such as ActiveX controls, are custom controls. While technically this is true, this chapter only describes custom controls as they are traditionally defined. Specifically this means any custom HWND-based control whose interface to a client application is the Win32 API.
</FONT>
<HR>
</BLOCKQUOTE>
<P>A custom control is in many ways like any of the standard Windows CE child or common controls. Like the controls supplied with the Windows CE operating system, custom controls are child windows used in applications to perform functions like displaying data, editing text, or responding to stylus taps in various ways. Your applications create custom controls by calling <I>CreateWindow</I> or <I>CreateWindowEx</I>, and respond to WM_COMMAND or WM_NOTIFY messages generated by the controls.</P>
<P>The big difference between the standard Windows CE controls and custom controls is that as the applications programmer, you design and implement the control. All aspects of the appearance of the control and its behavior are implemented by you to satisfy some special user interface needs not satisfied by any of the standard controls that come with Windows CE.</P>
<P>This points out the biggest benefit of using custom controls: As the control programmer, you have complete control over every aspect of the control’s appearance and behavior.</P>
<P>In this chapter we will look at how to implement custom controls by implementing a simple custom control in a Windows CE dynamic link library.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>AFTER COMPLETING THIS CHAPTER YOU WILL KNOW HOW TO…</B>
<DL>
<DD><B>Statically or dynamically link with a dynamic link library</B>
<DD><B>Implement a dynamic link library</B>
<DD><B>Design and implement a custom control as a dynamic link library</B>
</DL>
<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">The Example Custom Control</FONT></H3>
<P>Rather than focus on writing fancy control features and graphical appearance, this chapter concentrates on the framework required to implement a custom control. Therefore the custom control implemented in this chapter will look very familiar. We implement the standard button from scratch, and add some new custom control styles in the process.
</P>
<P>Yes, this is pretty boring from the point of view of learning how to create user interface components that look nothing like Windows CE. But the aspects of implementing custom controls requiring the most attention are issues such as supporting control-specific styles and responding to window messages. Also more worth our time is how to package custom controls for the most convenient use by applications.</P>
<P>The custom button defines three styles that are specific to this custom control. These styles are detailed in Table 11.1. Some examples of custom buttons with the various styles are shown in Figures 11.1 and 11.2.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 11.1</B> Custom Button Control Styles
<TR>
<TH WIDTH="30%" ALIGN="LEFT">STYLE
<TH WIDTH="70%" ALIGN="LEFT">MEANING
<TR>
<TD VALIGN="TOP">CBTN_PUSH
<TD>Creates a custom button that acts like a standard Windows CE push-button control.
<TR>
<TD VALIGN="TOP">CBTN_TOGGLE
<TD>Creates a custom button that toggles, much like a check box. The button stays pressed when tapped. It must be tapped again to unpress it.
<TR>
<TD VALIGN="TOP">CBTN_LARGEFONT
<TD>Tells the control to draw button text with 18 point Times New Roman font. Without this style, the font used is 12 point Times New Roman.
</TABLE>
<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/11-01.jpg',480,240 )"><IMG SRC="images/11-01t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/11-01.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 11.1</B></FONT></A> A custom button with the CBTN_PUSH style.</P>
<P><A NAME="Fig2"></A><A HREF="javascript:displayWindow('images/11-02.jpg',480,240 )"><IMG SRC="images/11-02t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/11-02.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 11.2</B></FONT></A> A custom button control with the CBTN_LARGEFONT and CBTN_TOGGLE styles in the pressed state.</P>
<P>The complete source code for the custom control and the client application that uses the control can be found under \Samples\custom on the companion CD. The workspace (.dsw) file is under the \Samples\custom\control subdirectory and is called control.dsw. This workspace contains the project for the custom control, CONTROL.DLL, as well as the client application, CUSTOM.EXE.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch10/287-288.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="291-294.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 + -