This article is translated from http://support.microsoft.com/kb/257717: get the top IWebBrowser2 interface in the ActiveX control
Information about this article is applied to:
Microsoft Internet Explorer (Programming) Version 4.0, 4.01, 4.01 SP1, 4.01 SP2, 5, 5.01, 5.5
summary
Microsoft Knowledge Base Article
Q172763 Information: Access object model in ActiveX
Explain how to get references to iWebBrowser2 in your control. However, developers actually need a reference to the top IWebBrowser2 with a frame set. For example, you can use the statustext () command to set the statustext () command before you load the status bar. Because this property is invalid for the webbrowser control, the function that calls the IWebBrowser2 in the framework will generate an error.
More information
In order to obtain top-level IWebBrowser2 reference, get IServiceProvider from the client site interfaces and perform an operation QueryService get IID_IServiceProvider Service: SID_STopLevelBrowser (which is defined in the Shlguid.h in); for the second IServiceProvider, perform a QueryService get IID_IWebBrowser2 service:. SID_SWebBrowserApp to do this The most suitable place 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)
{
Comvelese (Browser);
}
Else
{
HR = pClientSite-> queryinterface (IID_IServiceProvider, ReinterPret_cast
IF (Failed (HR))
{
HR = S_OK;
Goto cleanup;
}
HR = ISP-> QueryService (SID_STopleVelbrowser, IID_IServiceProvider, ReinterPret_cast
IF (Failed (HR))
{
HR = S_OK;
Goto cleanup;
}
HR = ISP2-> QueryService (SID_SWEBBROWSERAPP, IID_IWEBBROWSER2, Reinterpret_cast
IF (Failed (HR))
{
HR = S_OK;
Goto cleanup;
}
Cleanup:
// free resources.
Comvelease (ISP);
Comvelease (ISP2);
Return HR;
}
}
reference
For more information, click the following document number to view the article in the Microsoft Knowledge Base
Q172763 Information: Access object model in ActiveX
To develop a web-based Internet Explorer solution, visit the following site: http://msdn.microsoft.com/workshop/entry.asp
http://msdn.microsoft.com/ie/
http://support.microsoft.com/highlights/iep.asp?fr=0&sd=msdn
© Microsoft 2000, keep all rights
Microsoft's Jay Andrew Allen submitted
Extra Query Keywords: iServiceProvider Sid_StopleVelBrowser IWebBBROWSER2
Keywords: kbActiveX kbCtrl kbIE kbIE400 kbGrpDSInet kbie500 kbDSupport kbie501 kbie550 Article type: kbhowto Technology: kbIEsearch kbAudDeveloper kbSDKIESearch kbIE500Search kbSDKIE400 kbSDKIE401 kbSDKIE401SP1 kbSDKIE401SP2 kbSDKIE500 kbSDKIE501 kbSDKIE550 kbIE550Search
Last updated: July 21, 2001