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

Forms

Display images and messages from a VFP menu in a statusbar by ChrisRChamberlain
Posted: 19 Nov 06 (Edited 19 Nov 06)

If you want to enhance your own statusbar class, Internet Explorer style, by showing an image followed
by text in the bottom left of the statusbar, the following code will provide a starting point.

This enables you use a message from a VFP menu as well as a message from any other VFP control.

For instance, in a VFP menu message box put

"bitmaps\remove.bmp|Clear source files"

The message has two halves, the reference to the image file followed by the message using "|" as a delimeter.

The statusbar will need a method, .mMessage(), a 16x16 pixel image control,
.imgIcon, and a label, .lblMessage.

You will need to adapt your own code from what follows

In the .mMessage() method put:-

CODE

LPARAMETERS tcPicture, tcMessage

WITH THIS.cntStatusBar
    DO CASE
    CASE EMPTY(tcPicture) AND EMPTY(tcMessage)
        .imgIcon.Visible    = .F.
        .lblMessage.Left    = 0            
        .lblMessage.Caption    = []
    CASE EMPTY(tcPicture)
        .imgIcon.Visible    = .F.    
        .lblMessage.Left    = 0        
        .lblMessage.Caption    = tcMessage        
    OTHERWISE
        IF ADIR(laTemp,FULLPATH(tcPicture)) = 1    && Image exists
            .imgIcon.Visible    = .T.            
            .imgIcon.Picture    = FULLPATH(tcPicture)    && tcPicture
            .lblMessage.Left    = 20                
        ENDIF
        .lblMessage.Caption    = tcMessage        
    ENDCASE
ENDW
To use from a VFP control that has a picture, put the following code in the .MouseEnter() event:-

CODE

DODEFAULT()
oStatusbar.mMessage(THIS.Picture,THIS.StatusBarText)
Put the following code in the .MouseLeave() event:-

CODE

DODEFAULT()
oStatusbar.mMessage([],[])
Calvin Hsia's weblog titled "Why does BINDEVENT not work with StatusBar_Change?",
http://blogs.msdn.com/calvin_hsia/archive/2006/03/08/546722.aspx,
has been modified and provides the basis for the procedure that follows which needs to be called from your main.prg as you initialise the application:-

CODE

* *************************************
* Procedure: CaptureStatusBarText
*    Syntax: DO CaptureStatusBarText
* *************************************
PROCEDURE CaptureStatusBarText

*!*    Also required
SET MESSAGE TO
SET STATUS     BAR    OFF
SET STATUS     ON

#define    GWL_WNDPROC         (-4)
#define    WM_ENTERIDLE        0x0121
#define MSGF_DIALOGBOX      0
#define MSGF_MESSAGEBOX     1
#define MSGF_MENU           2
#define MSGF_SCROLLBAR      5

PUBLIC oHandler
oHandler = NEWOBJECT([StatusBarText])

BINDEVENT(_VFP,[STATUSBAR],oHandler,[STATUSBAR_CHANGE],1)
BINDEVENT(_vfp.HWnd,WM_ENTERIDLE,oHandler,[HandleMsg],5)

DEFINE CLASS StatusBarText AS Session
      dwOrigWindProc=0

    PROCEDURE init
        DECLARE integer GetWindowLong IN WIN32API     ;
            integer hWnd                            ,;
            integer nIndex
        DECLARE integer CallWindowProc IN WIN32API     ;
            integer lpPrevWndFunc                    ,;
            integer hWnd                            ,;
            integer Msg                                ,;
            integer wParam                            ,;
            integer lParam
       THIS.dwOrigWindProc = GetWindowLong(_VFP.HWnd,GWL_WNDPROC)   

    PROCEDURE HandleMsg(hWnd as Integer, msg as Integer, wParam as Integer, lParam as Integer)
        LOCAL nRetvalue
            nRetvalue=0

            DO CASE
            CASE msg = WM_ENTERIDLE
                IF wParam = MSGF_MENU
                    * Call default processing to set menu message
                    nRetvalue = CallWindowProc(THIS.dwOrigWindProc,hWnd,msg,wParam,lParam)                     
                    IF [|] $ _vfp.StatusBar
                        oStatusbar.mMessage(LEFT(_vfp.StatusBar,AT([|],_vfp.StatusBar) - 1),;
                            SUBSTR(_vfp.StatusBar,AT([|],_vfp.StatusBar) + 1))
                    ELSE                   
                        oStatusbar.mMessage([],_vfp.StatusBar)
                    ENDI
                ENDIF
            ENDCASE
            RETURN nRetvalue

    PROCEDURE StatusBar_Change
        RETURN
ENDDEFINE
There is a gotcha with "SET STATUS ON" - the bar showing table info will appear in _SCREEN.

Use a blank empty form that fully covers _SCREEN as a background mask and that will resolve the issue.

Chris
www.pdfcommander.com
www.pdfcommander.net

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