1, <button id= "loginbtn" class= "btn btn-login formsubmit" tabindex= "6" type= "submit" > Login </button> button Trigger
Ideas:
Program implementation to invoke the Web page submit method, in order to achieve the purpose of automatic submission of Web pages, may be used in many times, the author found a lot of information on the Internet, but mostly with COM interface calls, and seldom speak with MFC IHTMLFormElement method, I repeatedly study, found the method , issued for everyone to reference, in the future can be less detours, improve development efficiency.
First in # include <StdAfx.h> add # include <mshtml.h> header file to include IHTMLDocument2
ihtmldocument2 * phtmldoc= (ihtmldocument2*) (ihtmldocument2*) m_ Ctrlweb.getdocument (); //m_ctrlweb is activex associated variables for Microsoft web browser
void Cwebdlg::onbutton1 ()
{
IHTMLDocument2 * phtmldoc= (ihtmldocument2*) (ihtmldocument2*) m_ctrlweb.getdocument ();
IHTMLElementCollection *pcollection;
HRESULT hr;
LONG llength;
VARIANT varindex,var2;
Hr=phtmldoc->get_all (&pcollection);
if (FAILED (HR))
Return
Hr=pcollection->get_length (&llength);
if (FAILED (HR))
Return
for (int i=0;i<llength;i++) {
Varindex.vt=vt_uint;
Varindex.lval=i;
VariantInit (&VAR2);
IDispatch * Pdispatch;
Hr=pcollection->item (Varindex,var2,&pdispatch);
if (FAILED (HR))
Continue
IHTMLFormElement *pformelem=null;
Hr=pdispatch->queryinterface (Iid_ihtmlformelement, (void**) &pformelem);
if (FAILED (HR))
Continue
Pformelem->submit ();
}
}
If there are other ideas welcome to explore together, learn together! Common Progress!!!
MFC implements automatic search of Web pages