使用CppWebBrowser提交表单的问题
我在用CppWebBrowser编程中,给一个文本框设置值的时候,弹出错误信息框,说是只读属性,请那位大虾指导一下。
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(this->ComboBox1->Text.Length()<0)
{
return;
}
this->Mycwb->Navigate(WideString(this->ComboBox1->Text));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnTestClick(TObject *Sender)
{
IHTMLDocument2 *pHTMLDoc=NULL; //定义一个网页文档指针
LPDISPATCH pDisp=NULL; //定义一个LPDISPATCH变量
if(this->Mycwb->Busy)
return;
pDisp=this->Mycwb->Document; //获取文档的内容
pDisp->QueryInterface(IID_IHTMLDocument2,(void **)&pHTMLDoc); //将文档指针值赋给pHTMLDoc
IHTMLElementCollection *pelement;
pHTMLDoc->get_forms(&pelement);
tagVARIANT a,i;
a.vt=VT_UI4;
a.iVal=0;
pelement->item(a,i,&pDisp);
IHTMLFormElement *pFormElem=NULL;
pDisp->QueryInterface(IID_IHTMLFormElement,(LPVOID*)&pFormElem);
LPDISPATCH pDisp_msg=NULL;
tagVARIANT phone,msg,empty;
phone.vt=VT_UI4;
phone.iVal=0
msg.vt=VT_UI4;
msg.iVal=1; pFormElem->item(phone,empty,&pDisp);
pFormElem->item(msg,empty,&pDisp_msg);
IHTMLInputTextElement *phoneElem=NULL;
pDisp->QueryInterface(IID_IHTMLInputTextElement,(void **)&phoneElem);
WideString s_phone;
s_phone=this->edtTest->Text;
phoneElem->put_value(s_phone.c_bstr());
}