Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AddObject/RemoveObject
Message
 
 
À
27/03/2002 15:12:10
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00635975
Message ID:
00638274
Vues:
15
Hilmar,

First off, I guess I'd say that I'd never really use any of those options that you present in the article.

This statement:

Explanation: 1) Apparently, with RemoveObject() you can only eliminate the first object in the creation order. 2) ZOrder(1) ("send to back") changes this "creation order". ThisForm.RemoveObject("aOptions(5)") doesn't remove anything.

Is most definately false. RemoveObject() can remove any contained object at any time, ZOrder() also has nothing to do with it. I think the only reason you are having a problem is caused by this "peculiar" method you are proposing of creating dynamic forms.

I've only had two cases where I wanted to create dynamic forms at runtime. One was a calendar based application that was used to display and input union employee absence/vacation/reprimand status. The form displayed 6 months worth of data. The second form displayed knitting machine status in realtime. It had to display 150 machines like they are layed out on the plant floor.

In both these cases the forms had methods that did all of the initial layout of the objects. It all basically used code like:
for i = 1 to lnRows
   for j = 1 to lnCols
      lcName = "cnt" + padl( i, 2, '0' ) + padl( j, 2, '0' )
      this.AddObject( lcName, "cntGroup" )
      loObject = eval( "this." + lcName )
      with loObject
         .Top = ( i - 1 ) * .Height + 5
         .Left = ( j - 1 ) * .Width + 5
         ...
         .Visible = .t.
      endwith
   endfor
endfor
To iterate these controls I simply use the Objects[] collection:
for each loObject in this.Objects
   if ( loObject.Class = "cntGroup" )
      ...
   endif
endfor
If for performance reasons I needed to have much faster access to the controls I would have an array property of the form that I would fill in as the controls were instantiated and then use this array to iterate them. At form destruct time all I have to do is this.aControlRefs = .null.


>I should have added that I have your opinion in very high regard. Therefore, I invite you - should you have the time to do so - to look at the sample program provided in FAQ #8110, especially the part labelled "Option 1". Do you find a serious flaw in it? Apart from the fact, already mentioned, that it relies on undocumented features.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform