The Hypertext Markup Language (HTML) viewer control provides a viewer for displaying HTML text and embedded images. The HTML viewer provides the functionality required to implement Microsoft® Pocket Internet Explorer and the Help engine.
You can also create other viewers based on the HTML viewer control. An HTML source can include references to other sources, which may provide different types of data. If the application determines that some of the data it retrieves is of a type other than HTML, it can invoke another type of viewer to display that data.
To use the HTML viewer control, you must include the Htmlctrl.h header file and either link your application with the Htmlview.dll dynamic link, or load the HTML viewer DLL by calling the LoadLibrary function. When you call LoadLibrary, pass "Htmlview.dll" as the lpLibFileName parameter.
Before you can create or use the HTML viewer control, you have to register it by calling the InitHTMLControl function.You create an HTML viewer control by specifying DISPLAYNAME in the lpClassName parameter to the CreateWindow function.
If the image does not load successfully, send a DTM_IMAGEFAIL message, which indicates to the control that it should display the broken image icon.
The following code example shows how to create an HTML viewer control.
#define DISPLAYCLASS TEXT("DISPLAYCLASS")
BOOL g_bMakeFit = TRUE; // DTM_ENABLESHRINK Shrink-enable flag
TCHAR const c_szHTMLControlLibrary[] = TEXT("htmlview.dll");
HINSTANCE g_hInstHTMLCtrl; // HTML Control Viewer instance
HINSTANCE hInstance; // Application instance
HWND m_hwndHtml; // Handle to HTML DISPLAYCLASS window
g_hInstHTMLCtrl = LoadLibrary(c_szHTMLControlLibrary);
InitHTMLControl(hInstance);
LRESULT WndProc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch (message)
{
case WM_CREATE:
{
m_hwndHtml = CreateWindow(DISPLAYCLASS, NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPSIBLINGS,
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
hWnd, (HMENU)IDC_HTMLVIEW, g_hInst, NULL);
SetFocus(m_hwndHtml);
PostMessage(m_hwndHtml, DTM_ENABLESHRINK, 0, g_bMakeFit);
break;
}
.
.
.
}
}
Note When calling the LoadLibrary and CreateWindow functions, the library or class name has to be a Unicode string. Use the TEXT macro to cast a string as Unicode, for example, TEXT("Htmlview.dll").
Pocket Internet Explorer is an example of an application that uses the HTML viewer control. The application (Webview.exe) links with the dynamic-link library that provides the HTML viewer control (Htmlview.dll). The application provides the user interface, retrieves the data from the Uniform Resource Locators (URL), and interprets the data.
The following illustration describes how the application interacts with the HTML viewer control.
Interaction between the application and HTML viewer control
Note The HTML viewer control interface is not an ActiveX control, and does not expose any COM interfaces.