HWND property
Gets the handle of the Windows Internet Explorer main window.
Syntax
HRESULT value = object.get_HWND(long* pHWND);
Property values
Type: long
the window handle.
Remarks
Windows Internet Explorer 7. With the introduction of tabbed browsing, the return value of this method can be ambiguous. To alleviate confusion and maintain the highest level of compatibility with existing applications, this method returns a handle to the top-level window frame, not the currently selected tab.
Examples
For applications that absolutely require an HWND to the current tab, the following example returns the same logical window as IWebBrowser2::HWND in a previous version of Internet Explorer. This technique works equally well in both Internet Explorer 7 and Internet Explorer 6.
#include <shlguid.h>
IServiceProvider* pServiceProvider = NULL;
if (SUCCEEDED(pWebBrowser2->QueryInterface(
IID_IServiceProvider,
(void**)&pServiceProvider)))
{
IOleWindow* pWindow = NULL;
if (SUCCEEDED(pServiceProvider->QueryService(
SID_SShellBrowser,
IID_IOleWindow,
(void**)&pWindow)))
{
HWND hwndBrowser = NULL;
if (SUCCEEDED(pWindow->GetWindow(&hwndBrowser)))
{
// hwndBrowser is the handle of TabWindowClass
}
pWindow->Release();
}
pServiceProvider->Release();
}