Click here to Skip to main content
Click here to Skip to main content

Donut, A WTL sample - Hosting WebBrowser Control

, 15 Nov 2001
Rate this:
Please Sign up or sign in to vote.
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 PinmemberVishnu K B2-Nov-08 2:50 
GeneralRe: Webbrowser by Visual studio .net 2005 Pinmembermbaocha6-May-09 17:50 
QuestionHow can i add more than one rich text box in one desktop application (different tabs) PinmemberVishnu K B2-Nov-08 2:47 
GeneralDonut.rc(10) : fatal error RC1015: cannot open include file 'atlres.h'. PinmemberK.O.26-Jul-08 23:51 
QuestionControlling Sidebar from BHO PinmemberAlex Shneyder9-Oct-07 18:15 
GeneralUpdateCmdUI implementation is great Pinmemberkaddiexjc3-Apr-05 23:56 
Generalproblems with mtlweb.h Pinmembernihoninu13-May-04 20:34 
GeneralDonutin' alive PinmemberMB23-Jan-03 11:29 
Generalcompiling error: Pinmemberconquestjy8-Jan-03 22:44 
GeneralRe: compiling error: Pinmemberzerhart10-Jan-03 6:19 
GeneralRe: compiling error: Pinmemberconquestjy14-Jan-03 22:42 
GeneralRe: compiling error: PinsussRAPT23-Jan-03 5:20 
GeneralRe: compiling error: Pinmemberjerrycgl8-Jun-03 23:35 
QuestionHow to use WebBrowser in dialog? Pinmembermarco.song15-Dec-02 5:25 
Generalshow up a exception Pinmembermarco.song15-Dec-02 4:47 
Generalcompiling error Pinmemberhibiki197918-Nov-02 15:37 
GeneralRe: compiling error PinmemberHp1219-Nov-02 0:41 
GeneralDoes not love WTL7 PinmemberAnonymous27-Jun-02 11:04 
GeneralTabbing issue PinmemberAnonymous15-Jun-02 21:30 
GeneralCompile Error PinmemberAlexT13-Jun-02 2:01 
GeneralRe: Compile Error PinmemberMBMB14-Jun-02 0:22 
GeneralMozilla Control Integration PinmemberFrank Sowinski16-Apr-02 2:42 
GeneralRe: Mozilla Control Integration PinmemberMBMB16-Apr-02 4:27 
GeneralRe: Mozilla Control Integration PinmemberFrank Sowinski17-Apr-02 3:18 
GeneralRe: Mozilla Control Integration PinmemberMBMB17-Apr-02 6:22 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150331.1 | Last Updated 16 Nov 2001
Article Copyright 2000 by MB
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid