Click here to Skip to main content
15,881,616 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 347.6K   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

 
AnswerRe: How to Handle Forms? Pin
jswolf1923-Jul-03 10:32
jswolf1923-Jul-03 10:32 
GeneralHow to Handle Forms? [modified] Pin
bipdan25-Feb-07 23:08
bipdan25-Feb-07 23:08 
GeneralCompilation Errors Pin
mrabie12-Mar-03 10:32
mrabie12-Mar-03 10:32 
GeneralRe: Compilation Errors Pin
keith woodward16-Mar-03 11:59
keith woodward16-Mar-03 11:59 
GeneralRe: Compilation Errors Pin
freddy1ca9-Oct-04 15:25
freddy1ca9-Oct-04 15:25 
GeneralRe: Compilation Errors Pin
handdol7-Apr-03 21:00
handdol7-Apr-03 21:00 
GeneralRe: Compilation Errors Pin
JoongHoon Lee21-May-03 21:47
JoongHoon Lee21-May-03 21:47 
GeneralRe: Compilation Errors Pin
slomoman11-Oct-03 4:03
slomoman11-Oct-03 4:03 
right.
if you look into htmlview.h (external dependencies) you can look at the INLINEIMAGE struct. They used to have a TypeDef LPINLINEIMAGE for a pointer to a INLINEIMAGE struct, but now, they don't have that typedef. So you can just use INLINEIMAGE* instead of LPINLINEIMAGE or write a typedef yourself....

but is't still strange that LPINLINEIMAGE is gone in the header...
QuestionHow to get the word selected on HTMLviewer Pin
biswa13-Dec-02 1:20
biswa13-Dec-02 1:20 
AnswerRe: How to get the word selected on HTMLviewer Pin
Anonymous16-Dec-02 1:33
Anonymous16-Dec-02 1:33 
GeneralRe: How to get the word selected on HTMLviewer Pin
DerTyp16-Dec-02 12:45
DerTyp16-Dec-02 12:45 
GeneralRe: How to get the word selected on HTMLviewer Pin
biswa5-Mar-03 19:21
biswa5-Mar-03 19:21 
GeneralRe: How to get the word selected on HTMLviewer Pin
ProudPrimate7-Mar-10 12:19
ProudPrimate7-Mar-10 12:19 
GeneralQ241750 BUG: CHtmlView Leaks Memory by Not Releasing BSTRs in Several Methods Pin
Codin' Carlos5-Oct-02 7:31
Codin' Carlos5-Oct-02 7:31 
QuestionLeaks in Example Code...? Pin
Codin' Carlos5-Oct-02 3:34
Codin' Carlos5-Oct-02 3:34 
GeneralHTML under WinCE .net 4.0 Pin
christiandubois12-Sep-02 2:42
christiandubois12-Sep-02 2:42 
GeneralRe: HTML under WinCE .net 4.0 Pin
Anonymous8-Sep-03 7:57
Anonymous8-Sep-03 7:57 
GeneralRe: HTML under WinCE .net 4.0 Pin
radul16-Jan-04 4:45
radul16-Jan-04 4:45 
Generalone error Pin
GOLDEN6-Jul-02 22:43
GOLDEN6-Jul-02 22:43 
Generalabout HtmlView Control Pin
GOLDEN6-Jul-02 20:54
GOLDEN6-Jul-02 20:54 
GeneralListview class thorugh html ctrl Pin
12-Mar-02 1:02
suss12-Mar-02 1:02 
QuestionAccess Violation on exit with ARM Debug? Pin
Heather Bowen14-Jan-02 9:39
Heather Bowen14-Jan-02 9:39 
AnswerRe: Access Violation on exit with ARM Debug? Pin
Codin' Carlos5-Oct-02 3:42
Codin' Carlos5-Oct-02 3:42 
GeneralRe: Access Violation on exit with ARM Debug? Pin
waterdigi10-Apr-03 11:39
waterdigi10-Apr-03 11:39 
QuestionHow I handle button event, combobox event.. ect...? Pin
9-Dec-01 21:46
suss9-Dec-01 21: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.