Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help on Help - Name Property
Message
From
23/07/1998 18:57:42
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00120091
Message ID:
00120778
Views:
41
Hi again David,
Thanks for that.
I run this routine to return the handle to a named form, also optionally picks out specific instances from multiple instances. You need to "know" something unique about the instance you require of course. Please forgive my use of m. in preference to Hungarian - that's another topic :-)
FUNCTION GetForm
LPARAMETER cFrmName, cCond
* === returns a handle to the form named cFrmName
* NOTE: Case and length sensitive
* optionally locates the instance satisfying m.cCond
* cCond can be things like '.myProperty="FRED"'
* returns .NULL. if not found
* Remember to eventually release variables being assigned the form name otherwise the form may not release
LOCAL oFrm, oRetFrm
oRetFrm= .NULL.
FOR EACH oFrm IN _SCREEN.Forms
	WITH m.oFrm
		* if we have a form of the correct name, is it the instance we need (cCond)?
		IF .Name == m.cFrmName ;
				AND (EMPTY(m.cCond) OR EVALUATE(m.cCond))
			oRetFrm= m.oFrm
			EXIT
			*VVVVV
		ENDIF
	ENDWITH
ENDFOR
RETURN m.oRetFrm
<\PRE>

>David,
>
>I use the .Name property in my udf used to disable menu items. The SKIP FOR is:
><b>FormRunning( "frmTheFormName" )</b>
>
><pre>* FormRunning.PRG 08-Mar-98
>
>* determine if a particular form is running.
>
>* It checks the Name property
>
>lparameter pcFormName
>
>local i, llRetVal
>
>llRetVal = .f.
>pcFormName = upper( pcFormName )
>
>for i = 1 to _screen.FormCount
>   if ( upper( _screen.Forms[i].Name ) == pcFormName )
>      llRetVal = .t.
>      exit
>   endif
>endfor
>
>return llRetVal
>So yes you can "use" the form .Name property to look for a form. But you can't manipulate the form via it's .Name. The only time .Name is used for anything of consequence is when there is object containership involved. If the form is part of a formset then things change a little. Then the form .Name distinguishes one form from another, just like .txtFirstName is different that .txtLastName inside the same container.
>
>>Anyway, "name" clearly means lots of different things here too.
>>Is the name of the scx the name of the form. No!
>>When we DO FORM myFormName
>>we're talking about the name of the scx. Once instantiated the name of the form can be quite different. (For some peculiar reason my forms are named the same as the SCX with an frm in front)
>>I don't really want to reference a form by name, although I often want to know if a form of a given name is running already (and there could be many). I would like to know if you *can* refer to a form by name.
Previous
Reply
Map
View

Click here to load this message in the networking platform