您的位置:首页 > 其它

已知IWebBrowser2接口,如何获得其Internet Explorer_Server窗口句柄?

2017-01-17 21:32 537 查看
关键字:IWebBrowser2,HWND,::GetCursorPos,::ScreenToClient
方法:
HRESULT IWebBrowser2::get_HWND(long *pHWND);
代码:
#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();
}参考:http://msdn.microsoft.com/en-us/library/aa752126.aspx http://topic.csdn.net/u/20070301/11/91d45328-4985-4a16-8ccf-b58b2423e8a2.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: