博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2010-10-19 10:48 Activex调试以及m_hWnd为空 解决办法
阅读量:7222 次
发布时间:2019-06-29

本文共 1830 字,大约阅读时间需要 6 分钟。

1. 点击【开始】->【运行】 命令:regedit.

2. 定位到HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
3. 在【右边区域】【右键】新建一个名称为TabProcGrowth的DWORD值, 数值数据设置为0.

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

参看:

网页中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://iuzfm.baihongyu.com/

你可能感兴趣的文章
美的程序不可能从修修补补中来。它必须完美的把握住事物的本质,否则就会有许许多多无法修补的特例(转)...
查看>>
使用像素生成图象
查看>>
hadoop: hbase1.0.1.1 伪分布安装
查看>>
变量 - PHP手册笔记
查看>>
设置cookies第二天0点过期
查看>>
ntpdate公司测试
查看>>
.NET破解之轻量万能自定义信息管理系统
查看>>
Android blueZ HCI(一个):hciconfig实施和经常使用
查看>>
3、使用Lucene实现千度搜索
查看>>
【转载】NIO客户端序列图
查看>>
linux系统中如何查看日志(转)
查看>>
JavaScript的parseint()函数
查看>>
微信小程序 view 布局
查看>>
一步一步学Python(2) 连接多台主机执行脚本
查看>>
SUP (SAP Mobile SDK 2.2) 连接 Sybase SQL Anywhere sample 数据库
查看>>
流的压缩与解压缩函数
查看>>
Javascript 严格模式详解(转)
查看>>
AngularJS的Hello World
查看>>
日志池
查看>>
电子病历,到底是用BS还是CS
查看>>