Visual C++ Articles

Visual C++ related articles

Version Manager

Version Manager is a COM Add-in for Visual C++ .NET written in C++.  Its job is to increment the version number of the application being developed by one on each build (best known as the application's build number).  This add-in searches the project for an .rc file, and it if it finds one, it parses the .rc file to find the version information token(s), and increments the build count by one, and saves the file, and allows the compiler to proceed in compiling the application.

WebBrowser Goodies

I have worked with Microsoft WebBrowser control, MSHTML (the HTML parsing and rendering engine behind the WebBrowser control) and Internet Explorer quite a bit, and I have gained a lot of experience and information about them.  I have several articles on this subject, each of which cover a certain point about the topics mentioned above.  Here is a list of articles on this subject; I will update this list as I add newer articles.  Some of the articles on this list you may already have seen, the others are new.  I have also provided a short description on what each article is about.  Hope they will be useful to you.

IE Spy

IE Spy is a tool I wrote some time ago.  This tool enumerates all the windows of the WebBrowser control (including instances of Internet Explorer), and executes a set of standard commands on them, like View Source, Save, Refresh, Print, etc.  This tool may be useful to you for your special needs.  For example, suppose a program shows an HTML dialog and you want to see the HTML source of the page the dialog is displaying.  One way would be digging into the EXE resources and/or finding the page being displayed, using a Win32 Resource Editor utility (if necessary), and see its source code.  But this is tedious.  You can just use IE Spy plus Spy++ to obtain the source code instantly.  You should just us

Common WebBrowser Commands

Almost everyone has used the MFC AppWizard to create a CHtmlView-based application at least once.  Many of us also have written programs which are totally based upon CHtmlView and hence on the WebBrowser control.  When you use the MFC AppWizard to create the project, you'll get a relatively nice and functional web browser right away.  You can simply implement standard commands of a web browser like Back, Forward, Home, Refresh, etc.

HTML Dialogs

One of the most useful UI elements that can be simply merged into applications is HTML dialogs.  An HTML dialog is a normal dialog, except that it shows HTML content instead of normal dialog elements.  You can use any HTML code for an HTML dialog; even you can use DHTML, and scripting, embed Flash animations, use Java applets, and absolutely anything you can do with normal applications.  If you are good in designing pages, HTML dialogs provide a rapid way for developing rich user interfaces.  Many big applications are using HTML dialogs.  The most famous sample is Microsoft Internet Explorer.  Open up IE, choose Help | About menu item, and yuppers!  What you see is an HTML dialog!  Microsoft's

Advanced CHtmlView Hosting

The WebBrowser control (and CHtmlView, as its wrapper) is a great tool.  It saves you quite a bit of work to enable web-browsing features inside your applications.  But since it's not written by you, you have a limited amount of control over how it looks and acts.  The developers of WebBrowser control and MSHTML have provided use some advanced hosting features, so that once an application implements them, it can customize the behavior of the WebBrowser control in more aspects.  These customizations are accomplished by a set of interfaces.  The host application has to implement these interfaces, and MSHTML will query its host for these interfaces, and uses them if available.  These interfaces are IDocHostUIHandler, IDocHostShowUI, and ICustomDoc, w

Extending the WebBrowser DOM

Any application that uses the WebBrowser control for its User Interface will have to implement some functionality which allows the application to talk with the HTML page and vice versa.  Without this, using WebBrowser control will not make much sense, unless you only want to show the users some nice HTML stuff without allowing them to do anything with it.

Custom WebBrowser Registry Settings

The WebBrowser control stores many kinds of different information about user preferences inside the registry.  These settings are stores in the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\ registry key (as well as the keys below it).  Investigate that registry key using REGEDIT.EXE.  You'll find many different settings there.  Changing those settings will change how the WebBrowser looks and acts.  See my Changing IE Show Picture Setting article for an example of how to change a key value that toggles the "Show Picture" setting of the WebBrowser control.  What is important is touching any keys or values at that location will affect all the instances of the WebBrow

Custom WebBrowser Message Boxes

Imagine you have written an application which uses rich HTML user interface, with a lot of scripting and DHTML effects.  Maybe somewhere in your script codes, you have used the window.alert( ) function, and as soon as the alert message pops up, what do the users see?  A message box titled "Microsoft Internet Explorer"!  Hey, of course you are using the IE technology, but you don't like the normal user notice it, do you?!

Custom WebBrowser Context Menus

In my Advanced CHtmlView Hosting article, I showed a way to disable the context menu for the WebBrowser control.  Inside the ShowContextMenu( ) handler, you can display your own context menu using ::TrackPopupMenu( ).  This requires building your own menu using the Win32 API, or creating a menu resource, and loading it.  However, there are disadvantages in this approach.  First of all, you have to implement the functionality of every menu item yourself, which could be a tedious task.  Other than it, maybe you only want to disable one item of the context menu, and show the rest.  Of course you might say that one can create a menu resource that has all the items as the WebBrowser's default c

Syndicate content