Chinaunix首页 | 论坛 | 博客
  • 博客访问: 409012
  • 博文数量: 78
  • 博客积分: 3642
  • 博客等级: 中校
  • 技术积分: 695
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-23 15:33
文章分类

全部博文(78)

文章存档

2007年(53)

2006年(25)

分类:

2007-03-08 16:33:56

[转]
 
IWebBrowser2::HWND Property

Gets the handle of the Microsoft Internet Explorer main window.

What's New for Windows Internet Explorer 7

For compatibility reasons, this method returns a handle to the top-level window frame, consistent with previous versions of Internet Explorer. However, due to tabbed browsing in Internet Explorer 7, this window handle is not logically the same as in previous versions.

Syntax

HRESULT IWebBrowser2::get_HWND(long *pHWND);

Parameters

pHWND
Pointer to a variable of type long that receives the window handle.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

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.

Example

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 

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();
} 
阅读(2672) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~