Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy methods and properties from one form to another
Message
 
 
À
16/03/2002 01:18:17
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00633623
Message ID:
00633814
Vues:
21
>>Hi everybody,
>>
>>I have a form which is based on class which includes pageframe. This form has bunch of own properties and methods.
>>
>>I want to create another form based on another class (which doesn't have pageframe as a member), but this form should have all properties and methods as the first form. (E.g I want to re-design this form using another classlibrary).
>>
>>I put pageframe on the form, set pages to be 4, as on the first form, but now I'm thinking, how can I automate the process of copying properties and methods.
>>
>>Do you have ideas?
>
>Open them both in editor. Select the first one. In command window,
>
>aselobj(aa)
>o1=aa(1)
>Do the same with the other object, to get o2 as a reference to the second object. Then run this:
>
>do cprop with "{property name here}"
>do cmeth with "{method name here}"
>
>Here's the two progs:
>
* cprop.prg
>lparameters cProp
>
>cNewVal=evaluate("o1."+cProp)
>if type("cNewVal")#"U" or isnull(cNewVal)
>	if PEMSTATUS(o2,cProp,5)
>		store cNewVal to ("o2."+cProp)
>	else
>		o2.addproperty(cProp, cNewVal)
>	endif
>else
>	=alert(cProp+" is not such a good property of "+o1.name)
>endif
>
>*cmeth.prg
>LPARAMETERS cMethod
>o2.writemethod(cMethod, o1.ReadMethod(cMethod),.t.)
>
>So yes, you still have to type the names of each property and method - I took to programmers of 1st kind here, and didn't write proper scanner which would go down amembers() of o1 and call these two routines for each property and method which had non-default values. Eto domashnyaya rabota dlya tebya :) Recursion would be optional.

Thanks, Dragan. I thought about something like this, but since I'm lazy person, I just opened the first form as a table, copied properties, methods, reserved3 for the form from the first form to the second and viola - the second form has everything, which the first had... I still can not run it, though, I guess, I would need to copy DataEnvironment from first to second...
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform