Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help on Help - Name Property
Message
De
23/07/1998 19:08:05
 
 
À
23/07/1998 04:34:50
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00120091
Message ID:
00120784
Vues:
38
>>Hi David -
>>I think Lewis Carol would have a field day with the way were working here.
>>(He refered once to the name of the song, the title of the song and what the song is called - three different things!)
>>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.
>>
>>>
>>>Inside form methods always use thisform or this. Outside a form you can use the _screen.Forms[] collection or _screen.ActiveForm or your own forms manager object (but hardcoding a reference to an app object or form manager object can come back to hinder you). If one form is talking to another pass references from one to the other do form xyz with thisform this let's xyz easily work with any caller form.
>>>
>>>Coding to a specific form object name restricts you too much especially when dealing with multi-instance forms.
>>>
>>>>That all makes sense. I was thinking of "forms" at the time. Does that mean we can't or shouldn't refer to a form by name?
>
>Hi David,
>At runtime if your form.name is manually coded to be unique then you could use it for forms collection provided you work with single instances. Rather thisform and do .. with this (thisform) is one good way. Also you could have a formcontrol class at app level to control all instances of all forms. By this way you could keep multipl instances of a form(set) and yet control them individualy. Here is a very simple formcontrol example :
>
oFormManager = createobject("FormControl")
>oFormManager.NewInstance("c:\temp\itest.scx")
>* Add three buttons to itest
>* One button calls oFormManager.NewInstance("c:\temp\itest.scx") n Times
>* and with some other scx another n times
>* the other just releases form
>* Third calls oFormManager.cascadeinstances("c:\temp\itest.scx")
>read events
>
>define class FormControl as Custom
>    Protected FormInstances[1,2]
>
>    procedure NewInstance
>    lParameters cSCXName
>    	with this
>		    dimension .FormInstances[alen(.FormInstances,1)+1,2]
>		   	.FormInstances[alen(.FormInstances,1),1] = cSCXName
>	   		.FormInstances[alen(.FormInstances,1),2] = "F"+sys(2015)
>	   		cVarname = .FormInstances[alen(.FormInstances,1),2]
>	   		public &cVarName
>		   	do form (cSCXName) name (cVarName) linked with cVarName
>		   	return alen(.FormInstances,1) && Return new id
>		endwith
>    endproc
>
>    procedure CascadeInstances
>    lParameters cSCXName
>        nLeft = 0
>        nTop = 0
>	    for ix=1 to alen(this.FormInstances,1)
>	    	if Type("this.FormInstances[ix,2]") = "C" ;
>	    		and Type(this.FormInstances[ix,2]) = "O" ;
>	    		and !isnull(eval(this.FormInstances[ix,2])) ;
>	    		and this.FormInstances[ix,1] = cSCXName
>			    with eval(this.FormInstances[ix,2])
>    			   	.left = nLeft
>	    		    .Top = nTop
>				endwith
>				nLeft = nLeft + 20
>				nTop = nTop + 20
>	    	endif
>	    endfor
>    endproc
>enddefine
Cetin

Hi again Cetin,
Thanks for that code. Very interesting. Love the cascading. I was looking at building a form manager class, but didn't get very far. Your code might help be rethink that. In the mean time, I posted some code to David Frankenbach that I currently use (still testing though!) to distinguish multiple instances.

BTW my apologies to all on spelling Lewis Carroll as "Carol". Seriously, he would have been a fantastic programmer, were he alive today. So now we have:
The name of the form
The name of the instance
The title (caption) of the form
The handle to the form
The name of the handle to the form
(Just trivia)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform