View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Status bar on a UserForm?

Robert Crandal used his keyboard to write :
Is it possible to display a status bar control at the bottom of UserForm to
display status alerts or whatever??

Basically, my form contains about 6 text labels. If the
mouse is moved over any text label, I want to display info
about that label in the status bar. I want the status bar to
be placed at the bottom of the userform, so it kind of looks
like a status bar of a typical Windows app.

I'd appreciate any ideas. Thanks


Hi Robert,
The StatusBar control is not part of the MSO standard controls and so
using it will require redistribution with your project on systems
running Vista or later. The control will require to be registered on
each machine where it doesn't exist.

Alternatively, you can use a label (or series of labels) to emulate a
statusbar across the bottom of your userform. You can play with the 3d
effects to get it looking exactly like a real statusbar. You can even
emulate panels by using multiple labels inside a container (ie: Frame
with no caption/border, etched SpecialEffect).

While a StatusBar control can be auto-locked to a form's edge (bottom
by default), you can set the position of the fram in the
Userform_Initialize event so it fits the entire width, and top is at
its height minus the userform's height. A bit more work but worth doing
if you make a template that's reusable, then just modify it for each
form built with the template.

If you code the positioning/sizing correctly, the frame should autofit
any userform size. If you use it on a resizeable form (requires code to
achieve) then you need to put code in its Resize event. Here's what I
use for my projects...

Private Sub UserForm_Initialize()
With Me.fraStatusBar
.Top = Me.Height - .Height * 2
.Left = Me.Left: .Width = Me.Width
.Height = 18 '//adjust to suit
End With
With Me.lblStatusBar1
.Top = 0 '//set to top of container
.Left = Me.fraStatusBar.Left + 2
.Width = Me.fraStatusBar.Width - 2
.Height = Me.fraStatusBar.Height - 2
.Caption = "Ready"
End With
End Sub

...to serve as the base. Additional labels inside the frame will just
require incrementing their number ID. Obviously, you'll need to manage
widths/lefts appropriately so there's no overlapping. Adding borders as
separators is a nice touch. Narrow labels works good for this as well.

You can play with the SpecialEffect property of the frame/label[s] to
make it look/feel like a real statusbar.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion