線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1843
推到 Plurk!
推到 Facebook!

請問如何知道點擊網頁這個事件

缺席
MyYunSong
一般會員


發表:10
回覆:18
積分:5
註冊:2004-08-20

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-09-01 19:22:08 IP:61.235.xxx.xxx 未訂閱
用CppWebBrowser 看網頁,當用滑鼠點擊網頁的鏈接時,請問如何得到這個事件?
nlj859
資深會員


發表:139
回覆:375
積分:322
註冊:2004-03-20

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-09-02 13:09:33 IP:219.80.xxx.xxx 未訂閱
Hello MyYunSong,    使用OnBeforeNavigate2. OnBeforeNavigate2 Occurs immediately before the Web browser navigates to a new resource. OnCommandStateChange Occurs when the ability to execute certain TCppWebBrowser methods changes. OnDocumentComplete Occurs when the document being navigated to reaches ReadyState_Complete. OnDownloadBegin Occurs when the Web browser starts downloading a document. OnDownloadComplete Occurs when a navigation operation finishes, is halted, or fails. OnNavigateComplete2 Occurs immediately after the Web browser successfully navigates to a new location. OnTitleChange Occurs when the title of a document in the WebBrowser control becomes available or changes. 參考看看.
MyYunSong
一般會員


發表:10
回覆:18
積分:5
註冊:2004-08-20

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-09-02 13:13:33 IP:61.235.xxx.xxx 未訂閱
版主和大大們幫幫我啊
MyYunSong
一般會員


發表:10
回覆:18
積分:5
註冊:2004-08-20

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-09-02 13:21:33 IP:61.235.xxx.xxx 未訂閱
我找到了,就是這要,用接口來做 LinkClickEvt(DISPID id, VARIANT* pVarResult) {         //TODO: Add your source code here         HRESULT hResult;         System::DelphiInterface htmlwnd2; System::DelphiInterface htmlevt; System::DelphiInterface htmlelem; _di_IDispatch disp; System::DelphiInterface htmldoc2; try { disp = this->CppWebBrowser1->Document; if(disp==NULL) return; if(disp->QueryInterface(IID_IHTMLDocument2,(void**)&htmldoc2)!=0) return; hResult=htmldoc2->get_parentWindow(&htmlwnd2); if (htmlwnd2==NULL) return; if FAILED(hResult) return; hResult=htmlwnd2->get_event(&htmlevt); if (htmlevt==NULL) return; if FAILED(hResult) return; hResult=htmlevt->get_srcElement(&htmlelem); if(htmlelem==NULL) return; if FAILED(hResult) return; WideString ws; ws.SetLength(10240); hResult=htmlelem->get_outerHTML(&ws); } StartIt(TObject *Sender) { HRESULT hResult; _di_IDispatch disp; System::DelphiInterface htmldoc2; System::DelphiInterface htmlelem; disp = this->CppWebBrowser1->Document; if(disp == NULL) return false; hResult=disp->QueryInterface(IID_IHTMLDocument2,(void**)&htmldoc2); if(hResult!=S_OK) return false; // if FAILED(hResult) return; // if(htmldoc2==NULL) return false; hResult=htmldoc2->get_body(&htmlelem); if FAILED(hResult) return false; if(htmlelem==NULL) return false; WideString ws; ws.SetLength(10240); hResult=htmldoc2->get_title(&ws); if FAILED(hResult) return false; Hint=ws.c_bstr(); MySheet->Caption=Hint; MyPageControl->Hint=Hint; TVariant vt; vt = CFunctionObject::CreateEventFunctionObject(this,&TFrame1::LinkClickEvt,0); htmlelem->put_onclick(vt); htmlelem->Release(); htmldoc2->Release(); disp->Release(); return true; }
jackiehcc
一般會員


發表:3
回覆:2
積分:1
註冊:2005-06-29

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-08-31 09:51:23 IP:220.130.xxx.xxx 未訂閱
LinkClickEvt(DISPID id, VARIANT* pVarResult) { //TODO: Add your source code here HRESULT hResult; System::DelphiInterface htmlwnd2; System::DelphiInterface htmlevt; System::DelphiInterface htmlelem; _di_IDispatch disp; System::DelphiInterface htmldoc2; try { disp = this->CppWebBrowser1->Document; if(disp==NULL) return; if(disp->QueryInterface(IID_IHTMLDocument2,(void**)&htmldoc2)!=0) return; hResult=htmldoc2->get_parentWindow(&htmlwnd2); if (htmlwnd2==NULL) return; if FAILED(hResult) return; hResult=htmlwnd2->get_event(&htmlevt); if (htmlevt==NULL) return; if FAILED(hResult) return; hResult=htmlevt->get_srcElement(&htmlelem); if(htmlelem==NULL) return; if FAILED(hResult) return; WideString ws; ws.SetLength(10240); hResult=htmlelem->get_outerHTML(&ws); } StartIt(TObject *Sender) { HRESULT hResult; _di_IDispatch disp; System::DelphiInterface htmldoc2; System::DelphiInterface htmlelem; disp = this->CppWebBrowser1->Document; if(disp == NULL) return false; hResult=disp->QueryInterface(IID_IHTMLDocument2,(void**)&htmldoc2); if(hResult!=S_OK) return false; // if FAILED(hResult) return; // if(htmldoc2==NULL) return false; hResult=htmldoc2->get_body(&htmlelem); if FAILED(hResult) return false; if(htmlelem==NULL) return false; WideString ws; ws.SetLength(10240); hResult=htmldoc2->get_title(&ws); if FAILED(hResult) return false; Hint=ws.c_bstr(); MySheet->Caption=Hint; MyPageControl->Hint=Hint; TVariant vt; vt = CFunctionObject::CreateEventFunctionObject(this,&TFrame1::LinkClickEvt,0); htmlelem->put_onclick(vt); htmlelem->Release(); htmldoc2->Release(); disp->Release(); return true; } 有人可以將上篇翻譯成Delphi的做法嗎? 我功力不足,請高手幫幫忙一下,謝謝唷!!
emmanuel@erphk.com
一般會員


發表:0
回覆:1
積分:0
註冊:2005-09-27

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-09-29 21:31:25 IP:219.134.xxx.xxx 未訂閱
騙人的只是這三行就出錯了    System::DelphiInterface htmlwnd2; System::DelphiInterface htmlevt; System::DelphiInterface htmlelem;    [C++ Error] : E2102 Cannot use template 'DelphiInterface' without specifying specialization parameters 有try 又沒有 catch. 亂寫一堆
jackiehcc
一般會員


發表:3
回覆:2
積分:1
註冊:2005-06-29

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-09-30 00:15:06 IP:61.230.xxx.xxx 未訂閱
這題不是我回答的,我根本不會c 不知道誰用了我的帳號...
系統時間:2024-05-19 23:38:10
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!