Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copying a control at runtime??
Message
De
03/06/1999 16:28:10
 
 
À
03/06/1999 15:45:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00226170
Message ID:
00226232
Vues:
29
>>I build a shape based on some data. I would like to have another copy of the shape. Is there a quick way to copy all the layout properties of an object or do I have to code each property indivually -- shp2.top = shp1.top, shp2.left = shp1.left, etc...? There are actually dozens of shapes I need to copy, so this could be a big time saver. Thanks for any feedback.
>>
>
>You can use AMEMBERS(object name,1) to create an array of properties, instantiate a new instance of the class, and then spin through the array copying the value from one to the other. Some properties are read-only at runtime, so you'd need to trap errors resulting from trying to write to a read-only property...
>
>>Marcus.

here is a routine to do just that that I had stowed away somewhere...

LPARA o1, o2

IF TYPE('o1.Name') <> "C" OR TYPE('o2.Name') <> "C"
RETURN .F.
ENDIF

AMEMBERS(aProps, o1)

FOR i = 1 TO ALEN(aProps)
IF !ALLTRIM(UPPER(aProps(i)))$"CLASS:PARENTCLASS:BASECLASS:NAME"
uVal = GETPEM(o1,aProps(i)) && Value of property in source
IF PEMSTATUS(o2,aProps(i),5) && Does property exist in the second object?
IF !PEMSTATUS(o2,aProps(i),1) && Is the property readonly?
IF !PEMSTATUS(o2,aProps(i),2) && Is the property protected?
o2.WriteExpression(aProps(i), uVal)
ENDIF
ENDIF
ENDIF
ENDIF
ENDFOR
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform