Click here to Skip to main content
15,886,847 members
Articles / Mobile Apps

HTML based dialog for the Pocket PC

Rate me:
Please Sign up or sign in to vote.
4.81/5 (14 votes)
26 Aug 2001CPOL2 min read 349.2K   1.1K   51   107
A library that provides an easy wrapper that encapsulates most of work done with the HtmlView control in CE

Screenshot

Introduction

It seems to be a good idea to use a HTML based dialog in Pocket PC applications. Much of the work you have to do will be done by HTML engine. Pocket PC provides htmlview.dll that contains the HtmlView control. But a lot of developers find it difficult to use. The STHtmlDialog library provides an easy way to use a wrapper that encapsulates most of work done with the HtmlView control.

Using HTML in dialogs your can display a text using different fonts, colors and styles, use different HTML controls, display images, use links and many other features provided by HTML.

Keep also in mind that HTML provided by HtmlView control does not support some of the features you might expect as JavaScript, frames, etc.

What You Need

Background

To create a HtmlView control without the STHtmlDialog library you should:

  1. Add htmlview.lib library to your project. Call Project Settings dialog (Alt+F7), then go to the Link tab page and add htmlview.lib string to Object/library modules field.
  2. Include Htmlctrl.h files. Add  #include <Htmlctrl.h>  line to your StdAfx.h file.
  3. Load the HTML Viewer DLL by calling the LoadLibrary function. Specify Htmlview.dll in the lpLibFileName parameter.
  4. Register the HTML Viewer control class by calling the InitHTMLControl function.
  5. Create a window for the HTML Viewer control by calling the CreateWindow function. Specify DISPLAYNAME in the lpClassName parameter
  6. Rewrite WindowProc function and handle WM_NOTIFY messages. Here you should give images and handle links (NM_HOTSPOT and NM_INLINE_IMAGE codes).

Using STHtmlDialog library

To create an HTML dialog using the STHtmlDialog library you should:

  1. Insert the STHtmlDialog.h and STHtmlDialog.cpp files into your project (use Project\Add To Project\Files menu item).
  2. Add the htmlview.lib library to your project. Call Project Settings dialog (Alt+F7), then go to the Link tab page and add htmlview.lib string to Object/library modules field.
  3. Change the super class of your dialog form CDialog to CSTHtmlDialog.
  4. In the OnInitDialog method of your dialog you should add a call to the SetHtml function that sets the HTML text.

Handling HTML events

Links

When a user clicks a link in HTML, the OnLink virtual function of your dialog is called. To handle links you should override this function. The strHref parameter contains the href attribute of the link that was clicked.

Images

To use images in HTML first register them. Call the RegisterHtmlImage function during initialization for each image you are going to use in HTML. When you register an image you should specify a string that can be used in the HTML src attribute of img tag.

Conclusion

It's easy to create an HTML based dialog using STHtmlDialog library. CSTHtmlDialog wraps functionality of HtmlView control including images and links.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: HTML? But Under WinCE .net 4.0 Pin
christiandubois18-Aug-03 2:10
christiandubois18-Aug-03 2:10 
GeneralRe: HTML? But Under WinCE .net 4.0 Pin
dragomir26-Oct-03 22:36
dragomir26-Oct-03 22:36 
GeneralRe: HTML? But Under WinCE .net 4.0 Pin
christiandubois27-Oct-03 2:19
christiandubois27-Oct-03 2:19 
GeneralRe: HTML? But Under WinCE .net 4.0 Pin
dragomir28-Oct-03 1:12
dragomir28-Oct-03 1:12 
GeneralRe: HTML? But Under WinCE .net 4.0 Pin
christiandubois28-Oct-03 1:50
christiandubois28-Oct-03 1:50 
AnswerRe: HTML? Pin
Codin' Carlos27-Dec-01 6:05
Codin' Carlos27-Dec-01 6:05 
AnswerRe: HTML? Pin
Codin' Carlos5-Oct-02 3:48
Codin' Carlos5-Oct-02 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.