CDHtmlDialog Class

Is used to create dialog boxes that use HTML rather than dialog resources to implement their user interface.

Syntax

class CDHtmlDialog : public CDialog, public CDHtmlEventSink

Members

Public Constructors

Name Description
CDHtmlDialog::CDHtmlDialog Constructs a CDHtmlDialog object.
CDHtmlDialog::~CDHtmlDialog Destroys a CDHtmlDialog object.

Public Methods

Name Description
CDHtmlDialog::CanAccessExternal Overridable that is called as an access check to see whether scripting objects on the loaded page can access the external dispatch of the control site. Checks to make sure the dispatch is either safe for scripting or the current zone allows for objects that aren't safe for scripting.
CDHtmlDialog::CreateControlSite Overridable used to create a control site instance to host the WebBrowser control on the dialog.
CDHtmlDialog::DDX_DHtml_AxControl Exchanges data between a member variable and the property value of an ActiveX control on an HTML page.
CDHtmlDialog::DDX_DHtml_CheckBox Exchanges data between a member variable and a check box on an HTML page.
CDHtmlDialog::DDX_DHtml_ElementText Exchanges data between a member variable and any HTML element property on an HTML page.
CDHtmlDialog::DDX_DHtml_Radio Exchanges data between a member variable and a radio button on an HTML page.
CDHtmlDialog::DDX_DHtml_SelectIndex Gets or sets the index of a list box on an HTML page.
CDHtmlDialog::DDX_DHtml_SelectString Gets or sets the display text of a list box entry (based on the current index) on an HTML page.
CDHtmlDialog::DDX_DHtml_SelectValue Gets or sets the value of a list box entry (based on the current index) on an HTML page.
CDHtmlDialog::DestroyModeless Destroys a modeless dialog box.
CDHtmlDialog::EnableModeless Enables modeless dialog boxes.
CDHtmlDialog::FilterDataObject Allows the dialog to filter clipboard data objects created by the hosted browser.
CDHtmlDialog::GetControlDispatch Retrieves the IDispatch interface on an ActiveX control embedded in the HTML document.
CDHtmlDialog::GetControlProperty Retrieves the requested property of the specified ActiveX control.
CDHtmlDialog::GetCurrentUrl Retrieves the Uniform Resource Locator (URL) associated with the current document.
CDHtmlDialog::GetDHtmlDocument Retrieves the IHTMLDocument2 interface on the currently loaded HTML document.
CDHtmlDialog::GetDropTarget Called by the contained WebBrowser control when it's being used as a drop target to allow the dialog to supply an alternative IDropTarget.
CDHtmlDialog::GetElement Gets an interface on an HTML element.
CDHtmlDialog::GetElementHtml Retrieves the innerHTML property of an HTML element.
CDHtmlDialog::GetElementInterface Retrieves the requested interface pointer from an HTML element.
CDHtmlDialog::GetElementProperty Retrieves the value of an HTML element's property.
CDHtmlDialog::GetElementText Retrieves the innerText property of an HTML element.
CDHtmlDialog::GetEvent Gets the IHTMLEventObj pointer to the current event object.
CDHtmlDialog::GetExternal Gets the host's IDispatch interface.
CDHtmlDialog::GetHostInfo Retrieves the host's UI capabilities.
CDHtmlDialog::GetOptionKeyPath Retrieves the registry key under which user preferences are stored.
CDHtmlDialog::HideUI Hides the host's UI.
CDHtmlDialog::IsExternalDispatchSafe Indicates whether the host's IDispatch interface is safe for scripting.
CDHtmlDialog::LoadFromResource Loads the specified resource into the WebBrowser control.
CDHtmlDialog::Navigate Navigates to the specified URL.
CDHtmlDialog::OnBeforeNavigate Called by the framework before a navigation event is fired.
CDHtmlDialog::OnDocumentComplete Called by the framework to notify an application when a document has reached the READYSTATE_COMPLETE state.
CDHtmlDialog::OnDocWindowActivate Called by the framework when the document window is activated or deactivated.
CDHtmlDialog::OnFrameWindowActivate Called by the framework when the frame window is activated or deactivated.
CDHtmlDialog::OnInitDialog Called in response to the WM_INITDIALOG message.
CDHtmlDialog::OnNavigateComplete Called by the framework after a navigation event is completed.
CDHtmlDialog::ResizeBorder Alerts the object that it needs to resize its border space.
CDHtmlDialog::SetControlProperty Sets the property of an ActiveX control to a new value.
CDHtmlDialog::SetElementHtml Sets the innerHTML property of an HTML element.
CDHtmlDialog::SetElementProperty Sets a property of an HTML element.
CDHtmlDialog::SetElementText Sets the innerText property of an HTML element.
CDHtmlDialog::SetExternalDispatch Sets the host's IDispatch interface.
CDHtmlDialog::SetHostFlags Sets the host's UI flags.
CDHtmlDialog::ShowContextMenu Called when a context menu is about to be displayed.
CDHtmlDialog::ShowUI Shows the host's UI.
CDHtmlDialog::TranslateAccelerator Called to process menu accelerator-key messages.
CDHtmlDialog::TranslateUrl Called to modify the URL to be loaded.
CDHtmlDialog::UpdateUI Called to notify the host that the command state has changed.

Public Data Members

Name Description
CDHtmlDialog::m_bUseHtmlTitle Indicates whether to use the HTML document's title as the dialog caption.
CDHtmlDialog::m_nHtmlResID Resource ID of HTML resource to be displayed.
CDHtmlDialog::m_pBrowserApp A pointer to a Web browser application.
CDHtmlDialog::m_spHtmlDoc A pointer to an HTML document.
CDHtmlDialog::m_strCurrentUrl The current URL.
CDHtmlDialog::m_szHtmlResID String version of the HTML resource ID.

Remarks

CDHtmlDialog can load the HTML to be displayed from either an HTML resource or a URL.

CDHtmlDialog can also do data exchange with HTML controls and handle events from HTML controls, such as button clicks.

Inheritance Hierarchy

CObject

CDHtmlSinkHandlerBase2

CDHtmlSinkHandlerBase1

CCmdTarget

CDHtmlSinkHandler

CWnd

CDHtmlEventSink

CDialog

CDHtmlDialog

Requirements

Header: afxdhtml.h

DDX_DHtml Helper Macros

The DDX_DHtml helper macros allow easy access to the commonly used properties of controls on an HTML page.

Data Exchange Macros

Name Description
DDX_DHtml_ElementValue Sets or retrieves the Value property from the selected control.
DDX_DHtml_ElementInnerText Sets or retrieves the text between the start and end tags of the current element.
DDX_DHtml_ElementInnerHtml Sets or retrieves the HTML between the start and end tags of the current element.
DDX_DHtml_Anchor_Href Sets or retrieves the destination URL or anchor point.
DDX_DHtml_Anchor_Target Sets or retrieves the target window or frame.
DDX_DHtml_Img_Src Sets or retrieves the name of an image or a video clip in the document.
DDX_DHtml_Frame_Src Sets or retrieves the URL of the associated frame.
DDX_DHtml_IFrame_Src Sets or retrieves the URL of the associated frame.

CDHtmlDialog::CanAccessExternal

Overridable that is called as an access check to see whether scripting objects on the loaded page can access the external dispatch of the control site. Checks to make sure the dispatch is either safe for scripting or the current zone allows for objects that aren't safe for scripting.

virtual BOOL CanAccessExternal();

Return Value

Nonzero if successful; otherwise 0.

CDHtmlDialog::CDHtmlDialog

Constructs a resource-based dynamic HTML dialog box.

CDHtmlDialog();

CDHtmlDialog(
    LPCTSTR lpszTemplateName,
    LPCTSTR szHtmlResID,
    CWnd *pParentWnd = NULL);

CDHtmlDialog(
    UINT nIDTemplate,
    UINT nHtmlResID = 0,
    CWnd *pParentWnd = NULL);

Parameters

lpszTemplateName
The null-terminated string that is the name of a dialog-box template resource.

szHtmlResID
The null-terminated string that is the name of an HTML resource.

pParentWnd
A pointer to the parent or owner window object (of type CWnd) to which the dialog object belongs. If it's NULL, the dialog object's parent window is set to the main application window.

nIDTemplate
Contains the ID number of a dialog-box template resource.

nHtmlResID
Contains the ID number of an HTML resource.

Remarks

The second form of the constructor provides access to the dialog resource through the template name. The third form of the constructor provides access to the dialog resource through the ID of the resource template. Usually, the ID begins with the IDD_ prefix.

CDHtmlDialog::~CDHtmlDialog

Destroys a CDHtmlDialog object.

virtual ~CDHtmlDialog();

Remarks

The CWnd::DestroyWindow member function must be used to destroy modeless dialog boxes that are created by CDialog::Create.

CDHtmlDialog::CreateControlSite

Overridable used to create a control site instance to host the WebBrowser control on the dialog.

virtual BOOL CreateControlSite(
    COleControlContainer* pContainer,
    COleControlSite** ppSite,
    UINT /* nID */,
    REFCLSID /* clsid */);

Parameters

pContainer
A pointer to the COleControlContainer object.

ppSite
A pointer to a pointer to a COleControlSite.

Return Value

Nonzero if successful; otherwise 0.

Remarks

You can override this member function to return an instance of your own control site class.

CDHtmlDialog::DDX_DHtml_AxControl

Exchanges data between a member variable and the property value of an ActiveX control on an HTML page.

void DDX_DHtml_AxControl(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    VARIANT& var);

void DDX_DHtml_AxControl(
    CDataExchange* pDX,
    LPCTSTR szId,
    LPCTSTR szPropName,
    VARIANT& var);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value of the object tag's ID parameter in the HTML source for the ActiveX control.

dispId
The dispatch ID of the property with which you want to exchange data.

szPropName
The name of the property.

var
The data member, of type VARIANT, COleVariant, or CComVariant, that holds the value exchanged with the ActiveX control property.

Example

// COleVariant m_varSliderValue;
DDX_DHtml_AxControl(pDX, _T("slider1"), 0x0b /* Value */, m_varSliderValue);

CDHtmlDialog::DDX_DHtml_CheckBox

Exchanges data between a member variable and a check box on an HTML page.

void DDX_DHtml_CheckBox(
    CDataExchange* pDX,
    LPCTSTR szId,
    int& value);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value that you specified for the HTML control's ID parameter.

value
The value being exchanged.

Example

// int m_nItalic;
DDX_DHtml_CheckBox(pDX, L"italic", m_nItalic);

CDHtmlDialog::DDX_DHtml_ElementText

Exchanges data between a member variable and any HTML element property on an HTML page.

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    CString& value);

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    short& value);

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    int& value);

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    long& value);

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    DWORD& value);

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    float& value);

void DDX_DHtml_ElementText(
    CDataExchange* pDX,
    LPCTSTR szId,
    DISPID dispId,
    double& value);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value that you specified for the HTML control's ID parameter.

dispId
The dispatch ID of the HTML element with which you want to exchange data.

value
The value being exchanged.

CDHtmlDialog::DDX_DHtml_Radio

Exchanges data between a member variable and a radio button on an HTML page.

void DDX_DHtml_Radio(
    CDataExchange* pDX,
    LPCTSTR szId,
    long& value);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value that you specified for the HTML control's ID parameter.

value
The value being exchanged.

CDHtmlDialog::DDX_DHtml_SelectIndex

Gets or sets the index of a list box on an HTML page.

void DDX_DHtml_SelectIndex(
    CDataExchange* pDX,
    LPCTSTR szId,
    long& value);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value that you specified for the HTML control's id parameter.

value
The value being exchanged.

CDHtmlDialog::DDX_DHtml_SelectString

Gets or sets the display text of a list box entry (based on the current index) on an HTML page.

void DDX_DHtml_SelectString(
    CDataExchange* pDX,
    LPCTSTR szId,
    CString& value);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value that you specified for the HTML control's ID parameter.

value
The value being exchanged.

CDHtmlDialog::DDX_DHtml_SelectValue

Gets or sets the value of a list box entry (based on the current index) on an HTML page.

void DDX_DHtml_SelectValue(
    CDataExchange* pDX,
    LPCTSTR szId,
    CString& value);

Parameters

pDX
A pointer to a CDataExchange object.

szId
The value that you specified for the HTML control's ID parameter.

value
The value being exchanged.

Example

// CString m_strBlurDir;
DDX_DHtml_SelectValue(pDX, L"blurDir", m_strBlurDir);

CDHtmlDialog::DestroyModeless

Detaches a modeless dialog box from the CDHtmlDialog object and destroys the object.

void DestroyModeless();

CDHtmlDialog::EnableModeless

Enables modeless dialog boxes.

STDMETHOD(EnableModeless)(BOOL fEnable);

Parameters

fEnable
See fEnable in IDocHostUIHandler::EnableModeless in the Windows SDK.

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::EnableModeless, as described in the Windows SDK.

CDHtmlDialog::FilterDataObject

Allows the dialog to filter clipboard data objects created by the hosted browser.

STDMETHOD(FilterDataObject)(
    IDataObject* pDO,
    IDataObject** ppDORet);

Parameters

pDO
See pDO in IDocHostUIHandler::FilterDataObject in the Windows SDK.

ppDORet
See ppDORet in IDocHostUIHandler::FilterDataObject in the Windows SDK.

Return Value

Returns S_FALSE.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::FilterDataObject, as described in the Windows SDK.

CDHtmlDialog::GetControlDispatch

Retrieves the IDispatch interface on an ActiveX control embedded in the HTML document returned by GetDHtmlDocument.

HRESULT GetControlDispatch(
    LPCTSTR szId,
    IDispatch** ppdisp);

Parameters

szId
The HTML ID of an ActiveX control.

ppdisp
The IDispatch interface of the control if found in the Web page.

Return Value

A standard HRESULT value.

CDHtmlDialog::GetControlProperty

Retrieves the requested property of the specified ActiveX control.

VARIANT GetControlProperty(
    LPCTSTR szId,
    LPCTSTR szPropName);

VARIANT GetControlProperty(
    LPCTSTR szId,
    DISPID dispId);

VARIANT GetControlProperty(
    IDispatch* pdispControl,
    DISPID dispId);

Parameters

szId
The HTML ID of an ActiveX control.

szPropName
The name of a property in the default locale of the current user.

pdispControl
The IDispatch pointer of an ActiveX control.

dispId
The dispatch ID of a property.

Return Value

A variant containing the requested property or an empty variant if the control or property couldn't be found.

Remarks

The overloads are listed from least efficient at the top to most efficient at the bottom.

CDHtmlDialog::GetCurrentUrl

Retrieves the Uniform Resource Locator (URL) associated with the current document.

void GetCurrentUrl(CString& szUrl);

Parameters

szUrl
A CString object containing the URL to retrieve.

CDHtmlDialog::GetDHtmlDocument

Retrieves the IHTMLDocument2 interface on the currently loaded HTML document.

HRESULT GetDHtmlDocument(IHTMLDocument2 **pphtmlDoc);

Parameters

**pphtmlDoc A pointer to a pointer to an HTML document.

Return Value

A standard HRESULT. Returns S_OK if successful.

CDHtmlDialog::GetDropTarget

Called by the contained WebBrowser control when it's being used as a drop target to allow the dialog to supply an alternative IDropTarget.

STDMETHOD(GetDropTarget)(
    IDropTarget* pDropTarget,
    IDropTarget** ppDropTarget);

Parameters

pDropTarget
See pDropTarget in IDocHostUIHandler::GetDropTarget in the Windows SDK.

ppDropTarget
See ppDropTarget in IDocHostUIHandler::GetDropTarget in the Windows SDK.

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::GetDropTarget, as described in the Windows SDK.

CDHtmlDialog::GetElement

Returns an interface on the HTML element specified by szElementId.

HRESULT GetElement(
    LPCTSTR szElementId,
    IDispatch** ppdisp,
    BOOL* pbCollection = NULL);

HRESULT GetElement(
    LPCTSTR szElementId,
    IHTMLElement** pphtmlElement);

Parameters

szElementId
The ID of an HTML element.

ppdisp
An IDispatch pointer to the requested element or collection of elements.

pbCollection
A BOOL indicating whether the object represented by ppdisp is a single element or a collection of elements.

pphtmlElement
An IHTMLElement pointer to the requested element.

Return Value

A standard HRESULT value.

Remarks

Use the first overload if you need to handle conditions in which there may be more than one element with the specified ID. You can use the last parameter to find out whether the returned interface pointer is to a collection or a single item. If the interface pointer is on a collection, you can query for the IHTMLElementCollection and use its item property to refer to the elements by ordinal position.

The second overload will fail if there's more than one element with the same ID in the page.

CDHtmlDialog::GetElementHtml

Retrieves the innerHTML property of the HTML element identified by szElementId.

BSTR GetElementHtml(LPCTSTR szElementId);

Parameters

szElementId
The ID of an HTML element.

Return Value

The innerHTML property of the HTML element identified by szElementId or NULL if the element couldn't be found.

CDHtmlDialog::GetElementInterface

Retrieves the requested interface pointer from the HTML element identified by szElementId.

template <class Q> HRESULT GetElementInterface(
    LPCTSTR szElementId,
    Q** ppvObj);

HRESULT GetElementInterface(
    LPCTSTR szElementId,
    REFIID refiid,
    void** ppvObj);

Parameters

szElementId
The ID of an HTML element.

ppvObj
Address of a pointer that will be filled with the requested interface pointer if the element is found and the query succeeds.

refiid
The interface ID (IID) of the requested interface.

Return Value

A standard HRESULT value.

Example

CComPtr<IHTMLInputButtonElement> spBtn1;
CComPtr<IHTMLInputButtonElement> spBtn2;
HRESULT hr = S_OK;

// Use the template overload
hr = GetElementInterface(L"Button1", &spBtn1);

// Use the nontemplate overload
hr = GetElementInterface(L"Button1", IID_IHTMLInputButtonElement,
                         reinterpret_cast<void **>(&spBtn2));

CDHtmlDialog::GetElementProperty

Retrieves the value of the property identified by dispId from the HTML element identified by szElementId.

VARIANT GetElementProperty(
    LPCTSTR szElementId,
    DISPID dispId);

Parameters

szElementId
The ID of an HTML element.

dispId
The dispatch ID of a property.

Return Value

The value of the property or an empty variant if the property or element couldn't be found.

CDHtmlDialog::GetElementText

Retrieves the innerText property of the HTML element identified by szElementId.

BSTR GetElementText(LPCTSTR szElementId);

Parameters

szElementId
The ID of an HTML element.

Return Value

The innerText property of the HTML element identified by szElementId or NULL if the property or element couldn't be found.

CDHtmlDialog::GetEvent

Returns the IHTMLEventObj pointer to the current event object.

HRESULT GetEvent(IHTMLEventObj** ppEventObj);

Parameters

ppEventObj
Address of a pointer that will be filled with the IHTMLEventObj interface pointer.

Return Value

A standard HRESULT value.

Remarks

This function should only be called from within a DHTML event handler.

CDHtmlDialog::GetExternal

Gets the host's IDispatch interface.

STDMETHOD(GetExternal)(IDispatch** ppDispatch);

Parameters

ppDispatch
See ppDispatch in IDocHostUIHandler::GetExternal in the Windows SDK.

Return Value

Returns S_OK on success or E_NOTIMPL on failure.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::GetExternal, as described in the Windows SDK.

CDHtmlDialog::GetHostInfo

Retrieves the host's UI capabilities.

STDMETHOD(GetHostInfo)(DOCHOSTUIINFO* pInfo);

Parameters

pInfo
See pInfo in IDocHostUIHandler::GetHostInfo in the Windows SDK.

Return Value

Returns S_OK.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::GetHostInfo, as described in the Windows SDK.

CDHtmlDialog::GetOptionKeyPath

Retrieves the registry key under which user preferences are stored.

STDMETHOD(GetOptionKeyPath)(
    LPOLESTR* pchKey,
    DWORD dw);

Parameters

pchKey
See pchKey in IDocHostUIHandler::GetOptionKeyPath in the Windows SDK.

dw
See dw in IDocHostUIHandler::GetOptionKeyPath in the Windows SDK.

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::GetOptionKeyPath, as described in the Windows SDK.

CDHtmlDialog::HideUI

Hides the host's UI.

STDMETHOD(HideUI)(void);

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::HideUI, as described in the Windows SDK.

