Sybase, Inc. Navigational Bar

Powersoft Tools

Tip #10 - 100 cc's of ICONS - STAT! (StatusBar, that is.)

The Symptoms: Image of a textual GUI applicationThe patient is GUI but displays tendancies and traits towards character mode, leading to melancholy and depression. Despite having a window with a StatusBar, the only information in the StatusBar is textual and unexciting.

The Diagnosis: A whole application change is not necessary, just some additions to the StatusBar. A suggestion of icons in the StatusBar, and maybe a ProgressBar during a time of high activity (install, download, computation) is made. It would also be beneficial if the StatusBar were divided up into sections - and have those sections be resizeable if the window is resized.

The Prognosis: Once again, Power++ makes these sort of changes to your Win32 Windowed Executable easy. First let's add a StatusBar to your form. This is a property of your form. Right click on the form, choose Properties and then select the Status Bar tab. For this example I will be setting the StatusBarAtBottom property.

Before we go on, lets talk a bit about the StatusBar. StatusBar app with Object ViewIt is a component called WStatusBar. If you open up your View | Objects window, you will notice that at this point, you don't have an object called StatusBar. In fact, you don't have a variable to use to call the member functions. StatusBars are special creatures. There is a method of the form called GetStatusBar() that returns a (WStatusBar *). You should use this function whenever you want to call a member function of the current StatusBar.

Next comes the divisions of the StatusBar. The Power++ main window has a divided StatusBar. This is what we are going to accomplish in the following code in the Create() event of the form. Note that _statusBarRect is a "WRect _statusBarRect;" declared as a data member of the form.

Assuming that you have added the _statusBarRect as a data member of the form, you should be able to compile this and see a StatusBar with 3 parts. If you resize it, the first two sections will be of static size and the third section will expand to the rest of the size.

In order for the StatusBar to resize proportionally, you must add the exact same code to the resize event of the form. Right-click on the form, choose Events | More... and find the Resize() event for you form. Click on the word Resize and then click on the epsilon (...) that appears to right. That will create your Resize() event. Add the code above to this event. Now recompile and the sections will always be 1/3rd the size of the window.

Adding a ProgressBar to a StatusBar is an example of a more generic idea. Components are added to WWindows. A form is derived from WWindow, but so are other components like WCommandButton and WPictureBox. So a component can be added as a child to other components. The easiest way to do this is to drop a component on the form, in this case a WProgressBar from the Advanced Components, and then reassign the parent to be the WStatusBar.

Your ProgressBar is now in the 1st section of the Status Bar and resizes with the StatusBar. For the last part, we want to add an icon to the second section of the Status Bar. Open the Views | Resouces window and select menu File | Add Image... and select an icon from the list that is presented. Now drop a PictureBox onto the form and edit its Properties. Choose the Picture tab and in the Location selection, choose your icon denoted by its ResourceID (you can check the Views | Resources -> Icons if you don't know what the ResouceID is).

Now add the following code to the end of you Create() and Resize() events of the form (with the exception that the first line of code is only needed in the Create ).

Notice that the Width and Height are being set to 14x14. This is because by default, the icon that you added to the PictureBox is a 32x32 bit icon. This will resize the icon so that it will fit in the StatusBar.Dr.Power++'s finished Super Status Bar

In my sample, I added a WCommandButton that Start()'s a WTimer. When the WTimer handles its events, it increments the ProgressBar. When finished, it resets the ProgressBar to the beginning and Stop()'s. I have included a compressed version of my sample for download. ( I also have a special surprise for anyone who compiles the project.)

Click here to see Tip#11

Return to Power++ Home Page.

to top of page

Copyright 1999 Sybase, Inc. All Rights Reserved.
Privacy Policy