我按照这个link获取了一个ActiveX控件的窗口句柄
来自microsoft网站的示例代码
// 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.
}但在我的例子中,我总是发现"m_pInPlaceSite“总是空的。我正在尝试在我的控件FinalConstruct中运行这段代码。为了给m_pInPlaceSite赋值,我还需要实现什么吗?或者我需要查询才能获得值。
谢谢
发布于 2012-12-05 07:26:15
FinalConstruct还为时过早。在FinalConstruct中,您的类是刚刚创建的,还没有初始化。没有“就地”网站,根本就没有网站。
你的控件将被它的所有者调用,它将被赋予它的站点,然后被激活--只有这样你才有可能拥有可用的m_pInPlaceSite。
https://stackoverflow.com/questions/13710847
复制相似问题