Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a copy of the existing class
Message
De
09/03/2005 23:47:24
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Divers
Thread ID:
00994181
Message ID:
00994309
Vues:
29
This message has been marked as a message which has helped to the initial question of the thread.
>>How about using the class browser and opening the class. Select the view class code and select the code for a copy paste.
>
>But I need to re-create the properties (with their comments) and methods (with their comments) I added to the class. I don't see how Class Browser is going to help me. I would see all methods and properties, but I still have to add them somehow.

Ok, here's what I did for this before I started writing builders. Actually, this is a way of lightweight builder.

Edit both classes at the same time. Use aselobj() to get references to each, say oOld and oNew. Then have two routines:
procedure CopyProperty(o1, o2, cProperty)
o2.addproperty(cProperty, eval("o1."+cproperty))

procedure copyMethod(o1, o2, cMethod)
o2.writemethod(cMethod, o1.readmethod(cmethod), .t.)
Now just

copyproperty(oOld, oNew, "backcolor")
copyproperty(oOld, oNew, "forecolor")
copyproperty(oOld, oNew, "disabledbackcolor")
...etc etc, any properties you may want to copy. Similarly for code:

copymethod(oOld, oNew, "YourCustomMethod")
copymethod(oOld, oNew, "click")

You may also want a copy member method - if you have December FoxTalk2.0, you can take it from my article there, it's part of the sample code - you only need to write about four lines of code, to extract classlib and class from the member to copy, and then oNew.newobject() it.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform