Reference for C/C++ Developers

Reference for C/C++ Developers


This reference contains the following sections:

Interface

This section describes the new IWebBrowser2 interface that replaces the IWebBrowser and IWebBrowserApp interfaces from previous releases.

IWebBrowser2

IWebBrowser2 designates an interface that allows applications to implement an instance of the WebBrowser control in an application (ActiveX Control) or control an instance of the Internet Explorer application (OLE Automation). For methods applicable to the Internet Explorer object only, the description section in the following table uses the "Internet Explorer only" notation, and throughout the reference sections the "Applies To" heading also indicates which object (WebBrowser or Internet Explorer) that method applies to. The Exdisp.h file defines all the WebBrowser interfaces as well as the GUIDs (globally unique identifiers).

Methods in Vtable Order

IWebBrowser2 methods Description
GoBack Navigates to the previous item in the history list.
GoForward Navigates to the next item in the history list.
GoHome Navigates to the current home or start page.
GoSearch Navigates to the current search page.
Navigate Navigates to a resource identified by a Universal Resource Locator (URL).
Refresh Reloads the current file.
Refresh2 Reloads the current file and optionally prevents the "pragma:nocache" header from being sent.
Stop Stops opening a file.
get_Application Returns an application object representing the application that contains the current instance of the Internet Explorer application.
get_Parent Returns the automation object.
get_Container Returns the container of the WebBrowser control.
get_Document Returns the active document.
get_TopLevelContainer Returns a value indicating whether the current object is the top-level container of the WebBrowser control.
get_Type Returns the type name of the document object.
get_Left Returns the screen coordinate of the left edge of the Internet Explorer main window.
put_Left Sets the horizontal position of the Internet Explorer main window.
get_Top Returns the screen coordinate of the top edge of the Internet Explorer main window.
put_Top Sets the vertical position of the Internet Explorer main window.
get_Width Returns the width of the Internet Explorer main window.
put_Width Sets the width of the Internet Explorer main window.
get_Height Returns the height of the Internet Explorer main window.
put_Height Sets the height of the Internet Explorer main window.
get_LocationName Returns the name of the resource that WebBrowser is currently displaying.
get_LocationURL Returns the URL of the resource that WebBrowser is currently displaying.
get_Busy Returns a value indicating whether a download or other activity is still in progress.
Quit Closes the Internet Explorer application. (Internet Explorer only)
ClientToWindow Converts the client coordinates of a point to window coordinates. (Internet Explorer only)
PutProperty Sets the value of a property associated with the given object. (Internet Explorer only)
GetProperty Retrieves the current value of a property associated with the given object. (Internet Explorer only)
get_Name Returns the name of the object that contains the WebBrowser control used by Internet Explorer. (Internet Explorer only)
get_HWND Returns the window handle to the Internet Explorer main window. (Internet Explorer only)
get_FullName Returns the full path of the file that Internet Explorer is currently displaying. (Internet Explorer only)
get_Path Returns a string that evaluates to the full path of the resource that Internet Explorer is currently displaying. (Internet Explorer only)
get_Visible Returns a value indicating whether the object is visible or hidden.
put_Visible Sets a value indicating whether the object is visible or hidden.
get_StatusBar Returns a value that indicates whether the status bar is visible.
put_StatusBar Sets a value that determines whether the status bar is visible.
get_StatusText Returns the text of the status bar.
put_StatusText Sets the text for the status bar.
get_ToolBar Returns a value that indicates whether the toolbar is visible.
put_ToolBar Sets a value that determines whether the toolbar is visible.
get_MenuBar Returns a value that indicates whether the menu bar is visible.
put_MenuBar Sets a value that determines whether the menu bar is visible.
get_FullScreen Returns a value indicating whether Internet Explorer is in full-screen or normal window mode.
put_FullScreen Sets a value that determines whether Internet Explorer is in full-screen or normal window mode.
Navigate2 Navigates to a resource identified by a pointer to an item identifier list (PIDL).
QueryStatusWB Queries the object for status of commands.
ExecWB Executes a command.
ShowBrowserBar Shows or hides a specified browser bar.
get_ReadyState Returns a standard OLE ReadyState bindable property for the WebBrowser control.
get_Offline Returns a value that determines whether the control is offline.
put_Offline Sets a value that determines whether the control is offline.
get_Silent Returns a value indicating whether any dialog boxes can be shown.
put_Silent Sets a value indicating whether any dialog boxes can be shown.
get_RegisterAsBrowser Returns a value indicating whether the WebBrowser control is registered as a top-level browser for target name resolution.
put_RegisterAsBrowser Sets a value indicating whether the WebBrowser control is registered as a top-level browser for target name resolution.
get_RegisterAsDropTarget Returns a value indicating whether the WebBrowser control is registered as a drop target for navigation.
put_RegisterAsDropTarget Sets a value indicating whether the WebBrowser control is registered as a drop target for navigation.
get_TheaterMode Retrieves a value indicating whether the WebBrowser control is in theater mode.
put_TheaterMode Sets a value indicating whether the WebBrowser control is in theater mode.
get_AddressBar Determines if the Internet Explorer object's address bar is visible.
put_AddressBar Shows or hides the Internet Explorer object's address bar.
get_Resizable Retrieves the Internet Explorer object's resizable property.
put_Resizable Sets the Internet Explorer object's resizable property.

IWebBrowser2::ClientToWindow

HRESULT ClientToWindow(
    int FAR* pcx,
    int FAR* pcy
);

Converts the client coordinates of a point to window coordinates. Client coordinates are relative to the upper-left corner of the client area; window coordinates are relative to the upper-left corner of a window.

pcx
The x-coordinate of the point to convert, in client coordinates. When ClientToWindow returns, this variable contains the x-coordinate of the point in window coordinates.
pcy
The y-coordinate of the point to convert, in client coordinates. When ClientToWindow returns, this variable contains the y-coordinate of the point in window coordinates.

Applies To

Internet Explorer

IWebBrowser2::ExecWB

HRESULT ExecWB(
    [in] OLECMDID cmdID,
    [in] OLECMDEXECOPT cmdexecopt,
    [in] VARIANT * pvaIn,
    [out, in] VARIANT * pvaOut)

Implements a wrapper that allows you to execute a command on an OLE object using the IOleCommandTarget::Exec method.

cmdID
OLECMDID value that specifies the command to execute.
cmdexecopt
OLECMDEXECOPT value that specifies the command options.
pvaIn
Address of a VARIANT structure that specifies command input arguments. This argument may be NULL.
pvaOut
Address of a VARIANT structure that receives command output. This argument may be NULL.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::QueryStatusWB

IWebBrowser2::GetProperty

HRESULT GetProperty(
    BSTR szProperty,
    VARIANT FAR* pvtValue
);

Retrieves the value of a property associated with the given object.

szProperty
Caller-allocated buffer that contains the name of the property to retrieve.
pvtValue
Address of a variable that receives the value associated with the given property.

Applies To

Internet Explorer

See also IWebBrowser2::PutProperty

IWebBrowser2::GoBack

HRESULT GoBack(void);

Navigates backward one item in the history list.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::GoForward, IWebBrowser2::GoHome, IWebBrowser2::GoSearch

IWebBrowser2::GoForward

HRESULT GoForward(void);

Navigates forward one item in the history list.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::GoBack, IWebBrowser2::GoHome, IWebBrowser2::GoSearch

IWebBrowser2::GoHome

HRESULT GoHome(void);

Navigates to the current home or start page, as specified in the Internet Explorer Options dialog box and Internet Control Panel.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::GoBack, IWebBrowser2::GoForward, IWebBrowser2::GoSearch

IWebBrowser2::GoSearch

HRESULT GoSearch(void);

Navigates to the current search page, as specified in the Internet Explorer Options dialog box and Internet Control Panel.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::GoBack, IWebBrowser2::GoForward, IWebBrowser2::GoHome

IWebBrowser2::Navigate

HRESULT IWebBrowser2::Navigate(
    BSTR URL,
    VARIANT FAR* Flags,
    VARIANT FAR* TargetFrameName,
    VARIANT FAR* PostData,
    VARIANT FAR* Headers,
);

Navigates to a resource identified by a Uniform Resource Locator (URL) or to the file identified by a full path.

URL
A caller-allocated string that contains the URL to navigate to or the full path of the file to display.
Flags
Address of a variable that specifies whether to add the resource to the history list, whether to read to 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.
TargetFrameName
Address of a string that contains the name of the frame in which to display the resource.
PostData
Address of 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 does not specify any post data, Navigate issues an HTTP GET transaction. This parameter is ignored if URL is not an HTTP URL.
Headers
Address of 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 things like the action required of the server, the type of data being passed to the server, or a status code. This parameter is ignored if URL is not an HTTP URL.

The post data specified by PostData is passed as a SAFEARRAY structure. The variant should be of type VT_ARRAY and point to a SAFEARRAY. The SAFEARRAY should be of element type VT_UI1, dimension one, and have an element count equal to the number of bytes of post data.

Applies To

WebBrowser, Internet Explorer

See also DWebBrowserEvents2::BeforeNavigate2, DWebBrowserEvents2::NavigateComplete2

IWebBrowser2::Navigate2

HRESULT Navigate2(
    [in] VARIANT * URL,
    [in, optional] VARIANT * Flags,
    [in, optional] VARIANT * TargetFrameName,
    [in, optional] VARIANT * PostData,
    [in, optional] VARIANT * Headers,
);

Navigates the browser to a location that may not be able to be expressed as a URL, such as a pointer to an item identifier list (PIDL) for an entity in the Windows shell namespace.

URL
A caller-allocated string that contains the URL to navigate to or the full path of the file to display.
Flags
Address of a variable that specifies whether to add the resource to the history list, whether to read to 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.
TargetFrameName
Address of a string that contains the name of the frame in which to display the resource.
PostData
Address of 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 does not specify any post data, the Navigate2 method issues an HTTP GET transaction. This parameter is ignored if URL is not an HTTP URL.
Headers
Address of 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 things like the action required of the server, the type of data being passed to the server, or a status code. This parameter is ignored if URL is not an HTTP URL.

This method extends the Navigate method to allow for shell integration; however, the original Navigate method can still be used for URL navigations (Navigate2 does not make Navigate obsolete).

The post data specified by PostData is passed as a SAFEARRAY structure. The variant should be of type VT_ARRAY and point to a SAFEARRAY. The SAFEARRAY should be of element type VT_UI1, dimension one, and have an element count equal to the number of bytes of post data.

Applies To

WebBrowser, Internet Explorer

See also DWebBrowserEvents2::BeforeNavigate2, DWebBrowserEvents2::NavigateComplete2

IWebBrowser2::PutProperty

HRESULT PutProperty(
    BSTR szProperty,
    VARIANT vtValue
);

Sets the value of a property associated with the given object.

szProperty
Caller-allocated buffer that contains the name of the property to set.
vtValue
New value for the given property.

Applies To

Internet Explorer

See also IWebBrowser2::GetProperty

IWebBrowser2::QueryStatusWB

HRESULT QueryStatusWB(
    [in] OLECMDID nCmdID,
    [out, retval] OLECMDF *pcmdf
);

Implements a wrapper that allows you to query an OLE object for status of commands using the IOleCommandTarget::QueryStatus method.

nCmdID
OLECMDID value of the command for which the caller needs status information.
pcmdf
Address of an OLECMDF value that receives the status of the command.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::ExecWB

IWebBrowser2::Quit

HRESULT Quit(void);

Closes the Internet Explorer application.

Applies To

Internet Explorer

IWebBrowser2::Refresh

HRESULT Refresh(void);

Reloads the file that Internet Explorer is currently displaying.

Applies To

WebBrowser, Internet Explorer

IWebBrowser2::Refresh2

HRESULT Refresh2(
    VARIANT FAR* Level
);

Reloads the file that Internet Explorer is currently displaying. Unlike IWebBrowser2::Refresh, this method contains a parameter that specifies the refresh level.

Level
Address of a variable that specifies the level of refresh operation to perform. The variable can contain a type defined by the RefreshConstants enumeration.

Applies To

WebBrowser, Internet Explorer

IWebBrowser2::ShowBrowserBar

HRESULT ShowBrowserBar(
    VARIANT FAR* pvaClsid,
    VARIANT FAR* pvarShow,
    VARIANT FAR* pvarSize
);

Shows or hides a specified browser bar.

pvaClsid
Address of a string VARIANT that contains the class identifier of the browser bar to show or hide. This object must be registered as an Explorer Bar object with the CATID_InfoBand component category. For more information, see Band Objects.
pvarShow
Address of a BOOL VARIANT that specifies if the browser bar should be shown or hidden. If this is nonzero, the browser bar is shown. If this is zero, the browser bar is hidden.
pvarSize
Not currently used.

Applies To

Internet Explorer

IWebBrowser2::Stop

HRESULT Stop(void);

Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.

Applies To

WebBrowser, Internet Explorer

See also DWebBrowserEvents2::BeforeNavigate2, DWebBrowserEvents2::DownloadBegin, DWebBrowserEvents2::ProgressChange, IWebBrowser2::Quit, IWebBrowser2::Refresh

IWebBrowser2::get_AddressBar

HRESULT get_AddressBar(
    VARIANT_BOOL FAR* pValue
);

Determines if the Internet Explorer object's address bar is visible.

pValue
Address of a variable that receives a nonzero value if the address bar is visible, or zero if it is not visible.

Applies To

Internet Explorer

See also IWebBrowser2::put_AddressBar

IWebBrowser2::get_Application

HRESULT get_Application(
    IDispatch * FAR* ppDisp
);

Retrieves the automation interface supported by the Internet Explorer application.

ppDisp
Address of a variable that receives the pointer to the application's IDispatch interface.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::get_Container, IWebBrowser2::get_Document, IWebBrowser2::get_Parent

IWebBrowser2::get_Busy

HRESULT get_Busy(
    VARIANT_BOOL FAR* pBool
);

Discovers whether Internet Explorer is engaged in a downloading operation or other activity.

pBool
Address of a variable that receives TRUE if Internet Explorer is busy, or FALSE if not.

Applies To

WebBrowser, Internet Explorer

IWebBrowser2::get_Container

HRESULT get_Container(
    IDispatch * FAR* ppDisp
);

Retrieves a pointer to the IDispatch interface of the container.

ppDisp
Address of a variable that receives the pointer to the container's IDispatch interface.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::get_Application, IWebBrowser2::get_Document, IWebBrowser2::get_Parent

IWebBrowser2::get_Document

HRESULT get_Document(
    IDispatch * FAR* ppDisp
);

Retrieves a pointer to the IDispatch interface of the Active Document object.

ppDisp
Address of a variable that receives the pointer to the object's IDispatch interface.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::get_Application, IWebBrowser2::get_Container, IWebBrowser2::get_Parent

IWebBrowser2::get_FullName

HRESULT get_FullName(
    BSTR FAR* pbstrFullName
);

Retrieves the fully qualified path of the Internet Explorer executable file.

pbstrFullName
Address of a caller-allocated buffer that receives the path of the executable file.

Applies To

WebBrowser, Internet Explorer

IWebBrowser2::get_FullScreen

HRESULT get_FullScreen(
    VARIANT_BOOL FAR* pbFullScreen
);

Determines if Internet Explorer is in full-screen or normal window mode.

pbFullScreen
Address of a variable that receives TRUE if Internet Explorer is in full-screen mode, or FALSE if it is in normal window mode.

In full-screen mode, the Internet Explorer main window is maximized and the status bar, toolbar, menu bar, and title bar are hidden.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::put_FullScreen

IWebBrowser2::get_Height

HRESULT get_Height(
    long FAR* pl
);

Retrieves the height of the Internet Explorer main window.

pl
Address of a variable that receives the height, in pixels, of the main window.

Applies To

WebBrowser, Internet Explorer

See also IWebBrowser2::get_Width, IWebBrowser2::put_Height

IWebBrowser2::get_HWND

HRESULT get_HWND(
    long FAR* pHWND
);

Retrieves the handle to the Internet Explorer main window.

pHWND
Address of a variable that receives the window handle.

Applies To

Internet Explorer

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.