首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

请问,如何能把当前ie窗口的句柄传进activex控件里面去

2012-02-13 
请教,怎么能把当前ie窗口的句柄传进activex控件里面去?因为在activex控件里面要建窗口,建立的窗口的父窗口

请教,怎么能把当前ie窗口的句柄传进activex控件里面去?
因为在activex控件里面要建窗口,建立的窗口的父窗口句柄必须指定才能正常。

[解决办法]
IServiceProvider *isp, *isp2 = NULL;
IWebBrowser2* pWebBrowser = NULL;
HRESULT hr = m_pClientSite-> QueryInterface(IID_IServiceProvider, reinterpret_cast <void **> (&isp));


hr = isp-> QueryService(SID_STopLevelBrowser, IID_IServiceProvider, reinterpret_cast <void **> (&isp2));

hr = isp2-> QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, reinterpret_cast <void **> (&pWebBrowser));

[解决办法]
http://support.microsoft.com/kb/150204/en-us

How to retrieve the actual parent window of an ActiveX control

// The following code should return the
// actual parent window of the ActiveX control.
HWND CMyOleControl::GetActualParent()
{
HWND hwndParent = 0;

// Get the window associated with the in-place site object,
// which is connected to this ActiveX control.
if (m_pInPlaceSite != NULL)
m_pInPlaceSite-> GetWindow(&hwndParent);

return hwndParent; // Return the in-place site window handle.
}

热点排行