The information in this article is applied to: MicrosoftInternetExplorer (programming) versions 4.0, 4.01, 4.01SP1, 4.01SP2, 5, 5.01, 5.5. Note: support. microsoft. comdefault. aspx? Scidkb; en-us; Q257717 overview Microsoft Knowledge Base Article Q172763 information: Description of Object Model access in ActiveX
Information about this article applies to: Microsoft Internet Explorer (programming) versions 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.01, 5.5 reporter Note: http://support.microsoft.com/default.aspx? Scid = kb; en-us; Q257717 summary Microsoft Knowledge Base Article Q172763 information: Description of Object Model access in ActiveX
The information in this article is applied:
- Microsoft Internet Explorer (programming) Version 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.01, 5.5
Note: http://support.microsoft.com/default.aspx? Scid = kb; en-us; Q257717
Summary
Microsoft Knowledge Base Article
Q172763: access the object model in ActiveX
Describes how to obtain the IWebBrowser2 reference of the window in the control. However, developers often need to reference top-level IWebBrowser2 with a framework set. For example, you can use the statusText () command to set the value of the status bar before loading the webpage. This attribute is invalid for the WebBrowser control, so calling the IWebBrowser2 function of the Framework produces an error.
More information
To obtain the top-level IWebBrowser2 reference, obtain IServiceProvider from the customer site and perform a QueryService operation to obtain the IID_IServiceProvider service SID_STopLevelBrowser (defined in Shlguid. h ). For the second IServiceProvider, execute a QueryService to obtain the IID_IWebBrowser2 service SID_SWebBrowserApp.
The best way to do this is in the SetClientSite () method of IOleObject:
#include
#define COMRELEASE(ptr)/if (ptr != NULL) {/ptr->Release();/ptr = NULL;/}IWebBrowser2 *browser = NULL;STDMETHODIMP SetClientSite(IOleClientSite *pClientSite){HRESULT hr = S_OK;IServiceProvider *isp, *isp2 = NULL;if (!pClientSite){COMRELEASE(browser);}else{hr = pClientSite->QueryInterface(IID_IServiceProvider, reinterpret_cast
(&isp));if (FAILED(hr)){hr = S_OK;goto cleanup;}hr = isp->QueryService(SID_STopLevelBrowser, IID_IServiceProvider, reinterpret_cast
(&isp2));if (FAILED(hr)){hr = S_OK;goto cleanup;}hr = isp2->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, reinterpret_cast
(&browser));if (FAILED(hr)){hr = S_OK;goto cleanup;}cleanup:// Free resources.COMRELEASE(isp);COMRELEASE(isp2);return hr;}}
Reference
For more information, click the document number below to view the article in the Microsoft Knowledge Base.
Q172763: access the object model in ActiveX
Yes