Click here to Skip to main content
Click here to Skip to main content

HOWTO: Use the undocumented HTMLLITE.DLL component

, 8 Aug 2003
Rate this:
Please Sign up or sign in to vote.
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 Smile | :)

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

<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>
<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

Share

About the Author

Nathan Evans
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 Pinmembergene415-Aug-09 6:11 
GeneralManaged wrapper Pinmembercaddzooks24-Aug-07 3:23 
Generalthe format of IMG tag using bitmap from resource Pinmemberzhaowd20013-Aug-06 21:51 
QuestionLicense Pinmembergnjunge16-Sep-05 11:42 
GeneralMS Money has been using HTMLLite PinmemberMikeyN9-Aug-05 16:36 

Did the Spy thing on MS Money some time ago, I thougth HTMLLite was something written by msmoney team. I dropped it, didn't catch the DLL part.
 
Great Job!
 
Still curious if it can be shipped with app.
Maybe gotta include $29 MSMoney with the product Wink | ;)
 

 
Mikey_N
GeneralHTMLLite Vertical Scrolling PinmemberAlainCD18-Feb-05 5:51 
GeneralRe: HTMLLite Vertical Scrolling PinmemberHarry110823-Dec-05 12:14 
GeneralGreat PinmemberArmen Hakobyan17-Jan-05 3:45 
GeneralRe: Great PinmemberNathan Evans17-Jan-05 6:07 
GeneralWant IE and IpHelper Help [modified] Pinmembereiteiteit23-Nov-04 5:59 
QuestionHow to embed this in an editbox instead? Pinmemberchiac14-Jan-04 7:36 
Generalhtmllite.pas Pinsussavatarcr29-Oct-03 9:13 
GeneralI changed the function prototype to the following and everything appears to work fine under VS6/7 Pinmemberturbo2827-Oct-03 1:59 
Generalsuported html PinmemberSourcer10-Oct-03 6:57 
GeneralRe: suported html PinmemberSourcer10-Oct-03 7:10 
GeneralRe: suported html PinmemberNathan Evans10-Oct-03 7:28 
GeneralRe: suported html PinsussAnonymous21-Apr-04 10:57 
GeneralRe: suported html PinmemberAlexEvans29-Nov-05 14:09 
GeneralRe: suported html PinmemberGenghis8610-Apr-07 17:53 
GeneralRe: suported html PinmemberLycaonX25-Feb-11 10:40 
GeneralGood Work! Pinmemberlachlan7212-Aug-03 14:33 
GeneralMarkup PinmembermabZERO12-Aug-03 9:46 
GeneralRe: Markup PinmembermabZERO12-Aug-03 11:00 
GeneralRe: Markup PinsussNathan Evans12-Aug-03 12:15 
GeneralRe: Markup PinsussNathan Evans12-Aug-03 12:24 
QuestionVS 6? PinmemberPascal Binggeli12-Aug-03 6:59 
AnswerRe: VS 6? PinmembermabZERO12-Aug-03 8:47 
GeneralRe: VS 6? PinmemberPascal Binggeli12-Aug-03 9:40 
Generalkudos mate PinmemberStephane Rodriguez.10-Aug-03 5:03 
GeneralRe: kudos mate PinsussNathan Evans10-Aug-03 6:00 
GeneralRe: kudos mate PinmemberJohn Guin12-Aug-03 8:29 
Generalmanaged control PinmemberSampoSoft9-Aug-03 18:03 
GeneralRe: managed control PinsussNathan Evans10-Aug-03 7:10 
GeneralRe: managed control PinmemberDeckards11-Aug-04 5:59 
GeneralRe: managed control - Here's a start Pinmembercaddzooks23-Aug-07 23:05 
GeneralTry QHTM instead PinmemberI'm a code monkey9-Aug-03 13:46 
GeneralRe: Try QHTM instead PinmemberPaul Selormey9-Aug-03 13:50 
GeneralRe: Try QHTM instead PinsussNathan Evans9-Aug-03 13:54 
GeneralRe: Try QHTM instead PinmemberBlake Coverett9-Aug-03 14:12 
GeneralRe: Try QHTM instead PinsussNathan Evans9-Aug-03 14:20 
GeneralRe: Try QHTM instead PinmemberI'm a code monkey10-Aug-03 4:25 
GeneralOr try HtmLayout Pinmemberc-smile15-Sep-03 8:14 
GeneralRe: Or try HtmLayout PinmemberRavi Bhavnani18-Feb-05 6:48 
GeneralCorrect URL, HTMLayout with CSS support Pinmemberc-smile18-Feb-05 7:50 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 9 Aug 2003
Article Copyright 2003 by Nathan Evans
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid