Currently viewing: GipsySoft » Front Page» QHTM

Quick guide to using QHTM

I'll using that you are using Visual C++. The basic method is the same for pretty much any programming language.

These are the basic steps:

  • Include the QHTM header file
  • Link the library to your application
  • Initialise the library
  • Add the control to your dialog
  • Give QHTM some HTML

Include the QHTM header

This is the easiest bit:

#include "QHTM.h"

Link the library

Note: With the latest build you don't need to do this as QHTM will emit a command to the link to add QHTM.LIB into your project providing you have set an addition library path.

All we need to do is tell Visual C++ where to find the QHTM functions. We bring up the project settings (ALT+F7), choose the correct project, select the appropriate project, choose All Configurations and select the Link tab. We then add in the appropriate library name. For the Free version of QHTM the library name is QHTMLight.lib, for the paid for version it's QHTM.lib.

Initialise the library

We need to add a single call to QHTM_Initialize somewhere in our application startup. Traditionally this would be in WinMain, or in MFC this would be in the InitInstance member of your CWinApp desrive class.

//	Plain Win32 API would look like this
QHTM_Initialize( hInstance );

//	MFC might look like this
QHTM_Initialize( AfxGetInstanceHandle() )

Add the control to your dialog

Once the library is initialised we are free to use it anywhere a normal Win32 window can be used. This includes adding it to a dialog box or using CreateWindow APIs to create it. For this example we'll add it to a dialog.

We first add a custom control to the dialog. Select the custom control icon from the control palette, see the image on the right.

We set the caption1 to be the HTML we want displayed and set the class2 to be the QHTM window class, which is QHTM_Window_Class_001.

Give QHTM some HTML

Because we have added the control to a dialog and at the same time set the caption to be our HTML we don't need to write any more code. So, in one single line of code (QHTM_Initialize) we have added a HTML control to our dialog.

There is one 'gotcha' though. Resources are restricted to the amount of text that a caption can have. Whilst this is mostly okay for plain text HTML places much higher demands. Sometimes the text you want in the control is too big and needs to be sent to the control manually.

Luckily this is easy to achieve. QHTM will use whatever text you send it. This means you can use the SetDlgItemText or SetWindowText API functions to send QHTM some HTML.


SetDlgItemText( hwndDlg, IDC_QHTM, "Some <b>HTML in bold</b>" );