Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Controls collection at design time
Message
De
21/01/2004 23:48:14
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
21/01/2004 19:43:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00869260
Message ID:
00869369
Vues:
13
>>I'm writing a builder which replaces controls. It finds objects of certain class, adds a different object of the new class, copies properties from the old one, RemoveObject()s the old one.
>>The trouble is how to do this in a loop. If I try going for i=1 to oParent.ControlCount, as soon as I remove the old one, the whole collection is reshuffled. I'll probably fix it by doing for i=oParent.controlcount to 1 step -1, so those I replaced will be removed from the current position and new ones added in the end, which would be just OK (except the instantiation order would now be reverse - but this should not be important, or there's something wrong with the design).
>>
>>The trouble I have is when I attempt to do For Each oMember of loObj.Controls - it gives me syntax error for a form with just two objects (a pageframe and a custom). The collection is visible in debugger while the builder runs, and also in the command window - any member of the collection can be accessed by number. It's just that For Each it gives a syntax error.
>>
>>VFP7 SP1. Can anyone check whether this works in VFP8?
>>
>>
* have a form with a few controls open for editing
>>aselobj(oForms,1)
>>oForm=oForms[1]
>>for each oControl of oForm.controls
>>   ? oControl.name
>>endfor
>>Save this in a prg and run it while editing a form, I need to know whether anything changed here in VFP8.
>
>Hi Dragan,
>
>I wrote a tool for this purpose which is available in the downloads as NewClass. Check it out.

Nice (downloaded and looked at the code) - and if I was pressed for time, I would have gone that route for sure. I was doing this type of replacement manually for years :).

But, since I have too much time on my hands now, I've gotten into stubborn-Serbian mode and it will be a builder or nothing. Actually got the "for ii=loObj.ControlCount to 1 step -1" version working as expected. It's just that not having a general .controls collection available (at both runtime and design time) for each class which has .addobject() methot is so inelegant. All the recursive stuff would look so much nicer without the long Case grid... Case Optiongroup... block. And would be easier to develop and maintain as well.

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
Répondre
Fil
Voir

Click here to load this message in the networking platform