Creating a StatusBar Control with VFP 8

Creating a StatusBar Control with VFP 8

isual 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.

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 such as 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).

Using a VFP-Based wwStatusBar Class
To work around this problem, I decided to ditch the ActiveX control and write a new VFP class that simulates a StatusBar using VFP code. The control can render in XP style, in ‘classic’ style, and in a modified classic style that mixes XP and classic styles. It doesn’t mimic all the functionality of the ActiveX control, but implements most of the important functionality in an easy to use container class. Figure 2 shows a VFP application running with the wwStatusBar control in XP themes mode.

Some Limitations
Keep in mind that this is a minimalist implementation that isn’t completely event enabled. If you change certain properties of the wwStatusBar object, make sure that you always call RenderPanel() or RenderPanels() to refresh the status bar display properly. RenderPanels() is required anytime the sizes of panels change.

See also  Comparing different methods of testing your Infrastructure-as-Code

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist

©2024 Copyright DevX - All Rights Reserved. Registration or use of this site constitutes acceptance of our Terms of Service and Privacy Policy.