W
WilliamGui
Unregistered / Unconfirmed
GUEST, unregistred user!
用WebBrowser实现打开google点击搜索,第一次正常,再点击就不行,怎么回事代码如下:function TfrmMain.OpenWebPage(pSearchEngine: TSearchEngine; pSearchContent: string; pPageNo: integer): boolean; //WebBrowser动作:打开搜索引擎首页 function WB_OpenSearchEngine(pURL: string; pWebBrowser: TWebBrowser): boolean; begin result:=false; if trim(pURL)='' then exit; if pWebBrowser=nil then exit; if pWebBrowser.Busy then pWebBrowser.Stop; try pWebBrowser.Navigate(pURL); except exit; end; result:=true; end;var vURL: string; vWebBrowser: TWebBrowser; vWBDoc:IHTMLDocument2; vWBSearchContentName, vWBSearchBtnName: string; vWBSearchContent:IHtmlInputElement; vWBSearchBtn:OleVariant;begin result:=false; case pSearchEngine of Google: begin vURL:=SearchEngineURL_Google; vWBSearchContentName:='q'; vWBSearchBtnName:='btnG'; vWebBrowser:=wbGoogle; if not WB_OpenSearchEngine(vURL, vWebBrowser) then exit; while vWebBrowser.busy do begin Application.ProcessMessages; end; vWBDoc:=vWebBrowser.document as IHTMLDocument2; vWBSearchContent:=(vWBDoc.all.item(vWBSearchContentName,0) as ihtmlinputelement); vWBSearchContent.value:=vWBSearchContent.value+edtSearchContent.Text; vWBSearchBtn:=vWBDoc.all.item(vWBSearchBtnName,0); vWBSearchBtn.click; end; Baidu: begin