CDHtmlDialog::IsExternalDispatchSafe

Indicates whether the host's IDispatch interface is safe for scripting.

virtual BOOL IsExternalDispatchSafe();

Return Value

Returns FALSE.

CDHtmlDialog::LoadFromResource

Loads the specified resource into the WebBrowser control in the DHTML dialog.

BOOL LoadFromResource(LPCTSTR lpszResource);
BOOL LoadFromResource(UINT nRes);

Parameters

lpszResource
A pointer to a string containing the name of the resource to load.

nRes
The ID of the resource to load.

Return Value

TRUE if successful; otherwise FALSE.

CDHtmlDialog::m_bUseHtmlTitle

Indicates whether to use the HTML document's title as the dialog caption.

BOOL m_bUseHtmlTitle;

Remarks

If m_bUseHtmlTitle is TRUE, the dialog caption is set equal to the title of the HTML document; otherwise, the caption in the dialog resource is used.

CDHtmlDialog::m_nHtmlResID

Resource ID of HTML resource to be displayed.

UINT m_nHtmlResID;

Example

CDHtmlDialog mydialog(IDD_MYDHTMLDLG);
mydialog.m_nHtmlResID = IDR_HTML_MYDHTMLDLG;
mydialog.DoModal();

CDHtmlDialog::m_pBrowserApp

A pointer to a Web browser application.

CComPtr <IWebBrowser2> m_pBrowserApp;

CDHtmlDialog::m_spHtmlDoc

A pointer to an HTML document.

CComPtr<IHTMLDocument2> m_spHtmlDoc;

CDHtmlDialog::m_strCurrentUrl

The current URL.

CString m_strCurrentUrl;

CDHtmlDialog::m_szHtmlResID

String version of the HTML resource ID.

LPTSTR m_szHtmlResID;

Example

CDHtmlDialog mydialog(IDD_MYDHTMLDLG);
TCHAR szResID[] = _T("HTML_PAGE");
mydialog.m_szHtmlResID = szResID;
mydialog.DoModal();

Navigates to the resource identified by the URL that is specified by lpszURL.

void Navigate(
    LPCTSTR lpszURL,
    DWORD dwFlags = 0,
    LPCTSTR lpszTargetFrameName = NULL,
    LPCTSTR lpszHeaders = NULL,
    LPVOID lpvPostData = NULL,
    DWORD dwPostDataLen = 0);

Parameters

lpszURL
A pointer to a string containing the URL to be targeted.

dwFlags
The flags of a variable that specifies whether to add the resource to the history list, whether to read to the cache or write from the cache, and whether to display the resource in a new window. The variable can be a combination of the values defined by the BrowserNavConstants enumeration.

lpszTargetFrameName
A pointer to a string that contains the name of the frame in which to display the resource.

lpszHeaders
A pointer to a value that specifies the HTTP headers to send to the server. These headers are added to the default Internet Explorer headers. The headers can specify such information as the action required of the server, the type of data being passed to the server, or a status code. This parameter is ignored if the URL isn't an HTTP URL.

lpvPostData
A pointer to the data to send with the HTTP POST transaction. For example, the POST transaction is used to send data gathered by an HTML form. If this parameter doesn't specify any post data, Navigate issues an HTTP GET transaction. This parameter is ignored if the URL isn't an HTTP URL.

dwPostDataLen
Data to send with the HTTP POST transaction. For example, the POST transaction is used to send data gathered by an HTML form. If this parameter doesn't specify any post data, Navigate issues an HTTP GET transaction. This parameter is ignored if URL isn't an HTTP URL.

CDHtmlDialog::OnBeforeNavigate

Called by the framework to cause an event to fire before a navigation occurs.

virtual void OnBeforeNavigate(
    LPDISPATCH pDisp,
    LPCTSTR szUrl);

Parameters

pDisp
A pointer to an IDispatch object.

szUrl
A pointer to a string containing the URL to navigate to.

CDHtmlDialog::OnDocumentComplete

Called by the framework to notify an application when a document has achieved the READYSTATE_COMPLETE state.

virtual void OnDocumentComplete(
    LPDISPATCH pDisp,
    LPCTSTR szUrl);

Parameters

pDisp
A pointer to an IDispatch object.

szUrl
A pointer to a string containing the URL that was navigated to.

CDHtmlDialog::OnDocWindowActivate

Called by the framework when the document window is activated or deactivated.

STDMETHOD(OnDocWindowActivate)(BOOL fActivate);

Parameters

fActivate
See fActivate in IDocHostUIHandler::OnDocWindowActivate in the Windows SDK.

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::OnDocWindowActivate, as described in the Windows SDK.

CDHtmlDialog::OnFrameWindowActivate

Called by the framework when the frame window is activated or deactivated.

STDMETHOD(OnFrameWindowActivate)(BOOL fActivate);

Parameters

fActivate
See fActivate in IDocHostUIHandler::OnFrameWindowActivate in the Windows SDK.

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::OnFrameWindowActivate, as described in the Windows SDK.

CDHtmlDialog::OnInitDialog

Called in response to the WM_INITDIALOG message.

virtual BOOL OnInitDialog();

Return Value

The default implementation returns TRUE.

Remarks

This message is sent to the dialog box during the Create, CreateIndirect, or DoModal calls, which occur immediately before the dialog box is displayed.

Override this member function if you need to perform special processing when the dialog box is initialized. In the overridden version, first call the base class OnInitDialog but disregard its return value. You'll normally return TRUE from your overridden member function.

Windows calls the OnInitDialog function through the standard global dialog-box procedure common to all Microsoft Foundation Class Library dialog boxes, rather than through your message map, so you don't need a message-map entry for this member function.

CDHtmlDialog::OnNavigateComplete

Called by the framework after navigation to the specified URL is completed.

virtual void OnNavigateComplete(
    LPDISPATCH pDisp,
    LPCTSTR szUrl);

Parameters

pDisp
A pointer to an IDispatch object.

szUrl
A pointer to a string containing the URL that was navigated to.

CDHtmlDialog::ResizeBorder

Alerts the object that it needs to resize its border space.

STDMETHOD(ResizeBorder)(
    LPCRECT prcBorder,
    IOleInPlaceUIWindow* pUIWindow,
    BOOL fRameWindow);

Parameters

prcBorder
See prcBorder in IDocHostUIHandler::ResizeBorder in the Windows SDK.

pUIWindow
See pUIWindow in IDocHostUIHandler::ResizeBorder in the Windows SDK.

fFrameWindow
See fFrameWindow in IDocHostUIHandler::ResizeBorder in the Windows SDK.

Return Value

Returns E_NOTIMPL.

CDHtmlDialog::SetControlProperty

Sets the property of an ActiveX control to a new value.

void SetControlProperty(
    LPCTSTR szElementId,
    DISPID dispId,
    VARIANT* pVar);

void SetControlProperty(
    IDispatch* pdispControl,
    DISPID dispId,
    VARIANT* pVar);

void SetControlProperty(
    LPCTSTR szElementId,
    LPCTSTR szPropName,
    VARIANT* pVar);

Parameters

szElementId
The HTML ID of an ActiveX control.

dispId
The dispatch ID of the property to set.

pVar
Pointer to a VARIANT containing the new property value.

pdispControl
Pointer to an ActiveX control's IDispatch interface.

szPropName
String containing the name of the property to set.

CDHtmlDialog::SetElementHtml

Sets the innerHTML property of an HTML element.

void SetElementHtml(
    LPCTSTR szElementId,
    BSTR bstrText);

void SetElementHtml(
    IUnknown* punkElem,
    BSTR bstrText);

Parameters

szElementId
The ID of an HTML element.

bstrText
The new value of the innerHTML property.

punkElem
The IUnknown pointer of an HTML element.

CDHtmlDialog::SetElementProperty

Sets a property of an HTML element.

void SetElementProperty(
    LPCTSTR szElementId,
    DISPID dispId,
    VARIANT* pVar);

Parameters

szElementId
The ID of an HTML element.

dispId
The dispatch ID of the property to set.

pVar
The new value of the property.

CDHtmlDialog::SetElementText

Sets the innerText property of an HTML element.

void SetElementText(
    LPCTSTR szElementId,
    BSTR bstrText);

