Creating a Statusbar Control with VFP 8
Visual FoxPro 8 offers many new features and opportunities to make life easier.In this article Rick describes how to build a native VFP-based status bar that fixes some of the problems found in the Windows Common Control OCX version (MSCOMCTL.OCX) that ships with VFP and other development tools. This article introduces several new VFP 8 features: Collections, the Empty object, AddProperty() and BindEvents(), and shows how to integrate these new features into a useful component.
One of the really cool features of VFP 8 is its ability to work with Windows Themes and provide fully themed user interfaces. Some people say that XP themes are nothing more than fancy window dressing that suck up CPU cycles and screen real estate, but once you start using themes it's hard to look back on the classic Windows interface and not have it feel archaic.
Visual FoxPro 8 now supports fully themed controls for all of its own native controls. Unfortunately, the same is not true of the Common Controls ActiveX controls (MSCOMCTL.OCX) that many of us use to build enhanced user interfaces for our users. Even when using a Manifest file (see sidebar), the various controls like the treeview, listview, statusbar, progressbar and others do not inherit the Windows XP look and feel and instead render in the 'classic' style, which looks a little bit funky when you run them inside an otherwise themed application. To me this is most noticeable with the StatusBar control, which gives away a non-XP compliant application immediately.
It's too bad we have a nice XP style interface for our forms but are stuck with statusbars, treeviews, and listviews that are stuck in the 'classic' era.
What's wrong with MSCOMCTL StatusBar?
The StatusBar ActiveX control has always had a number of problems. The most obvious is that the StatusBar does not properly show the sizing grip even when you enable the sizing grip in the control. Well, it does ? sometimes. If you define the control in code and add it to the form and run it in an MDI form inside of the main VFP or another Fox application window, then it works. But in a Top Level Form the sizing grip never shows. Many of us have gotten around this by utilizing an image and embedding it on the statusbar (see Figure 1).
Figure 1: A nice themed VFP application with a StatusBar control that's stuck in Windows Classic mode
I use the StatusBar control in almost all of my applications and in many of them it has serious timing problems with form rendering. The result is that the StatusBar often doesn't show up correctly ? either completely missing or missing the panels ? when the form first loads. It will show up correctly after the form is resized for the first time. To work around this funky (and very inconsistent) behavior, you need to insert several DoEvents and refresh the StatusBar from the Form's Activate event. And even then it sometimes doesn't behave correctly.
Now with VFP 8 supporting Windows Themes, the most visible problem is that the StatusBar isn't themed. Figure 1 shows a VFP 8 application running under XP with the nice themed user interface, but a status bar that is stuck in Windows Classic mode, which looks funky and rather unprofessional.
By: Rick Strahl
Rick Strahl is president of West Wind Technologies in Maui, Hawaii. The company specializes in Web and distributed application development and tools, with focus on Windows Server Products, .NET, Visual Studio, and Visual FoxPro. Rick is the author of West Wind Web Connection, West Wind Web Store, and West Wind HTML Help Builder. He’s also a C# MVP, a frequent contributor to magazines and books, a frequent speaker at international developer conferences, and the co-publisher of CoDe Magazine. For more information please visit his Web site at www.west-wind.com or contact Rick at firstname.lastname@example.org.
Visual FoxPro 8 offers full support for themes and the XP style look. Unfortunately the Windows Common Control OCX that ships with VFP 8 doesn't support this same look. This article describes how to build a status bar control that looks and behaves like an XP style status bar, using several new features of VFP 8.
Code for this article: