Click here to Skip to main content
15,867,308 members
Articles / Desktop Programming / MFC
Article

HOWTO: Use the undocumented HTMLLITE.DLL component

Rate me:
Please Sign up or sign in to vote.
4.81/5 (35 votes)
8 Aug 20033 min read 158.7K   1.3K   77   44
There is an undocumented DLL library included with VS.NET called HTMLLITE...

Sample Image - htmllite.gif

Introduction

There is an undocumented DLL component used in the Installer of VS.NET that allows you to render HTML for your application, and all from a simple window class.

The control would allow you to render, say, a richly formatted report in your application and display it to the user.

The library is located at \Program Files\Microsoft Visual Studio .NET 2003\Setup\Visual Studio .NET Enterprise Architect 2003 - English with the filename: htmllite.dll (136 Kb).

You must copy the DLL from here and place it with the other source and executable files extracted from the ZIP archive. The DLL has not been included in the ZIP for redistribution reasons.

How to use HTMLLITE

The library is very simple to use. You need to first call a sub aliased:

RegisterHtmlLiteClass

... and this will make ready the window class for use in your application (similar to calling InitCommonControls).

The control can then be created with CreateWindowEx like any other window:

CreateWindowEx(WS_EX_CONTROLPARENT, "HTMLLITE", 
   "TODO: HTML goes here...", WS_CHILD | WS_VISIBLE, 
   10, 10, 500, 500, hWnd, 0, 0, 0);

The control is then ready and visible on your parent window.

Under the hood

A few weeks ago when I first started tinkering with HTMLLITE, I spent a few hours on that ancient utility called Spy++ to see what messages HTMLLITE was using...

I found that HTMLLITE works very similar to the standard Windows Common Controls, such as ListViews. It makes use of WM_NOTIFY, to send notifications to your application about mouse clicks, moves, and others.

The lParam of the WM_NOTIFY contains a pointer to a NMHDR structure, and like any other control, the members are no different... hwndFrom, idFrom and code.

'Code' was the important one, so I set about learning what each code meant and came up with the following:

//HTMLLITE Notify Codes

//A link has been clicked either via
//... the Mouse or Spacebar key
#define HTMLLITE_CODE_LEFTCLICK    1000 
//A link has received focus due to 
//... the Tab Cycle, or Keyboard Arrow Keys
#define HTMLLITE_CODE_TABCYCLE  1001 
//A link has been right-clicked, and already had focus
#define HTMLLITE_CODE_RIGHTCLICK   1003 
//Mouse is over a link
#define HTMLLITE_CODE_MOUSEOVER    1004 
//Mouse is hovering a link (~1 second = hover)
#define HTMLLITE_CODE_MOUSEHOVER   1005 
//Mouse has left a link's rectangle
#define HTMLLITE_CODE_MOUSEEXIT    1006 

Simple.

The control also uses its window text/caption as the source for the HTML. So if you want to change the HTML content after it has been created, simply send a WM_SETTEXT message containing the new HTML.

Next step was to find a way to determine which hyperlink had been clicked in any given HTMLLITE control instance. As pot luck had it, a couple of days ago I stumbled upon the MSDN pages about the SYSLINK control (new with Common Controls v6). The SYSLINK control is similar to HTMLLITE except it can only render simple <a href> style markup. I tried out the notification structure of the SYSLINK control to see if HTMLLITE used anything similar.. and.. hut-damn, it did:

typedef struct tagNMLINK { //nm structure for SYSLINK
    NMHDR hdr;
    LITEM item;
} NMLINK, *PNMLINK;

After about half an hour I had reversed the entire HTMLLITE NM structure...

The most important member is linkid. This member contains the value of the parameter linkid used in a <a href="..."> style markup. So if you have more than one link in a HTMLLITE control, simply add linkid parameters to your <a>'s and they will be filled into the following structure's similarly named member.

typedef struct NMHTMLLITE {
  //The Window Handle (hWnd) of the HTMLLITE control
  //... sending you this message.
  DWORD hwndFrom;      
  //If your HTMLLITE control is on a dialog, this member
  //... contains its Dialog ID.
  DWORD idFrom;
  //As defined below. As an example, this member will
  //... equal HTMLLITE_CODE_LEFTCLICK when a Link has
  //... been Left-clicked.                      
  DWORD code;  
  //When you create a Link with <a href="..." linkid=xxx>
  //... the linkid parameter is filled in this member.
  //.. allowing you to know which link has been clicked
  //... in your HTMLLITE control and then perform a specific action.
  DWORD linkid; 
  //This is a RECT structure which contains the coord's and
  //... dimensions of the Link concerned.      
  RECT  linkrc; 
} NMHTMLLITE, *LPNMHTMLLITE;

Easy peasy.

Extent of HTML implementation?

Well to be honest, I am unsure. I know it seems to use CSS-alike HTML, but it is not really W3C quality :)

Here are a few pieces of markup that MS .NET apps use, so you'll know how much I know:

HTML
<p highlight=#003399 padding-left=20 padding-top=14 padding-bottom=14>
<font face="arial" size=12pt color="white"><b>Microsoft®</b></font>
<br><font face="arial" size=22pt color="white">Visual Studio® .NET Setup
</font></p>
HTML
<p align="right"><a color=#3F4F7F HOVER-COLOR=#C3120C linkid=211>
<b>Text goes here</b></a></p>

Earlier today I checked if Tables would work - they didn't.

Please post comments in the section below, so we can fill the holes in this particular area.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United Kingdom United Kingdom
I am the lead developer of numerous .NET-based networking and communication server systems for Windows, for a company based in Cambridge. Including SMS/SMPP, VOIP and VoiceXML technologies.

Comments and Discussions

 
GeneralAdd text Pin
gene415-Aug-09 5:11
gene415-Aug-09 5:11 
GeneralManaged wrapper Pin
caddzooks24-Aug-07 2:23
caddzooks24-Aug-07 2:23 
Generalthe format of IMG tag using bitmap from resource Pin
zhaowd20013-Aug-06 20:51
zhaowd20013-Aug-06 20:51 
QuestionLicense Pin
gnjunge16-Sep-05 10:42
gnjunge16-Sep-05 10:42 
GeneralMS Money has been using HTMLLite Pin
MikeyN9-Aug-05 15:36
MikeyN9-Aug-05 15:36 
GeneralHTMLLite Vertical Scrolling Pin
AlainCD18-Feb-05 4:51
AlainCD18-Feb-05 4:51 
GeneralRe: HTMLLite Vertical Scrolling Pin
Harry110823-Dec-05 11:14
Harry110823-Dec-05 11:14 
GeneralGreat Pin
Armen Hakobyan17-Jan-05 2:45
professionalArmen Hakobyan17-Jan-05 2:45 
But is htmllite control is free to use?

#define __ARMEN_H__
GeneralRe: Great Pin
Nathan Evans17-Jan-05 5:07
Nathan Evans17-Jan-05 5:07 
GeneralWant IE and IpHelper Help [modified] Pin
eiteit23-Nov-04 4:59
eiteit23-Nov-04 4:59 
QuestionHow to embed this in an editbox instead? Pin
jiac1214-Jan-04 6:36
jiac1214-Jan-04 6:36 
Generalhtmllite.pas Pin
avatarcr29-Oct-03 8:13
sussavatarcr29-Oct-03 8:13 
GeneralI changed the function prototype to the following and everything appears to work fine under VS6/7 Pin
turbo2827-Oct-03 0:59
turbo2827-Oct-03 0:59 
Generalsuported html Pin
Sourcer10-Oct-03 5:57
Sourcer10-Oct-03 5:57 
GeneralRe: suported html Pin
Sourcer10-Oct-03 6:10
Sourcer10-Oct-03 6:10 
GeneralRe: suported html Pin
Nathan Evans10-Oct-03 6:28
Nathan Evans10-Oct-03 6:28 
GeneralRe: suported html Pin
Anonymous21-Apr-04 9:57
Anonymous21-Apr-04 9:57 
GeneralRe: suported html Pin
AlexEvans29-Nov-05 13:09
AlexEvans29-Nov-05 13:09 
GeneralRe: suported html Pin
Genghis8610-Apr-07 16:53
Genghis8610-Apr-07 16:53 
GeneralRe: suported html Pin
LycaonX25-Feb-11 9:40
LycaonX25-Feb-11 9:40 
GeneralGood Work! Pin
lachlan7212-Aug-03 13:33
lachlan7212-Aug-03 13:33 
GeneralMarkup Pin
mabZERO12-Aug-03 8:46
mabZERO12-Aug-03 8:46 
GeneralRe: Markup Pin
mabZERO12-Aug-03 10:00
mabZERO12-Aug-03 10:00 
GeneralRe: Markup Pin
Nathan Evans12-Aug-03 11:15
Nathan Evans12-Aug-03 11:15 
GeneralRe: Markup Pin
Nathan Evans12-Aug-03 11:24
Nathan Evans12-Aug-03 11:24 

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.