void SetElementText(
    IUnknown* punkElem,
    BSTR bstrText);

Parameters

szElementId
The ID of an HTML element.

bstrText
The new value of the innerText property.

punkElem
The IUnknown pointer of an HTML element.

CDHtmlDialog::SetExternalDispatch

Sets the host's IDispatch interface.

void SetExternalDispatch(IDispatch* pdispExternal);

Parameters

pdispExternal
The new IDispatch interface.

CDHtmlDialog::SetHostFlags

Sets the host UI flags.

void SetHostFlags(DWORD dwFlags);

Parameters

dwFlags
For possible values, see DOCHOSTUIFLAG in the Windows SDK.

CDHtmlDialog::ShowContextMenu

Called when a context menu is about to be displayed.

STDMETHOD(ShowContextMenu)(
    DWORD dwID,
    POINT* ppt,
    IUnknown* pcmdtReserved,
    IDispatch* pdispReserved);

Parameters

dwID
See dwID in IDocHostUIHandler::ShowContextMenu in the Windows SDK.

ppt
See ppt in IDocHostUIHandler::ShowContextMenu in the Windows SDK.

pcmdtReserved
See pcmdtReserved in IDocHostUIHandler::ShowContextMenu in the Windows SDK.

pdispReserved
See pdispReserved in IDocHostUIHandler::ShowContextMenu in the Windows SDK.

Return Value

Returns S_FALSE.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::ShowContextMenu, as described in the Windows SDK.

CDHtmlDialog::ShowUI

Shows the host's UI.

STDMETHOD(ShowUI)(
    DWORD dwID,
    IOleInPlaceActiveObject* pActiveObject,
    IOleCommandTarget* pCommandTarget,
    IOleInPlaceFrame* pFrame,
    IOleInPlaceUIWindow* pDoc);

Parameters

dwID
See dwID in IDocHostUIHandler::ShowUI in the Windows SDK.

pActiveObject
See pActiveObject in IDocHostUIHandler::ShowUI in the Windows SDK.

pCommandTarget
See pCommandTarget in IDocHostUIHandler::ShowUI in the Windows SDK.

pFrame
See pFrame in IDocHostUIHandler::ShowUI in the Windows SDK.

pDoc
See pDoc in IDocHostUIHandler::ShowUI in the Windows SDK.

Return Value

Returns S_FALSE.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::ShowUI, as described in the Windows SDK.

CDHtmlDialog::TranslateAccelerator

Called to process menu accelerator-key messages.

STDMETHOD(TranslateAccelerator)(
    LPMSG lpMsg,
    const GUID* pguidCmdGroup,
    DWORD nCmdID);

Parameters

lpMsg
See lpMsg in IDocHostUIHandler::TranslateAccelerator in the Windows SDK.

pguidCmdGroup
See pguidCmdGroup in IDocHostUIHandler::TranslateAccelerator in the Windows SDK.

nCmdID
See nCmdID in IDocHostUIHandler::TranslateAccelerator in the Windows SDK.

Return Value

Returns S_FALSE.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::TranslateAccelerator, as described in the Windows SDK.

CDHtmlDialog::TranslateUrl

Called to modify the URL to be loaded.

STDMETHOD(TranslateUrl)(
    DWORD dwTranslate,
    OLECHAR* pchURLIn,
    OLECHAR** ppchURLOut);

Parameters

dwTranslate
See dwTranslate in IDocHostUIHandler::TranslateUrl in the Windows SDK.

pchURLIn
See pchURLIn in IDocHostUIHandler::TranslateUrl in the Windows SDK.

ppchURLOut
See ppchURLOut in IDocHostUIHandler::TranslateUrl in the Windows SDK.

Return Value

Returns S_FALSE.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::TranslateUrl, as described in the Windows SDK.

CDHtmlDialog::UpdateUI

Called to notify the host that the command state has changed.

STDMETHOD(UpdateUI)(void);

Return Value

Returns E_NOTIMPL.

Remarks

This member function is the CDHtmlDialog implementation of IDocHostUIHandler::UpdateUI, as described in the Windows SDK.

See also

MFC Sample DHtmlExplore
DDX_DHtml Helper Macros
Hierarchy Chart