2010-10-19 10:48 Activex调试以及m_hWnd为空 解决办法

简介: 1. 点击【开始】->【运行】 命令:regedit.2. 定位到HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main3.

1. 点击【开始】->【运行】 命令:regedit.
2. 定位到HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
3. 在【右边区域】【右键】新建一个名称为TabProcGrowth的DWORD值, 数值数据设置为0.

VS不用重启,直接可以按F5进行调试ActiveX了!

参看: http://social.microsoft.com/Forums/en-US/vsdebug/thread/e2c795cd-b7a0-4fad-b7c9-b1ca40d7302e

网页中OCX控件HWND为空问题当网页中的OCX控件没有出现到屏幕上之前(或者尺寸为0时),它的WM_CREATE消息将不会被调用. 这样当script程序调用一些必须要有有效HWND的操作时就会导致MFC/ATL底层库的崩溃(调试版本则会ASSERT)。 在MFC中的调试版本:
ASSERT(::IsWindow(m_hWnd)); 在ATL中的调试版本:
ATLASSERT(::IsWindow(m_hWnd)); MFC的解决办法是:在派生类中钩住OnSetClientSite,创建一个窗口,代码如下:// CMyControl is derived from COleControl.
void CMyControl::OnSetClientSite()
{
// It doesn't matter who the parent window is or what the size of
// the window is because the control's window will be reparented
// and resized correctly later when it's in-place activated.
if (m_pClientSite)
    VERIFY (CreateControlWindow (::GetDesktopWindow(), CRect(0,0,0,0), CRect(0,0,0,0)));
COleControl::OnSetClientSite();
}ATL的解决办法:
// CMyControl is derived from CComControl
STDMETHOD(SetClientSite)(IOleClientSite *pClientSite)
{
if (pClientSite)
{
    RECT rc = {0,0,0,0};
    // Don't have access to the container's window so just use the
    // desktop. Window will be resized correctly during in-place
    // activation.
    HWND hWnd = CreateControlWindow(::GetDesktopWindow(), rc);
    _ASSERT (hWnd);
}
return IOleObjectImpl<CMyControl>::SetClientSite (pClientSite);
}HRESULT InPlaceActivate(LONG iVerb, const RECT* prcPosRect)
{
// Get the container's window.
_ASSERT (m_spClientSite);
LPOLEINPLACESITE pInPlaceSite = NULL;
HRESULT hr = m_spClientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&pInPlaceSite);
_ASSERT (SUCCEEDED (hr) && pInPlaceSite);
HWND hParent = NULL;
hr = pInPlaceSite->GetWindow (&hParent);
_ASSERT (SUCCEEDED (hr) && hParent);
pInPlaceSite->Release ();

// Set container window as our parent window
SetParent (hParent);
return CComControlBase::InPlaceActivate(iVerb, prcPosRect);
}

参看:http://support.microsoft.com/kb/195188

目录
相关文章
|
Shell Windows
windows出现错误0x800401E5:没有供标记使用的对象
windows出现错误0x800401E5:没有供标记使用的对象
windows出现错误0x800401E5:没有供标记使用的对象
|
4月前
|
Ubuntu
这个错误提示是因为`hgctl`工具在尝试打开浏览器时,找不到可执行的`xdg-open`文件
这个错误提示是因为`hgctl`工具在尝试打开浏览器时,找不到可执行的`xdg-open`文件
54 1
|
10月前
|
安全
【Win32】资源文件(对话框),逆向对话框回调函数,消息断点(附带恶意软件源码)(下)
【Win32】资源文件(对话框),逆向对话框回调函数,消息断点(附带恶意软件源码)
|
10月前
|
安全 数据可视化 数据安全/隐私保护
【Win32】资源文件(对话框),逆向对话框回调函数,消息断点(附带恶意软件源码)(上)
【Win32】资源文件(对话框),逆向对话框回调函数,消息断点(附带恶意软件源码)
|
11月前
|
安全 Shell
按“window+E”键出现【找不到应用程序】或【explore.exe找不到】的解决方法
按“window+E”键出现【找不到应用程序】或【explore.exe找不到】的解决方法
642 0
|
Windows
Windows 技术篇-win10运行没有、不保存历史记录解决方法,win10文件夹浏览记录为空问题解决
Windows 技术篇-win10运行没有、不保存历史记录解决方法,win10文件夹浏览记录为空问题解决
361 0
Windows 技术篇-win10运行没有、不保存历史记录解决方法,win10文件夹浏览记录为空问题解决
visual studio编写C#代码时“未能从程序集.....中加载类型”和“找不到方法”的一种可能的解决办法
编译前报错:$exception    {"未能从程序集“XSW.MySQLDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”中加载类型“XSW.MySQLDAL.EnterpriseLibraryProductDAL”。
1699 0