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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Status Bar to appear 2

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I'm coming back to VFP apps after a long lay-off and I'm not young any more so my memory of how things work is scratchy.

I have not been able to get this working. I want to use the bar as a debugging aid as I develop my new app.

I have in the load event of my single form application.

Code:
SET STATUS BAR ON
SET STATUS ON
SET TALK ON

The form is identified as a 'Top level form' in its properties.

Is there anything else I need to do?

Thanks

GenDev
 
_Screen has a status bar.
_screen is a top level form.
By creating a top level form it doesn't have a status bar, though.

Notifications and SET MESSAGE will only be seen in _SCREEN

You may use a status bar ActiveX control, but that won't get the system messages.

Bye, Olaf.


 
Put it another way: If you have a single-form application with a top-level form, you can't have a status bar as well. You will have to either keep _SCREEN visible, or do without the status bar.

If your only reason to have a status bar is for a place to display short messages, consider using a Wait window instead. Or perhaps create your own pseudo status bar at the foot of the form, this being essentially a label whose caption you change to the text of the message you want to show.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
My app is a single form with a pageframe on it. Thus my app operates like a standalone utility program. If I want a status bar how will I add the codes to have it and where?

Hoping you can help.

GenDev
 
Well, you can't have anything that'll get SET MESSAGE or other TALK notifications redirected to it.
But you may add a label at the bottom of your form and set its caption, as Mike already said.

Bye, Olaf.
 
Would it be possible to intercept the status bar text?

Code:
* // frmMainWnd.Init
FUNCTION Init( ) AS Boolean
[indent]...[/indent]
[indent]DECLARE INTEGER	GetWindowLong IN USER32 INTEGER, INTEGER[/indent]
[indent]This.AddProperty( "WndProc", GetWindowLong( This.hWnd, -4 ))    && GWL_WNDPROC[/indent]

[indent]BINDEVENT( _VFP, "StatusBar", This, "OnStatusBar", 1 )[/indent]
[indent]BINDEVENT( This.hWnd, WM_ENTERIDLE, This, "OnWM_ENTERIDLE")[/indent]

[indent]...[/indent]
ENDFUNC

and

Code:
* // frmMainWnd.OnStatusBar
PROCEDURE OnStatusBar( )
[indent]This.pgfStatusBar.pagStatusBar.lblStatusBar.Caption	= _VFP.StatusBar[/indent]
ENDPROC

* // frmMainWnd.OnWM_ENTERIDLE
FUNCTION OnWM_ENTERIDLE( thWnd AS Integer, tnMsg AS Integer, tnWParam AS Integer, tnLParam AS Integer ) AS Integer
[indent]IF tnWParam == MSGF_MENU[/indent]
[indent][indent]This.pgfStatusBar.pagStatusBar.lblStatusBar.Caption	= _VFP.StatusBar[/indent][/indent]
[indent]ENDIF[/indent]
[indent]RETURN CallWindowProc( This.WndProc, thWnd, tnMsg, tnWParam, tnLParam )[/indent]
ENDFUNC
 
You know more than me about _VFP.StatusBar.

>Would it be possible to intercept the status bar text?
I haven't tested, but it could work. As you coded this, have you?

One thing is consistent: SET MESSAGE TO "Hello Status Bar" will arrive in _VFP.StatusBar

Bye, Olaf.
 
There is a SET TALK WINDOW cName command, but with two bizare and fun behavior.
First, the result of COUNT and SUM is 0 records, although without SET TALK WINDOW cName, the result is correct
Code:
**************************
* Show TALK in a window  *
* with incorrect results *
**************************
PUBLIC ofrm,ofrmmess
ofrmmess = CREATEOBJECT("MyMessages")
ofrm = CREATEOBJECT("MyForm")
ofrmmess.show()
ofrm.show()

DEFINE CLASS MyMessages as Form
	desktop = .T.
	alwaysontop = .T.
	titlebar = 0
	left = 600
ENDDEFINE

DEFINE CLASS MyForm as Form
	ADD OBJECT cmdc as commandbutton WITH caption = "count",autosize = .T.,top = 50
	ADD OBJECT cmds as commandbutton WITH caption = "sum",autosize = .T.,top = 100
	
	PROCEDURE load
		LOCAL lni
		SET STATUS OFF
		SET STATUS BAR OFF
		SET TALK WINDOW (ofrmmess.name) && set the window
		SET TALK ON
		
		CREATE CURSOR cc (ii I AUTOINC,cc C(10) DEFAULT SYS(2015))
		FOR lni =1 TO 5
			APPEND BLANK
		NEXT
		GO TOP
	ENDPROC
	PROCEDURE cmdc.click
		COUNT
	ENDPROC
	PROCEDURE cmds.click
		SUM
	ENDPROC
	PROCEDURE destroy
		ofrmmess.release
	ENDPROC
ENDDEFINE

Second, if SET TALK WINDOW cName si followed by SET TALK WINDOW, the correct results are showed in a WAIT WINDOW NOWAIT.
Code:
******************************
* Show TALK in a WAIT window *
* with correct results       *
******************************
PUBLIC ofrm,ofrmmess
ofrmmess = CREATEOBJECT("MyMessages")
ofrm = CREATEOBJECT("MyForm")
ofrm.show()

DEFINE CLASS MyMessages as Form
	desktop = .T.
	alwaysontop = .T.
	titlebar = 0
	left = 600
ENDDEFINE

DEFINE CLASS MyForm as Form
	ADD OBJECT cmdc as commandbutton WITH caption = "count",autosize = .T.,top = 50
	ADD OBJECT cmds as commandbutton WITH caption = "sum",autosize = .T.,top = 100
	
	PROCEDURE load
		LOCAL lni
		SET STATUS OFF
		SET STATUS BAR OFF
		SET TALK WINDOW (ofrmmess.name) && set
		SET TALK WINDOW  && and reset the window
		SET TALK ON
		
		CREATE CURSOR cc (ii I AUTOINC,cc C(10) DEFAULT SYS(2015))
		FOR lni =1 TO 5
			APPEND BLANK
		NEXT
		GO TOP
	ENDPROC
	PROCEDURE cmdc.click
		COUNT
	ENDPROC
	PROCEDURE cmds.click
		SUM
	ENDPROC
	PROCEDURE destroy
		ofrmmess.release
	ENDPROC
ENDDEFINE

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
I'd perhaps do it simpler in this case:

Add a Textbox to display status bar test and in the Data tab of property window set Controlsource=_VFP.StatusBar. Let it be readonly and in the layout tab change BorderStyle=0 and BackStyle=0 so it appears as a transparent label.

Then you may bind to _vfp.statusbar changes just to refresh the textbox, nothing more.

Bye, Olaf.
 
With SET ODOMETER TO 1 the record number is correct.
Code:
PUBLIC ofrm,ofrmmess
ofrmmess = CREATEOBJECT("MyMessages")
ofrm = CREATEOBJECT("MyForm")
ofrmmess.show()
ofrm.show()

DEFINE CLASS MyMessages as Form
	desktop = .T.
	alwaysontop = .T.
	titlebar = 0
	left = 600
ENDDEFINE

DEFINE CLASS MyForm as Form
	ADD OBJECT cmdc as commandbutton WITH caption = "count",autosize = .T.,top = 50
	ADD OBJECT cmds as commandbutton WITH caption = "sum",autosize = .T.,top = 100
	
	PROCEDURE load
		LOCAL lni
		SET STATUS OFF
		SET STATUS BAR OFF
		SET TALK WINDOW (ofrmmess.name)
		SET ODOMETER TO 1
		SET TALK ON
		
		CREATE CURSOR cc (ii I AUTOINC,cc C(10) DEFAULT SYS(2015))
		FOR lni =1 TO 5
			APPEND BLANK
		NEXT
		GO TOP
	ENDPROC
	PROCEDURE cmdc.click
		COUNT
	ENDPROC
	PROCEDURE cmds.click
		SUM
	ENDPROC
	PROCEDURE destroy
		ofrmmess.release
	ENDPROC
ENDDEFINE

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Let's go back to the beginning for a moment. GenDev said he wanted to use the status bar "as a debugging aid". If that means that he wants to display messages to tell him which code is executing, or perhaps to display the current values of variables, then how about using DEBUGOUT?

You can use this to display just about anything you like, including the current record number, current alias, even the time of day. The advantage is that the output goes to the debugger, so it doesn't interfere with your user interface in any way. And you don't need to remove it when you are ready to distribute the EXE, because it has no effect if the debugger isn't present (but it would be good practice to remove it anyway).

Just a thought.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Good idea, indeed.

And if you're especially interested in the system statusbar output like record count, current alias etc. SET TALK ON puts there, you will debug your application inside the IDE. The screen is available there and you'll see status bar messages appear there.

Otherwise you have all the power about what your application does including logging output. DEBUGOUT is a very good and easy idea at design time/debugging.
All you do to debug without compiling is click on the main PRG in your project and RUN. Your app will start its top level form, but the _sceen also is still there.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top