HTML Control

By using the HTML control, developers can allow their applications to display HTML pages that are either obtained locally or downloaded dynamically from the Internet or an intranet. These pages can use all the features of Pocket Internet Explorer, including scripting, ActiveX® controls, and Extensible Markup Language (XML).

Note   The Windows Mobile SDK includes two Win32 samples, Browse and HTMLHost, that demonstrate how to use the HTML control.

The HTML Control API has been extended to include a DTM_NAVIGATE message (shown in the following code) that causes the control to download and display a specific URL. As a result, developers can now wrap the functionality of Microsoft Pocket Internet Explorer directly into their applications.

#include <htmlctrl.h>

// Create the control. 
m_hwndHTML = CreateWindow(WC_HTML,  NULL, 
             WS_CHILD | WS_VISIBLE | HS_NOSCROLL,
             0, 0, 100, 100, m_hwndContainer,
             NULL, HINST_RESDLL, NULL);
if (m_hwndHTML == NULL)
{
    // CreateWindow failed.
    MessageBox(NULL, _T("Can't create window."),
               _T("Warning"), MB_OK);
    exit(0);  // Replace with specific error handling.
}
if (!SendMessage(m_hwndHTML, DTM_ENABLESCRIPTING, 0, 0))
{
    // SendMessage failed.
    MessageBox(NULL, _T("Can't send message."),
               _T("Warning"), MB_OK);
    exit(0);  // Replace with specific error handling.
}
if (!SendMessage(m_hwndHTML, DTM_ZOOMLEVEL, 0, 1))
{
    // SendMessage failed.
    MessageBox(NULL, _T("Can't send message."),
              _T("Warning"), MB_OK);
    exit(0);  // Replace with specific error handling.
}
if (fWantToAddHtmlContent) {
    // This inserts HTML directly.
    if (!SendMessage(m_hwndHTML, DTM_ADDTEXTW, FALSE,
        (LPARAM)pszHTMLContent))
    {
        // SendMessage failed.
        MessageBox(NULL, _T("Can't send message."),
                   _T("Warning"), MB_OK);
        exit(0);  // Replace with specific error handling.
    }
    if (!SendMessage(m_hwndHTML, DTM_ENDOFSOURCE, 0, 0))
    {
        // SendMessage failed.
        MessageBox(NULL, _T("Can't send message."),
                   _T("Warning"), MB_OK);
        exit(0);  // Replace with specific error handling.
    }
} else {
    // This navigates to a URL (including RES:).
    if (!SendMessage(m_hwndHTML, DTM_NAVIGATE, 0, 
        (LPARAM)m_sbi.pszContent))
    {
        // SendMessage failed.
        MessageBox(NULL, _T("Can't send message."),
                   _T("Warning"), MB_OK);
        exit(0);  // Replace with specific error handling.
    }
}

See Also

Windows Mobile Controls

Last updated on Friday, April 22, 2005

© 2005 Microsoft Corporation. All rights reserved.

Send feedback on this topic to the authors.