The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
  Code Libraries &nbsp
&nbsp

Common Dialog Hooks - Create a VB Style Open Project Dialog

 
 

Using Hooks to Create Fully-Featured File Dialogs

 


 NOTE: this code has been superceded by the version at the new site.



&nbsp
Demonstration of Embedding File Open Dialog

Download the VB-Style File New/Open Sample (32kb)
Download the Picture Preview File Open Sample (27kb)

&nbsp UpdatedUpdated! 21 March 2000 &nbsp
&nbsp Updated samples so that they take into account the different window shapes caused when you set the system to Large fonts (or modify the system Font Size setting to something other than 96 dpi). &nbsp
&nbsp 1 November 1999 &nbsp
&nbsp Mark Grimes completely rewrote the VB style File-Open demonstration so it has the correct tab order and the dialog keeps in focus. Much better than my version, so I've canned the one I wrote!

He also supplied the Picture Preview sample which is included in the download here.
&nbsp
&nbsp Before you Begin &nbsp
&nbsp This project requires the CommonDialog/Direct component. Make sure you have loaded and registered this before trying the project. &nbsp
 

Overview
This sample, completely rewritten from an original sample at this site by Mark Grimes (kapag@tir.com), demonstrates how to create a full VB-style Open project dialog by taking advantage of the Hook support provided in the CommonDialog/Direct DLL component.

Implementing a hook for a Common Dialog allows numerous messages in the dialog to be intercepted. In this case, the dialog open notification is utilised to capture elements from a VB form into the common dialog, and OK/Cancel button clicks are intercepted to determine whether to close the VB form. The result is an excellent way of creating customised File Open dialogs which additionally show your own fields.

There is another way to implement this sort of functionality, which is to use Common Dialog Templates. Cayce Cochran rose to the challenge of making templates work in VB, and you can see the result in the sample Common Dialog Templates. Excellent stuff, but the approach only supports the standard Windows controls. If you need something more, then hooking the dialog and combining it with a VB form is the way to go.

The only difficulty with it is that the coding to get all the items in the right place, and working out the tabbing, can be pretty tedious and error prone. Since the only way to ensure tabbing works correctly is to use a Windows Keyboard Hook, you also might find it difficult to debug...




TopBack to top
Source Code - What We're About!Back to Code Libraries
Source Code - What We're About!Back to Source Code Overview

&nbsp  
 

About  Contribute  Send Feedback  Privacy

Copyright © 1998-2000, Steve McMahon ( steve@vbaccelerator.com). All Rights Reserved.
Last updated: 21 March 2000