[IE編程] 多頁面基於IE核心瀏覽器的程式碼範例

來源:互聯網
上載者:User

有不少人發信問這個問題,我把答案貼在這裡: 建議參考 WTL (Windows Template Library) 的程式碼範例工程 TabBrowser  (在WTL目錄/Samples/TabBrowser 下面)。該工程示範了如何用WTL + IE WebBrowser介面開發一個多Tab的IE核心瀏覽器, 並示範如何用ATL的IDispEventSimpleImpl監聽DWebBrowserEvents2 事件, 代碼簡潔易懂,很有參考價值。

WTL 是微軟的開源項目,可以去 http://wtl.sourceforge.net/ 上下載。

 

TabBrowser 代碼在Visual Studio 2008 上會有編譯錯誤

1>c:/projects/wtl80/samples/tabbrowser/stdafx.h(33) : error C2065: '_stdcallthunk' : undeclared identifier
1>c:/projects/wtl80/samples/tabbrowser/stdafx.h(33) : error C2070: ''unknown-type'': illegal sizeof operand

 

解決方案: 在stdafx.h 裡面加入#include <atlstdthunk.h>

 

#include <atlbase.h>
#include <atlstdthunk.h>  // 插入這行代碼可以解決VS2008 下的編譯錯誤

#ifdef _VC80X
  // Support for VS2005 Express & SDK ATL
  namespace ATL
  {
 inline void * __stdcall __AllocStdCallThunk()
 {
  return ::HeapAlloc(::GetProcessHeap(), 0, sizeof(_stdcallthunk));
 }

 inline void __stdcall __FreeStdCallThunk(void *p)
 {
  ::HeapFree(::GetProcessHeap(), 0, p);
 }
  };
#endif // _VC80X

 

 

 

如果想用MFC而不用ATL/WTL, MSDN 上有一個MFCIE 的程式碼範例工程值得參考

http://msdn.microsoft.com/en-us/library/ms177540(VS.80).aspx

 

 

另外, Codeproject 上有一篇文章"WTL Browser"也不錯 http://www.codeproject.com/KB/wtl/wtlbrowser.aspx 

 

 

>> 原創文章的著作權屬於作者,轉載請註明出處和作者資訊(http://blog.csdn.net/WinGeek/), 謝謝。 <<

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.