Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opposite of
Message
From
05/09/2006 10:38:29
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
04/09/2006 22:17:57
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
01150809
Message ID:
01150950
Views:
30
>Opposite of "save as class":
>
>If I have an object on a form, I can convert it to a class with the command "Save as Class".
>
>Is there a way to do this the other way, convert a class to an object on the form? I know I can place an instance of a class, but in this case I want to use the object in one single form, and eliminate the class.
>
>The class is inherited from some custom class. Right now, I am creating an instance of the custom class on the form, and manually copying the PEMs. I was thinking there should be a faster way, but there doesn't seem to be.

You may need to write a little builder. Place an instance of the parent class of your object on the form, and get a variable refering to it via aSelObj(). Open your custom class for editing and get another variable refering to it. Now get all the nondefault PEMs for it (via aMembers(), I think "UC" would be the proper third parameter), and then loop through the array it got you, copying PEMs from the second object into the first:

objOnForm.AddProperty("pemname", getpem(obj2, "pemname"))

For methods, instead of .AddProperty use .WriteMethod, but beware: as Nad.. Naomi said, it won't work for new methods that the parent class didn't have. They will be written into your object, but they'll be lost when you save your form. You may want to add them as abstract methods to the parent class before you start this.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform