Click here to Skip to main content
14,977,142 members
Articles / Desktop Programming / WTL
Posted 14 Oct 2000


82 bookmarked

Donut, A WTL sample - Hosting WebBrowser Control

Rate me:
Please Sign up or sign in to vote.
4.73/5 (5 votes)
15 Nov 2001
MDI and Tabbed WebBrowser

Sample Image


Welcome to Donut2. Donut grows up to the practical application. I have resolved many problems, which involved even a bug of CString, for this year. WTL lacks: the way to serialize application general settings, to serialize Rebar-Bands states, to serialize Toolbar states, to ordering of ToolBar buttons, and to load 8bit bitmap Toolbar images, and the implementation of the reliable CommandBar, OLE-drag-drop, and Update-Command-UI. All is the foundamentals for your applications. So I had to write many drafts for them, and I have reached and published almost good one. Before you play your own role, check that codes.


  • Supports most of all Microsoft Internet Explorer supports
  • Controls downloading image, running scripts and so on
  • Switches active MDI child windows by Tab control
  • Deters advertising popup windows
  • Supports Favorite Group
  • Tab control supports OLE-drag-and-drop
  • Supports the loading of Favorites' order
  • You can try Mozilla control

Source code guide

  • ATL3.0 doesn't support put_DLControlFlags which controls downloading images etc, so I have Changed Atlhost.h a little. You need not to read AtlhostEx.h, AtlifaceEx.h, AtlifaceEx.idl, and AtlifaceEx_i.c.
  • Many users hope an application not use "Registry", so I wrote MtlProfile.h for "Ini file", in which algorithms support ATL::CRegKey, too. And you can find functions which save and load ReBar Bands' position.
  • In ExplorerMenu.h, Emulates IE's "Favorites Menu" which loads your Favorites dynamically.
  • As WTL::CCommandBarCtrl doesn't support MenuControl (Nobody finds MDI application with a command bar on rebar), I wrote MDIMenuControl.h.
  • In MtlWeb.h or MtlMisc.h you can find some utility functions. Some SHx APIs require the infamous "Active Desktop", so I had to write some codes instead of them.
  • If a SDI application, WTL::UpdateUI frame work is not bad. But if a MDI application, I think it useless. So I wrote CUpdateCmdUI.h from MFC's UpdateCommandUI framework.
  • If the file name is Mtlx.h, I think it reusable. If not, it's a draft header.


  • While switching the active maximized MDI child window, you can take a look at normal-sized window.
  • If you activate other window before page loading is completed, then WebBrowser control will lose a focus every page you go.
  • If a link decides target frame, "Window Lock" is not effective.
  • As I forcefully narrow the vertical gap of rebar in a menubar and toolbar band, if you change the position of toolbar bands, top and bottom of toolbar pressed buttons can't be painted.
  • If IE4, then you can't load Donut. Can you fix it?
  • It seems that SetWindowText API sometimes crashes. Somebody fix it!


  • Donut needs WTL3.1 and the latest SDK headers.
  • Donut doesn't use C-Runtime Library(CRT) according to WTL. (But it depends on the STL implementation. If HP's STL, it's ok. If SGI's STL, CRT required). If you determine whether to use CRT or not, you'd better use it! I guess that in Donut, which is not so large, the amout of code of tricks for avoidance of CRT is now more than CRT set-up codes.
  • If you build it in Release mode, the compiler would warn that Exception is invalid, but don't care.
  • Fonts of Dialog resources is "MS UI Gothic". So if you don't have this font, it's possible the dialog layout may go mad.
  • As I don't have English version of Microsoft Internet Explorer, All the menu texts is not same as that.
  • Favorite Group files are searched in the path \folder has Donut.exe\FavoriteGroup\. Please make FavoriteGroup folder.


  • Simple wrapper classes such as CWindow feel good. MFC tries to control a life of a window and often makes trouble.
  • Even if you write wrong codes, the access violation may not occur. I think HWND is even more safe than CWnd*.
  • WTL's message map is very flexible, so you can write codes much more easily than MFC in some cases.
  • CCommandBarCtrl is big one, but I think the function of displaying icons must be separated from command bar in order to smallize a code size, because I think many developers want only command bar.
  • About WTL's rebar framework, I have some complaints.
  • While developing it, I've found some bugs, you can check it out here, where you may still find bugs.


Donut now means "Why Don't you use WTL?". Even if you do a job with WTL, you will not think it useless, while you shares Donut source codes. WTL makes a use of the bare functionalities of Windows APIs, which is absolutely object-oriented (Do you believe it?). That's why WTL has the crucial advantage - the smallest and fastest code, that I think the reason why you choose C++. Now that the new programming paradigm is coming, you are trying to write codes in generic way: Concept-based, Policy-based programming, that is, template magics, almost of which VC6 can't cast. I believe WTL considerably will fit it.

Words of thanks

Special thanks to those who help me cook Donut, especially Dog-store, fub and Nishizawa. you can find them in the source code.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Japan Japan
No Biography provided

Comments and Discussions

GeneralWebbrowser by Visual studio .net 2005 Pin
VeeKeyBee2-Nov-08 1:50
MemberVeeKeyBee2-Nov-08 1:50 
GeneralRe: Webbrowser by Visual studio .net 2005 Pin
mbaocha6-May-09 16:50
Membermbaocha6-May-09 16:50 
QuestionHow can i add more than one rich text box in one desktop application (different tabs) Pin
VeeKeyBee2-Nov-08 1:47
MemberVeeKeyBee2-Nov-08 1:47 
GeneralDonut.rc(10) : fatal error RC1015: cannot open include file 'atlres.h'. Pin
some1One126-Jul-08 22:51
Membersome1One126-Jul-08 22:51 
QuestionControlling Sidebar from BHO Pin
Alex Shneyder9-Oct-07 17:15
MemberAlex Shneyder9-Oct-07 17:15 
GeneralUpdateCmdUI implementation is great Pin
kaddiexjc3-Apr-05 22:56
Memberkaddiexjc3-Apr-05 22:56 
Generalproblems with mtlweb.h Pin
nihoninu13-May-04 19:34
Membernihoninu13-May-04 19:34 
GeneralDonutin' alive Pin
MB23-Jan-03 10:29
MemberMB23-Jan-03 10:29 
Generalcompiling error: Pin
conquestjy8-Jan-03 21:44
Memberconquestjy8-Jan-03 21:44 
GeneralRe: compiling error: Pin
zerhart10-Jan-03 5:19
Memberzerhart10-Jan-03 5:19 
GeneralRe: compiling error: Pin
conquestjy14-Jan-03 21:42
Memberconquestjy14-Jan-03 21:42 
GeneralRe: compiling error: Pin
RAPT23-Jan-03 4:20
MemberRAPT23-Jan-03 4:20 
GeneralRe: compiling error: Pin
jerrycgl8-Jun-03 22:35
Memberjerrycgl8-Jun-03 22:35 
QuestionHow to use WebBrowser in dialog? Pin
marco.song15-Dec-02 4:25
Membermarco.song15-Dec-02 4:25 
Generalshow up a exception Pin
marco.song15-Dec-02 3:47
Membermarco.song15-Dec-02 3:47 
Generalcompiling error Pin
hibiki197918-Nov-02 14:37
Memberhibiki197918-Nov-02 14:37 
GeneralRe: compiling error Pin
Hp1218-Nov-02 23:41
MemberHp1218-Nov-02 23:41 
GeneralDoes not love WTL7 Pin
27-Jun-02 10:04
suss27-Jun-02 10:04 
GeneralTabbing issue Pin
15-Jun-02 20:30
suss15-Jun-02 20:30 
GeneralCompile Error Pin
13-Jun-02 1:01
suss13-Jun-02 1:01 
GeneralRe: Compile Error Pin
13-Jun-02 23:22
suss13-Jun-02 23:22 
GeneralMozilla Control Integration Pin
Frank Dering16-Apr-02 1:42
MemberFrank Dering16-Apr-02 1:42 
GeneralRe: Mozilla Control Integration Pin
16-Apr-02 3:27
suss16-Apr-02 3:27 
GeneralRe: Mozilla Control Integration Pin
Frank Dering17-Apr-02 2:18
MemberFrank Dering17-Apr-02 2:18 
GeneralRe: Mozilla Control Integration Pin
17-Apr-02 5:22
suss17-Apr-02 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.