- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
基本上,我想开发一个 BHO,它可以验证表单上的某些字段并自动将一次性电子邮件放置在适当的字段中(更多内容是我自己的知识)。所以在 DOCUMENTCOMPLETE 事件中我有这个:
for(long i = 0; i < *len; i++)
{
VARIANT* name = new VARIANT();
name->vt = VT_I4;
name->intVal = i;
VARIANT* id = new VARIANT();
id->vt = VT_I4;
id->intVal = 0;
IDispatch* disp = 0;
IHTMLFormElement* form = 0;
HRESULT r = forms->item(*name,*id,&disp);
if(S_OK != r)
{
MessageBox(0,L"Failed to get form dispatch",L"",0);// debug only
continue;
}
disp->QueryInterface(IID_IHTMLFormElement2,(void**)&form);
if(form == 0)
{
MessageBox(0,L"Failed to get form element from dispatch",L"",0);// debug only
continue;
}
// Code to listen for onsubmit events here...
}
如何使用 IHTMLFormElement 接口(interface)来监听 onsubmit 事件?
最佳答案
一旦您有了指向要为其接收事件的元素的指针,您将为 IConnectionPointContainer
QueryInterface()
,然后连接到该元素:
REFIID riid = DIID_HTMLFormElementEvents2;
CComPtr<IConnectionPointContainer> spcpc;
HRESULT hr = form->QueryInterface(IID_IConnectionPointContainer, (void**)&spcpc);
if (SUCCEEDED(hr))
{
CComPtr<IConnectionPoint> spcp;
hr = spcpc->FindConnectionPoint(riid, &spcp);
if (SUCCEEDED(hr))
{
DWORD dwCookie;
hr = pcp->Advise((IDispatch *)this, &dwCookie);
}
}
一些注意事项:
dwCookie
和 cpc
,因为稍后调用 pcp->Unadvise()
断开连接时需要它们下沉。pcp->Advise()
的调用中,我传递了这个。您可以使用任何实现 IDispatch
的对象,它可能是也可能不是这个对象。设计留给您。riid
将是您要接收的事件调度接口(interface)。在这种情况下,您可能需要 DIID_HTMLFormElementEvents2
。断开连接的方法如下:
pcp->Unadvise(dwCookie);
如果您还有其他问题,请告诉我。
编辑-1:
是的,那个 DIID 是错误的。它应该是:DIID_HTMLFormElementEvents2
。
我是这样找到它的:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK>findstr /spin /c:"Events2" *.h | findstr /i /c:"form"
关于c++ - BHO 处理 OnSubmit 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1418476/
我已经根据本教程编写了一个 BHO: http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx 我的 GetSite 和 SetSite 与教程
我想让我的 BHO 监听某个网页中某个元素的 onmousedown 事件。我有找到特定元素的所有代码,在 msdn 中它说我需要使用 get_onmousedown事件。我想出了这段代码。 CCo
我已经实现了 BHO 插件来使用 C# 从网页中检测 NUmber。每次加载页面时都会在网页中附加 javascript 并且 javascript 检测数字并将其替换为超链接数字。 代码 publ
对不起我的无知。你必须向我解释事情,我正在涉足新领域。我有一些 JAVA 背景,但主要是 php、javascript。 http://www.codeproject.com/Articles/199
我有一个用 C# 编写的 BHO 库 mybho.dll。我嵌入了一个资源文件“image.png”。我想在某些页面上显示此图像。根据我的阅读,它应该是这样的: 但是 Internet Explor
我正在使用 helloworld 示例创建 BHO。 Building Browser Helper Objects with Visual Studio 2005 BHO 未加载,我无法在 SetS
测试浏览器扩展的最佳方法/工具是什么? 在我的案例中,我使用的是 IE 浏览器帮助程序对象 (C#),它有一个自己的小 UI 和大量的数据库交互。到目前为止,我们使用自动化单元测试来测试我们的模型/业
我有一个用 C++ 编写的浏览器帮助程序对象,但在接收 OnHelp HtmlEvent 时遇到问题。 当我尝试访问属性时,浏览器崩溃了。 VARIANT_BOOL STDMETHODCALLTYPE
如果有两个功能相似的BHO,IE如何决定先加载哪个?因为先加载的BHO会影响后面加载的BHO。所以我想将我的 BHO 设置为第一个加载的。我能做什么? 最佳答案 没有记录的方法可以做到这一点。但根据我
我正在为 Internet Explorer (BHO) 编写扩展程序。我阅读了很多问题和答案,但无法找到和理解,如何在每个页面上从资源中执行 Javascript 文件?不附加网页,需要在每个页面上
我正在使用以下示例创建 IE BHO:http://code.msdn.microsoft.com/CSBrowserHelperObject-c5f3d2f6 我遇到的问题是,对于每个选项卡,BHO
我似乎找不到在我的 IE C# BHO 和作为 SYSTEM 运行的 C# 控制台应用程序之间进行通信的方法。 到目前为止,我已经尝试过使用 Remoting 和 EventWaitHandle,但是
我正在 CSHARP 中开发 BHO,但我在 onDocumentComplete 方法中遇到问题。 它在主文档加载的每个 IFRAME 上运行。我怎样才能避免它?我只想处理主窗口中的事件。 publ
我不是 windows 程序员,但似乎我必须为 Internet explorer 做一个扩展。 我在这个线程的帮助下制作了一个 BHO:How to get started with develop
IE 不会在页面刷新 (F5) 后触发 DocumentComplete 和 NavigateComplete2 事件。 这显然是“设计使然”,但它很难响应页面重新加载。 哪些方法取得了最大的成功?有
我需要在 C# 中创建一个 BHO。除了典型的 Microsoft C++ 示例之外,还有其他可用的文档吗? 我该如何开始?谢谢... 最佳答案 这实际上并没有那么难,但是您必须亲 body 验 CO
我有一个 C# BHO,它在文档中调用一些 JS 函数。通常我是这样做的(一切正常): IHTMLWindow2 wnd; //... wnd.execScript("testMethod(\"tes
http://www.adp-gmbh.ch/win/com/bho.html 当我编译时,我得到了很多错误: error C2236: unexpected 'class' 'adpbho'. Di
我正在为一个客户做一个项目。我们正在构建一个内部门户网站,出于各种(主要是政治)原因,我们最终为 IE8 构建了一个 BHO。 t 所做的其中一件事是确保一次只能打开一个门户实例。它通过在门户打开时写
我需要开发一个 bho,但我以前从未使用过它。那么任何人都可以给我一些关于如何开始 bho 的建议吗?欢迎一些教程。 PS:我熟悉C++开发。 最佳答案 以下是一些示例: http://social.
我是一名优秀的程序员,十分优秀!