描述:
如何用com禁止com所在页的鼠标选择文本操作?
我用atl做的comX件,希望用com禁止com所在页的鼠标选择文本操作,
在OnCreate事件中得到 CComQIPtr<IHTMLDocument2,&IID_IHTMLDocument2> spDoc(spIE);
// QI the container for the doucmnet interface , spDoc stores the HTMLDocument2
得到成功后,加入下列语句:
if(spDoc)
{
VARIANT v;
v.vt=VT_BSTR;
//我希望事件处理代码啥也不做,就是返回false;
v.bstrVal = ::SysAllocString(OLESTR("return false;"));
if(v.bstrVal==NULL)
{ MessageBox(L"SysAllocString Error!",L"error",MB_OK); }
else
{
// 修改selectstart事件响应代码,使其返回false,do nothing
// 从而达到屏蔽鼠标选择的目的!
if(spDoc->put_onselectstart(v)!=S_OK)
MessageBox(L"put_onselectstart() error!",L"致命错误",MB_OK);
::SysFreeString(v.bstrVal);
}
}