64,654
社区成员
发帖
与我相关
我的任务
分享
for (long i=0;i<form_num;i++)//遍历每一个表单
{
V_VT(&id) = VT_I4;
V_I4(&id) = i;
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
if (pElementCol->item(id,index,&spDispatch)==S_OK)
{
if (spDispatch->QueryInterface(IID_IHTMLFormElement,(void**)&pFormElement)==S_OK)//获取FORMELEMENT
{
CComBSTR form_name;
char ch_form[100];
memset(ch_form,0,100);
pFormElement->get_name(&form_name);
CComBSTR_to_char(form_name,ch_form,100);
memset(echo_data,0,1024);
sprintf(echo_data,"第%d个表单名为:%s\n",i,ch_form);
this->ui.textEdit->insertPlainText(echo_data);
long item_num=0;
if(pFormElement->get_length(&item_num)==S_OK)
{
for(long j=0;j<item_num;j++)
{
V_VT(&id) = VT_I4;
V_I4(&id) = j;
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
if(pFormElement->item(id,index, &spDispatch)==S_OK)
{
if(spDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement)==S_OK)
{
CComBSTR value;
CComBSTR name;
CComBSTR type;
CComBSTR cls_ID;
pInputElement->get_type(&type);
if(type==CComBSTR("text"))
{
pInputElement->get_name(&name);
pInputElement->get_value(&value);
memset(echo_data,0,1024);
sprintf(echo_data,"输入框name:");
CComBSTR_to_char(name,echo_data+strlen(echo_data),1024);
sprintf(echo_data+strlen(echo_data),"输入框内的值:");
CComBSTR_to_char(value,echo_data+strlen(echo_data),1024);
strcat(echo_data,"\n");
this->ui.textEdit->insertPlainText(echo_data);
}
else if(type==CComBSTR("password"))
{
pInputElement->get_name(&name);
pInputElement->get_value(&value);
memset(echo_data,0,1024);
sprintf(echo_data,"密码框name:");
CComBSTR_to_char(name,echo_data+strlen(echo_data),1024);
sprintf(echo_data+strlen(echo_data),"密码框内的值:");
CComBSTR_to_char(value,echo_data+strlen(echo_data),1024);
strcat(echo_data,"\n");
this->ui.textEdit->insertPlainText(echo_data);
}
}
else if(spDispatch->QueryInterface(IID_IHTMLElement,(void**)&pElement)==S_OK)
{
CComBSTR value;
CComBSTR name;
CComBSTR type;
CComBSTR cls_ID;
pElement->get_type(&type);
if(type==CComBSTR("submit"))
{
pButtonElement->get_name(&name);
pButtonElement->get_value(&value);
memset(echo_data,0,1024);
sprintf(echo_data,"提交按钮name:");
CComBSTR_to_char(name,echo_data+strlen(echo_data),1024);
sprintf(echo_data+strlen(echo_data),"提交按钮内的值:");
CComBSTR_to_char(value,echo_data+strlen(echo_data),1024);
strcat(echo_data,"\n");
this->ui.textEdit->insertPlainText(echo_data);
}
}
}
}
}