Programming Samples

In this area, you'll find sample programs written in various languages. Some of the samples extend code found in my books, other samples show how to solve non-trivial problems that I have encountered. The list of samples will grow over time.

Signal Wiring Diagrams

Click here for the Visio stencil for Signal Wiring Diagrams, as described in my book Event-Based Programming: Taking Events to the Limit. The stencil works with Visio 2000 and later.

C# Code

Check out my article on for an in-depth description of Music Explorer. A PDF version is also available.

The book's sample code can be downloaded here. The code is contained in a single zip file, with separate folders for each chapter. The detailed table of contents for the book can be found here.

The original code for customizing the WebBrowser can be found in the book "Component-based Development with Visual C#". See above for all the book's code.  The entire chapter devoted to WebBrowser customization is also available online here.  The samples presented below show alternative ways to achieve customization. 

WebBrowserSample1 shows how to use the ICustomDoc interface to pass a reference to the host's IDocHostUIHandler interface to MsHtml. This approach is necessary when hosts don't implement the IOleClientSite interface. 

WebBrowserSample2 is a complete customization example, showing how to implement IDocHostUIHandler and IDocHostShowUI interfaces. The sample described in the book code contained the IDocHostUIHandler and other interfaces in a separate DLL. Because many programmers are interested in seeing the code that implements the various Ole interfaces, in Sample2 I created separate C# files for each interface, exposing all the details. The following interfaces are shown as C# classes: IOleClientSite, IOleDocumentSite, IDocHostUIHandler and IDocHostShowUI.

WebBrowserSample3 is an extension and refinement of WebBrowserSample2, and was presented at the Southern California .NET User Group in Long Beach, CA on 2003-2-12. Among the changes or additions are:

  1. It uses the WebBrowser's CommandStateChange event to control the enabling/disabling of the back and forward navigation buttons. 
  2. It shows how to implement File Save, using WebBrowser.ExecWB( ).  
  3. It  shows how to implement IDocHostUIHandler.GetExternal( ), to allow script on an HTML page to call custom methods of the host application. 

Other useful links to WebBrowser customization

Visual Basic.NET Code

VbCustomWebBrowser is a completely customized WebBrowser, implemented as a UserControl rather than a Windows Form. It uses the same Forward and Back button management as the C# example WebBrowserSample3.