請問如何知道點擊網頁這個事件 |
缺席
|
MyYunSong
一般會員 發表:10 回覆:18 積分:5 註冊:2004-08-20 發送簡訊給我 |
|
nlj859
資深會員 發表:139 回覆:375 積分:322 註冊:2004-03-20 發送簡訊給我 |
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 發送簡訊給我 |
|
MyYunSong
一般會員 發表:10 回覆:18 積分:5 註冊:2004-08-20 發送簡訊給我 |
我找到了,就是這要,用接口來做
LinkClickEvt(DISPID id, VARIANT* pVarResult)
{
//TODO: Add your source code here
HRESULT hResult;
System::DelphiInterface
|
jackiehcc
一般會員 發表:3 回覆:2 積分:1 註冊:2005-06-29 發送簡訊給我 |
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 發送簡訊給我 |
|
jackiehcc
一般會員 發表:3 回覆:2 積分:1 註冊:2005-06-29 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |