Click here to Skip to main content
15,878,852 members
Articles / Desktop Programming / WTL
Article

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 332.3K   3K   82   63
MDI and Tabbed WebBrowser

Sample Image

Preface

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.

Features

  • 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.

Problems

  • 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!

Warning

  • 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.

Comment

  • 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.

WTL or MFC

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.

License

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


Written By
MB
Japan Japan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralLink Error Pin
kcjayhawk2-Apr-02 17:52
kcjayhawk2-Apr-02 17:52 
GeneralRe: Link Error Pin
4-Apr-02 23:11
suss4-Apr-02 23:11 
Questionhow to use function "internetsetoption" Pin
benben15-Mar-02 21:07
benben15-Mar-02 21:07 
AnswerRe: how to use function "internetsetoption" Pin
15-Mar-02 22:38
suss15-Mar-02 22:38 
Questionhow to let the menu support OLE-drag-and-drop Pin
aaaHHH26-Dec-01 4:11
aaaHHH26-Dec-01 4:11 
AnswerRe: how to let the menu support OLE-drag-and-drop Pin
MB27-Dec-01 18:01
MB27-Dec-01 18:01 
GeneralRe: how to let the menu support OLE-drag-and-drop Pin
aaaHHH13-Jan-02 21:32
aaaHHH13-Jan-02 21:32 
GeneralRe: how to let the menu support OLE-drag-and-drop Pin
MB14-Jan-02 18:00
MB14-Jan-02 18:00 
QuestionHow to Handle popup window in custom browser Pin
coolvcguy17-Dec-01 18:42
coolvcguy17-Dec-01 18:42 
AnswerRe: How to Handle popup window in custom browser Pin
MB19-Dec-01 11:58
MB19-Dec-01 11:58 
Generalerror compiling Pin
[ pomj ]5-Dec-01 12:20
[ pomj ]5-Dec-01 12:20 
GeneralRe: error compiling Pin
MB6-Dec-01 9:48
MB6-Dec-01 9:48 
GeneralRe: error compiling Pin
[ pomj ]7-Dec-01 10:31
[ pomj ]7-Dec-01 10:31 
GeneralRe: error compiling Pin
MB8-Dec-01 9:10
MB8-Dec-01 9:10 
GeneralA question about HTML filter Pin
Leo Wang27-Nov-01 5:06
Leo Wang27-Nov-01 5:06 
GeneralRe: A question about HTML filter Pin
MB27-Nov-01 7:59
MB27-Nov-01 7:59 
GeneralClipboard Bug Pin
Leo Wang21-Nov-01 2:23
Leo Wang21-Nov-01 2:23 
GeneralRe: Clipboard Bug Pin
MB22-Nov-01 3:26
MB22-Nov-01 3:26 
GeneralConstant not found Pin
Leo Wang18-Nov-01 2:00
Leo Wang18-Nov-01 2:00 
GeneralRe: Constant not found Pin
MB18-Nov-01 4:09
MB18-Nov-01 4:09 
GeneralCompile Error() Pin
16-Nov-01 18:51
suss16-Nov-01 18:51 
GeneralRe: Compile Error() Pin
Darren Schroeder17-Nov-01 2:24
Darren Schroeder17-Nov-01 2:24 
GeneralRe: Compile Error() Pin
MB17-Nov-01 2:55
MB17-Nov-01 2:55 
QuestionNew Version? Pin
Darren Schroeder15-Sep-01 15:04
Darren Schroeder15-Sep-01 15:04 
GeneralCompile Error(altres.h not found) Pin
Maria Jothi16-Jun-01 2:58
Maria Jothi16-Jun-01 2:58 

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.