Creating an HTML Viewer Control for Palm-size PC

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.

    To create the HTML viewer control

  1. Load the HTML viewer DLL by calling the LoadLibrary function, specifying Htmlview.dll in the lpLibFileName parameter.
  2. Register the HTML viewer control class by calling the InitHTMLControl function.
  3. Create a window for the HTML viewer control by calling the CreateWindow function, specifying DISPLAYNAME in the lpClassName parameter.

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”).

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: 
    {
      DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL | 
                      WS_CLIPSIBLINGS;

      m_hwndHtml = CreateWindow (DISPLAYCLASS, 
                                 NULL,
                                 dwStyle,
                                 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;
    }
}
}