More Interface Stuff
Here are some other enhanced interface issues you might be interested in:
-
Wouldn’t it be nice to have a drop-down list for selecting drives and directories, like the one in Windows Explorer and the Open common dialog? Well, tough luck. Windows provides no way to reuse the standard control. Not in Visual Basic or in any other language. You can, however, produce a similar but cruder effect with the Browse For Folder dialog box. I wrap the SHBrowseForFolder API function in the Visual Basic function BrowseForFolder (in FOLDTOOL.BAS). You pass in arguments to set the initial state of the dialog box, and then get the results from the return value. To see it in action, click on the button next to the Destination field in the Windows Interface Tricks application shown in Figure 11-10 on page 666. Fortunately, someone wasn’t ready to take this crude tool for granted. Take a look at the control supplied by hardcore programmer Andrea Wyss. You’ll see an example of this on the companion CD.
-
You can add files to the Documents list on the Start menu by calling the AddToRecentDocs procedure (in FOLDTOOL.BAS), which in turn calls SHAddToRecentDocs. You can clear the list with ClearRecentDocs. The Windows Interface Tricks application has buttons that demonstrate these functions.
-
If your application needs to put a status icon on the Taskbar, you
can call Shell_NotifyIcon to install or remove the icon. I wrap the Shell_NotifyIcon function in the CTrayIcon class; you can see it in action in the Windows Interface Tricks application. The class uses the subclassing system described at the end of Chapter 6 to handle mouse messages from the installed tray object. To create a new CTrayIcon object, declare it using the WithEvents syntax, then call the Create method to pass in a window handle, an icon, and a tip string. CTrayIcon uses this information to install your icon and generate events whenever the user interacts with it. (Be careful when debugging the application. If you interrupt the program with the End button, you’ll never hit the Unload event where tray objects are destroyed. You’ll end up with orphaned icons on your Taskbar.) CTrayIcon is very easy to install and use even if you don’t care how it works, but hardcore programmers might also want to study the implementation in TRAYICON.CLS.
-
You can make good use of new help features such as the What’s This? help button. There’s a programming element to this, but most of the work lies in creating the help files. (I confess to not writing a single help file for the samples provided with this book. You’re on your own.)
-
To support Plug and Play, you can install the System Information control, through which you can monitor various events, particularly those that change the screen size. Unfortunately, this is another control that shouldn’t be a control. I wanted to attach the same events to the System object described on page 612, but I didn’t get around to it.
-
Use property sheets everywhere you can. Create a property sheet form for your document types, using either the TabStrip or the Tabbed Dialog control. Put a Properties item on your toolbars and your context menus whenever appropriate.