INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Tips -N- Tricks

How can I create my own statusbar? by ChrisRChamberlain
Posted: 11 Feb 03 (Edited 12 Feb 03)

If you need more from a StatusBar than either the native VFP or the MS StatusBar ActiveX control can offer, then creating your own InterNet Explorer style statusbar is not as difficult as you might imagine.

What this statusbar will not do is display the messages from a VFP menu.

What it will do is a whole lot more than the alternatives and is only really limited by your imagination as a developer!

In the following example a simple five panel statusbar bar is created.

Panel 1 - Bitmap + line of text

This is used to display a 16 x 16 bitmap and text string relative to the control passed over by the mouse, or any other bitmaps/messages you programatically send.

Panel 2 - Progressbar

This displays the progress of processing within a loop

Panel 3 - AVI Player

This displays 16 x 16 .avi files

Panel 4 - Time display

Time including seconds, (if you don't already have a timer running, you will need to add one)

Panel 5 - Date display

Today's date


The example comes from an MDI form which sits at the bottom of _SCREEN, so to include the statusbar in a form, you simply replace the _SCREEN references with THISFORM.

The panels are containers with the following non-default properties

.Height = 20
.SpecialEffect = 1

The containers for panels 1 - .cntPanel1, 2 - .cntPanel2 and 3 - .cntPanel3, each have a form method relative to the container, .mCntPanel1(), .mCntPanel2() and .mCntPanel3().

File names, messages etc are passed to the controls in the container through the methods as parameters.

The .Resize() event of the form adjusts the positions of the containers relative to the width of the form.
The width of .cntPanel1 is adjusted relative to the width of the remaining space in the statusbar.

The code and controls required for the progressbar can be found in FAQ184-2366

You will not find many 16 x 16 .avi files but making your own is easy.

Let's assume you want the print icon or the save icon to flash during an operation. In animation terms you could use two bitmaps, a 16 x 16 bitmap with an image and 16 x 16 bitmap without an image. The player continuously plays the sequence and thus the display flashes, until told to stop.

To show the .avi file you need the OleClass MSComCt2.Animation.2 control to be found in the list of ActiveX controls.
To be able to create .avi files, download the freeware AviCreator 1.5 to be found through any Internet search engine.

If you don't want to take advantage of the possibilities presented by using the animation control, a simple workaround is to use an image control instead and use the timer event to toggle the .Visible property. This will cause the image control to appear/disappear every second.

The sizing of the controls is important - I suggest you use MS Sans Serif fontsize 9 for the labels and 16 x 16 for the image and olecontrol. The texbox use for the progressbar should be the same size as its container.

So how do you send messages to the statusbar?

In the .MouseEnter() or .MouseMove() event of a control such as a commandbutton of a toolbar, put :-

oStatusBar.mCntPanel1(THIS.Picture,THIS.ToolTipText)

The code in the method .mCntPanel1() would be :-

LPARAMETERS cFile, cLine1

WITH THIS
    .cntPanel1.Image1.Picture = cFile
    .cntPanel1.Label1.Caption = cLine1
ENDWITH

For form objects, you need to substitute THIS.Picture with a path\filename.ext


To play/stop an .avi file

oStatusBar.mCntPanel3([avi\print.avi],[Play])

or

oStatusBar.mCntPanel3([avi\print.avi],[Stop])

The code in the method .mCntPanel3() would be :-

LPARAMETERS cFile, cAction

THIS.cntPanel3.oleAviPlayer.Open(cFile)
lcExpr = [THIS.cntPanel3.oleAviPlayer.] + cAction
&lcExpr

The code from the form follows to enable you to put your own version together.

PUBLIC ofooter

ofooter=NEWOBJECT("footer")
ofooter.Show
RETURN


*************************************************
*-- Form:         footer (c:\test\newfooter.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   02/11/03 09:06:00 AM
*
DEFINE CLASS footer AS form


    Top = 0
    Left = 0
    Height = 27
    Width = 812
    DoCreate = .T.
    ShowTips = .T.
    BorderStyle = 0
    Caption = ""
    ControlBox = .F.
    Closable = .F.
    FontName = "MS Sans Serif"
    TitleBar = 0
    WindowState = 0
    AlwaysOnBottom = .T.
    Name = "FOOTER"
    lfullsize = .F.


    ADD OBJECT cntpanel1 AS container WITH ;
        Top = 4, ;
        Left = 1, ;
        Width = 53, ;
        Height = 20, ;
        SpecialEffect = 1, ;
        Name = "cntPanel1"


    ADD OBJECT footer.cntpanel1.image1 AS image WITH ;
        Picture = "bitmaps\autoname.bmp", ;
        BackStyle = 0, ;
        Height = 16, ;
        Left = 2, ;
        Top = 2, ;
        Width = 16, ;
        Name = "Image1"


    ADD OBJECT footer.cntpanel1.label1 AS label WITH ;
        AutoSize = .T., ;
        FontName = "MS Sans Serif", ;
        Caption = "Label1", ;
        Height = 15, ;
        Left = 19, ;
        Top = 4, ;
        Width = 34, ;
        Name = "Label1"


    ADD OBJECT cntpanel2 AS container WITH ;
        Top = 4, ;
        Left = 277, ;
        Width = 224, ;
        Height = 20, ;
        SpecialEffect = 1, ;
        Name = "cntPanel2"


    ADD OBJECT footer.cntpanel2.txtprogressbar AS textbox WITH ;
        FontBold = .F., ;
        FontName = "MS Sans Serif", ;
        Alignment = 2, ;
        BorderStyle = 1, ;
        Enabled = .F., ;
        Height = 20, ;
        Left = 0, ;
        ReadOnly = .T., ;
        TabStop = .F., ;
        Top = 0, ;
        Visible = .F., ;
        Width = 432, ;
        DisabledBackColor = RGB(255,255,255), ;
        DisabledForeColor = RGB(0,0,0), ;
        Name = "txtProgressBar"


    ADD OBJECT cntpanel3 AS container WITH ;
        Top = 4, ;
        Left = 523, ;
        Width = 21, ;
        Height = 20, ;
        SpecialEffect = 1, ;
        Name = "cntPanel3"


    ADD OBJECT footer.cntpanel3.oleaviplayer AS olecontrol WITH ;
        Top = 2, ;
        Left = 2, ;
        Height = 16, ;
        Width = 16, ;
        Name = "oleAviPlayer"


    ADD OBJECT cntpanel4 AS container WITH ;
        Top = 4, ;
        Left = 547, ;
        Width = 51, ;
        Height = 20, ;
        SpecialEffect = 1, ;
        Name = "cntPanel4"


    ADD OBJECT footer.cntpanel4.label1 AS label WITH ;
        AutoSize = .T., ;
        FontName = "MS Sans Serif", ;
        Caption = "Label1", ;
        Height = 15, ;
        Left = 4, ;
        Top = 4, ;
        Width = 34, ;
        Name = "Label1"


    ADD OBJECT cntpanel5 AS container WITH ;
        Top = 4, ;
        Left = 600, ;
        Width = 55, ;
        Height = 20, ;
        SpecialEffect = 1, ;
        Name = "cntPanel5"


    ADD OBJECT footer.cntpanel5.label1 AS label WITH ;
        AutoSize = .T., ;
        FontName = "MS Sans Serif", ;
        Caption = "Label1", ;
        Height = 15, ;
        Left = 3, ;
        Top = 4, ;
        Width = 34, ;
        Name = "Label1"


    ADD OBJECT tmrtime AS timer WITH ;
        Top = 0, ;
        Left = 684, ;
        Height = 23, ;
        Width = 23, ;
        Interval = 1000, ;
        Name = "tmrTime"


    PROCEDURE mcntlabel1
        LPARAMETERS cFile, cLine1

        WITH THIS
            .cntPanel1.Image1.Picture = cFile
            .cntPanel1.Label1.Caption = cLine1
        ENDWITH
    ENDPROC


    PROCEDURE mcntlabel3
        LPARAMETERS cFile, cAction

        THIS.cntPanel3.oleAviPlayer.Open(cFile)
        lcExpr = [THIS.cntPanel3.oleAviPlayer.] + cAction
        &lcExpr
    ENDPROC


    PROCEDURE Resize
        WITH THIS
            .Height        = 27
            .Top        = _SCREEN.Height - 27
            .Width        = _SCREEN.Width

            WITH .cntPanel2
                .Left    = _SCREEN.Width - 338
                .Width     = 200
            ENDW

            WITH .cntPanel3
                .Left    = _SCREEN.Width - 136
            ENDWITH

            WITH .cntPanel4
                .Left = _SCREEN.Width - 113
            ENDWITH

            WITH .cntPanel5
                .Left = _SCREEN.Width - 60
            ENDWITH

            WITH .cntPanel1    && The one panel that resizes
                .Left    = 3
                .Width     = _SCREEN.Width - 343
            ENDW
        ENDW
    ENDPROC


    PROCEDURE Init
        THIS.Resize()
        THIS.mCntLabel1([],[This is a test, and an even bigger test])
        THIS.mCntLabel2()
        THIS.mCntLabel3([bitmaps\n3.avi],[Play])
    ENDPROC


    PROCEDURE Destroy
        RELE oFooter
    ENDPROC


    PROCEDURE mcntlabel2
    ENDPROC


    PROCEDURE mcntlabel4
    ENDPROC


    PROCEDURE mcntlabel5
    ENDPROC


    PROCEDURE label1.MouseEnter
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        THIS.ToolTipText = THIS.Caption
    ENDPROC


    PROCEDURE label1.MouseEnter
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        THIS.ToolTipText = [The time is ] + THIS.Caption
    ENDPROC


    PROCEDURE label1.MouseEnter
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        THIS.ToolTipText = [The date is ] + THIS.Caption
    ENDPROC


    PROCEDURE tmrtime.Timer
        THISFORM.cntPanel4.Label1.Caption = TIME()
    ENDPROC


ENDDEFINE
*
*-- EndDefine: footer
**************************************************

If anyone can work out a way of utilizing the messages from a VFP menu, please advise

Have fun

ChrisRChamberlain

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close