Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
USER INTERFACES >>  DISPLAY IMAGES AND MESSAGES FROM A VFP MENU IN A STATUSBAR

  Chris Chamberlain
  Where is Chris Chamberlain?
 GL6 0PN
 United Kingdom
 Chris Chamberlain



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 an image and message from a VFP menu as well as an image and 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:-

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:-

DODEFAULT()
oStatusbar.mMessage(THIS.Picture,THIS.StatusBarText)


Put the following code in the .MouseLeave() event:-

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:-

* *************************************
* 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

FEEDBACK

jerome @ 3/1/2010 10:58:37 AM
sir can i download your whole code with matching forms?



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: