Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help! Can not establish reference to field on SDI Form
Message
From
25/10/2001 03:50:17
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Help! Can not establish reference to field on SDI Form
Miscellaneous
Thread ID:
00573053
Message ID:
00573053
Views:
51
The hacked about function below does not work as expected when it is called by an external program.

I like to use a simple function that outputs a message to my users in a convenient way.

eg QMESS('This Order is ready for dispatch')

The function will check if there is a field on the active form called Qmess and if there is it will output to that field. If there is no field by that name it displays the message using WAIT WINDOW instead.

It is very handy for displaying status messages to users as a process operates.

Foe some reason, if I call a program from my Top Level form which in turn uses this function to display something on the form, output does not go to the Qmess field on the form.

This does not seem to be a problem if the VFP desktop is visible.
I would have expected _screen.activeform to work with a top level form but it did not do the trick so I commented it out and replaced it with code based on _vfp.forms.item as you can see below.
The code below seemed to work when calling Qmess('My Message') from the command window but stopped working with no VFP desktop visible.

The function works great as a method of the form but I want to keep it in my proc lib and call it from programs external to the form so that is not an option form me.


All help gratefully received.
	*****************************************************************************
	*
	*       Function: QMESS
	*

	*     Parameters: lcMessage,lcFormOb
	*        Returns: True
	*      Variables:
	*               : lcMessage       The message string to be sent
	******************************************************************************
	*[99
	* OVERVIEW of QMESS
	* uses wait window to print a quick message on the screen
	* converts any tilde ~ characters it finds to chr(13)
	* to help with formatting the output
	* If there is a field on the active form called qmess it will
	* output to that field instead
	* If it is a TOP Level form with no desktop visible you will have to provide an object reference and I dont know why
	*]99

	Func qmess
	Lparam lcMessage,lcFormOb
	Local lcCommand,lcMessage,liforms,llsucess
	lcMessage=Strtran(lcMessage,'~ ','~')
	lcMessage=Strtran(lcMessage,'~',Chr(13))
	*!*		If type('_screen.activeform.qmess')='O'
	*!*			_Screen.activeform.qmess.value=lcMessage
	*!*			_Screen.activeform.qmess.refresh
	*!*		ELSE

	If pcount()=2
		lcCommand=lcFormOb+'.qmess.value='+lcMessage
		&lcCommand

	Else
		liforms=_vfp.Forms.Count

		For li = liforms To 1 Step -1
			If Type('_vfp.forms.item(li).qmess')='O'
				_vfp.Forms.Item(li).qmess.Value=lcMessage
				_vfp.Forms.Item(li).qmess.Refresh
				llsuccess=.T.
				Exit
			Endif
		Next
		If !llsuccess
			Wait Window lcMessage Nowait
		Endif
	Endif
	DoEvents && put this in to ensure a message displays even when an Activex Control is on the form
	Return .T.
Next
Reply
Map
View

Click here to load this message in the networking platform