How to give HTML to QHTM
There are four ways to put HTML into the QHTM control. The Windows API example demonstrates most of these techniques.
As the caption of the control
When you create a QHTM control, either in a dialog resource script or by using
CreateWindow(Ex)(...) you have the opportunity to set some caption text for the window.
This is the actual text that QHTM will use initially. You can leave it blank with no problems but you can remove initialisation code if you set yoru initial text here.
Windows allow you to set the caption text of a window by using the API
SetWindowText(...) or by sending the control a
WM_SETTEXT message. QHTM is no different and will accept HTML in either of these formats.
From a file
This is the easiest method to manage, especially if you have designers working on the HTML as it allows your program to be built first and the HTML loaded from disk without any need for the designers to compile your software.
See also QHTM_PrintSetTextFile
You should use this option if you want to your application to survive without any supporting files. Great if you have a small application with lots of HTML content as it saves disk space.
To add a HTML file to your resources you will probably have to edit your resource script by hand. This isn't as bad as your think. This is an extract from the MFC example's RC2 file:
LOGO.PNG RCDATA DISCARDABLE "res\\logo.png"
ID_ABOUT_HTML_RESOURCE RCDATA DISCARDABLE "res\\about.html"
ID_DEFAULT_HTML RCDATA DISCARDABLE "res\\Default.html"
ABOUT.PNG RCDATA DISCARDABLE "res\\About.png"
REFRESH.PNG RCDATA DISCARDABLE "res\\Refresh.png"
Note that you can use either
RT_HTML as the resource type as QHTM will happily load either.
See also QHTM_PrintSetTextResource
But how does QHTM find images?
When QHTM comes across an image in your HTML it looks for a a marker, "RES:", at the start of the image name, if it finds this marker then it reads the image from the resources e.g.