?? 313-317.html
字號(hào):
<!-- 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=12//-->
<!--PAGES=313-317//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch11/310-312.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="317-320.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 12<BR>The HTML Viewer Control
</FONT></H2>
<P><BIG><BIG>T</BIG></BIG>he advent of the Internet and the World Wide Web have led to dramatic changes in the basic functionality of computer operating systems. Microsoft’s Win32-based operating systems are no exception. Windows NT, Windows 98, and Windows CE are all very comfortable with providing users with the ability to browse the Internet and display data in all of the various new formats that this medium has generated.</P>
<P>Applications such as Pocket Internet Explorer, the Microsoft Windows CE Web browser, can display hypertext markup language (HTML) documents containing formatted text and images just like their desktop Web browser counterparts.</P>
<P>HyperText Markup Language, or HTML, has always been an important part of the Internet. One of the simplest ways to display HTML in Windows CE applications is with the HTML viewer control provided with Windows CE. This control is in fact used by Pocket Internet Explorer for viewing HTML pages. As we will see, adding HTML rendering capabilities to your Windows CE applications can be easily done with the HTML viewer control.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>AFTER COMPLETING THIS CHAPTER YOU WILL KNOW HOW TO …</B>
<DL>
<DD><B>Use the HTML viewer control to display HTML documents</B>
</DL>
<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Overview of the HTML Viewer Control</FONT></H3>
<P>The Windows CE HTML viewer control is not a child control. Therefore it is not part of the Graphics, Windowing, and Event Subsystem. Nor is it part of COMMCTRL.DLL. That means it does not get loaded along with the tree view and trackbar controls when you call <I>InitCommonControls</I>.</P>
<P>The HTML viewer control resides in its very own dynamic link library, called HTMLVIEW.DLL. To use the control, applications must either explicitly link with the DLL’s import library, HTMLVIEW.LIB, or dynamically link with HTMLVIEW.DLL by loading the DLL at run-time.</P>
<P>Next, before using the HTML viewer control, applications must initialize it by calling <I>InitHTMLControl</I>. This is a function, exported by HTMLVIEW.DLL, that is responsible for registering the control’s window class. After calling <I>InitHTMLControl</I>, applications are free to create instances of the control. In these respects, the design of this control closely resembles the custom control we designed in the previous chapter.</P>
<P><FONT SIZE="+1"><B>Control Features</B></FONT></P>
<P>The HTML viewer control provides very basic (and I mean <I>very</I> basic) functionality for viewing HTML documents. As we will soon see, the control leaves many of the details of navigating between HTML links, displaying images, and playing sounds to the application that contains the control.</P>
<P>First and foremost, it is important to keep in mind that the control is only an HTML viewer. It does not provide HTML editing capabilities.</P>
<P>Next, the HTML viewer control interprets HTML and displays data in the correct format. The control understands all the standard HTML tags, and displays text in the correct sizes and styles based on those tags.</P>
<P>As an example, Figure 12.1 shows the HTML viewer control’s rendering of the following HTML file:</P>
<!-- CODE SNIP //-->
<PRE>
<h1>The HTML Viewer Control</h1>
<h4>Welcome to the <a href="\Windows\wince.htm">Windows
CE</a></h4>
<h4>control for displaying HTML</h4>
</PRE>
<!-- END CODE SNIP //-->
<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/12-01.jpg',480,240 )"><IMG SRC="images/12-01t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/12-01.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 12.1</B></FONT></A> The HTML viewer control at work.</P>
<P>The only work the application had to do was send the HTML text to the control. The HTML viewer control takes care of the rest.
</P>
<P>The situation is not quite so pleasant in the case of images or sound references in an HTML document. For example, the HTML viewer control does not automatically render GIF files referenced in a document. Nor does it automatically play sound files.</P>
<P>If we add a line to the top of the sample HTML file referencing an inline GIF image, the HTML viewer control displays the file as shown in Figure 12.2:</P>
<!-- CODE SNIP //-->
<PRE>
<IMG SRC="\Windows\home.gif">
<h1>The HTML Viewer Control</h1>
<h4>Welcome to the <a href="\Windows\wince.htm">Windows CE</a> </h4>
<h4>control for displaying HTML</h4>
</PRE>
<!-- END CODE SNIP //-->
<P><A NAME="Fig2"></A><A HREF="javascript:displayWindow('images/12-02.jpg',480,240 )"><IMG SRC="images/12-02t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/12-02.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 12.2</B></FONT></A> The HTML Viewer Control displaying an image.</P>
<P>The HTML viewer control only sends a notification to its parent window when it reads a reference to an image from an HTML file. It is the responsibility of the application to then convert the image file to a Windows CE bitmap. The application must then send the appropriate message to the control telling it to display the bitmap representation of the original image file.
</P>
<P>The HTML viewer control will also notify its parent when a user has tapped on a hypertext link. It is again, however, the application’s responsibility to follow the link. That is, the application must respond to this notification by loading the referenced file and telling the HTML viewer control to display it.</P>
<P>At first this seems like a major limitation of the control. But it does make sense for the application, not the control, to do this work. A particular instance of the HTML viewer control has no idea if the HTML documents it is being asked to render are stored locally on the Windows CE device or are coming from a live Internet connection. The application has all of this context information and should therefore be responsible for supplying the data to the control in the correct form.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B><B>T<SMALL>HE</SMALL> N<SMALL>AMES</SMALL> S<SMALL>HOULD</SMALL> H<SMALL>AVE</SMALL> B<SMALL>EEN</SMALL> C<SMALL>HANGED</SMALL> <SMALL>TO</SMALL> P<SMALL>ROTECT</SMALL> <SMALL>THE</SMALL> I<SMALL>NNOCENT</SMALL></B>
<P><B>You will notice that all of the HTML viewer control message names begin with DTM_. This is somewhat confusing, because the message names for the date time picker control start with DTM_ as well.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">The Sample Application</FONT></H3>
<P>Our discussion of the HTML viewer control is motivated by the sample application HTML.EXE. This application, which can be found in \Samples\html on the companion CD, illustrates many of the features provided by the HTML viewer control.
</P>
<P>HTML.EXE implements a basic HTML file viewer. It allows a user to view any HTML file on the file system of a Windows CE device (or the emulation file system if run in the emulator). Two simple HTML files, sample.htm and wince.htm, are provided. These files must be placed in the device or emulator file system under the \Windows directory. See the section on “Viewing the Windows CE Object Store” in the introduction to Part II for a description of how to transfer files using the Remote Object Viewer.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch11/310-312.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="317-320.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 -->
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -