Click here to Skip to main content
15,867,308 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 347K   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

 
GeneralBitmap not shown under W2003 Pin
thollsten5-Feb-04 8:27
thollsten5-Feb-04 8:27 
GeneralRe: Bitmap not shown under W2003 Pin
kaubeu26-Jul-04 22:25
kaubeu26-Jul-04 22:25 
GeneralRe: Bitmap not shown under W2003 Pin
nabilssorial9-Jan-05 2:12
nabilssorial9-Jan-05 2:12 
GeneralRe: Bitmap not shown under W2003 Pin
kaubeu9-Jan-05 10:00
kaubeu9-Jan-05 10:00 
GeneralRe: Bitmap not shown under W2003 Pin
nabilssorial9-Jan-05 22:07
nabilssorial9-Jan-05 22:07 
GeneralRe: Bitmap not shown under W2003 Pin
riki_risnandar23-Jan-05 6:38
riki_risnandar23-Jan-05 6:38 
GeneralRe: Bitmap not shown under W2003 Pin
nabilssorial30-Jan-05 22:31
nabilssorial30-Jan-05 22:31 
GeneralRe: Bitmap not shown under W2003 Pin
riki_risnandar31-Jan-05 16:47
riki_risnandar31-Jan-05 16:47 
GeneralRe: Bitmap not shown under W2003 Pin
nabilssorial2-Feb-05 4:55
nabilssorial2-Feb-05 4:55 
GeneralRe: Bitmap not shown under W2003 Pin
xingzz7-Mar-06 1:30
xingzz7-Mar-06 1:30 
GeneralRe: Bitmap not shown under W2003 Pin
jmt63417-Mar-10 18:00
jmt63417-Mar-10 18:00 
GeneralHTML content is not diplayed. Pin
biswa10-Dec-03 21:28
biswa10-Dec-03 21:28 
QuestionHow to Remove the cache from HTML control? Pin
jammu13-Nov-03 15:12
jammu13-Nov-03 15:12 
GeneralHTML Viewer with .NET CF Pin
dragomir26-Oct-03 22:52
dragomir26-Oct-03 22:52 
GeneralRe: HTML Viewer with .NET CF Pin
Anonymous24-May-04 9:55
Anonymous24-May-04 9:55 
QuestionHow to get the redirected URL or Curent URL from the HTML Viwer/Container Pin
AKSIVAKUMAR14-Oct-03 5:35
AKSIVAKUMAR14-Oct-03 5:35 
Questionshow HTML form WWW? Pin
slomoman12-Oct-03 5:42
slomoman12-Oct-03 5:42 
Generalread image from file Pin
slomoman11-Oct-03 4:17
slomoman11-Oct-03 4:17 
GeneralRe: read image from file Pin
João Paulo Figueira11-Oct-03 6:21
professionalJoão Paulo Figueira11-Oct-03 6:21 
GeneralRe: read image from file Pin
slomoman12-Oct-03 4:53
slomoman12-Oct-03 4:53 
GeneralRe: read image from file Pin
yamusf8-Apr-04 3:25
yamusf8-Apr-04 3:25 
GeneralRe: read image from file Pin
slomoman8-Apr-04 10:16
slomoman8-Apr-04 10:16 
QuestionHow do I control page?.. Pin
Lee C.H.6-Jul-03 20:32
Lee C.H.6-Jul-03 20:32 
AnswerRe: How do I control page?.. Pin
Anonymous11-Jul-03 21:21
Anonymous11-Jul-03 21:21 
GeneralRe: How do I control page?.. Pin
bob hwang13-Apr-04 0:46
bob hwang13-Apr-04 0:46 

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.