Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display images and messages from a VFP menu in a statusbar

Forms

Display images and messages from a VFP menu in a statusbar

by  ChrisRChamberlain  Posted    (Edited  )
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
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top