[zz]IE編程技巧

來源:互聯網
上載者:User

1.實現Ctrl+C:

    ExecWB(OLECMDID_COPY,OLECMDEXECOPT_DONTPROMPTUSER,NULL,NULL); 

2.實現Ctrl+V:

    ExecWB(OLECMDID_PASTE,OLECMDEXECOPT_DONTPROMPTUSER,NULL,NULL); 

3.實現尋找:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_FIND,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

4.實現顯示來源程式:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_VIEWSOURCE,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

5.實現顯示Internet選項:

MSHTML::IHTMLDocument2Ptr pdoc;
_variant_t varinput,varoutput;
IOleCommandTarget *pCmd;
HRESULT hr;
pdoc=GetHtmlDocument();
hr=pdoc.QueryInterface(IID_IOleCommandTarget,&pCmd);
if(SUCCEEDED(hr))
{
varinput=_T("");
hr=pCmd->Exec(&CGID_MSHTML,IDM_OPTIONS,OLECMDEXECOPT_DODEFAULT,&varinput,&varoutput);
}

6.下載事件說明:

OnDownloadBegin <--開始下載
OnDownloadComplete <--下載結束
OnDocumentComplete <--頁面下載完畢

對於每個HTML頁面,順序都是如此.如果是Frame或IFrame的檔案都會當成HTML頁面處理.也就是說如果一個頁面中有3個IFrame,那麼總共會觸發4次BeforeNavigate2事件.

對於每個串連且需要顯示出來的二進位檔案(如*.gif,*.bmp,*.jpg...)都會觸發一個DownloadBegin和DownloadComplete事件.

那我們怎麼判斷是否全部下載完畢呢?嘿嘿,TWebBrowser控制項不是有一個Busy屬性的嗎?

7.點選連結產生的事件:

OnBeforeNavigate2 <--開始連結時會觸發此事件
OnNavigateComplete2 <--成功的連結到此網頁(以後才會有上面的事件)

8.包括相關檔案:

#include <mshtmhst.h>
#include <mshtmcid.h>//這裡面有很多實現IE功能的XXID,請看一看!
#import <mshtml.tlb>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.