基本上,我想开发一个 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 接口来监听 onsubmit 事件?