Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RemoveObject in Init
Message
 
 
À
28/02/2001 08:16:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00480229
Message ID:
00480518
Vues:
8
>Glenn:
>
>>>>>>
>I cannot explain why in the VFP model why during instanciation you cannot remove an object but I can offer a work around.
>
>According to Drew Speedie, to properly instanciate forms in VFP follow LISAG (Load,Instanciate,Show,Activate,Gotfocus). If in the Activate event you test for the presence of this object and if it exists removeit eg.
>
>Form::Activate
>if type('this.badobject') = 'O'
>this.removeobject('BadObject')
>endif
>
>you will successfully accomplish your objective.
>>>>>>
>
>Thank you. I will experiment with the idea.
>
>Daniel

Daniel,

This is not exactly true. My colleague started an application (which then was forwarded to me and now it's mine), which contains this piece of code in Form's Init method:
* remove all but one of the alternate grid layouts
do case
  case this.dedupetype = DDJC_TRNX               && Weekly Transaction Processing
       this.removeobject('grdBldmstr2')          && remove grid for parcel processing mode
       this.caption = this.caption + " - " + DDJD_TRNX

  case this.dedupetype = DDJC_PRCL               && Parcel Processing
       this.removeobject('grdBldmstr')               && remove grid for weekly transaction processing mode
       this.grdBldmstr2.name = 'grdBldmstr'     && rename parcel processing to primary grid name
       this.caption = this.caption + " - " + DDJD_PRCL

  case this.dedupetype = DDJC_TRNM               && TranMstr Maintenance
       this.caption = this.caption + " - " + DDJD_TRNM
       wait window 'DEDUMAIN.Init: "' + DDJC_TRNM + '" mode of de-duping is not yet supported.'
       return .f.                                        && fail

  otherwise
       wait window 'DEDUMAIN.Init: unknown de-duping job type.  Must be "' ;
         + DDJC_TRNX + '" or "' + DDJC_PRCL + '".'
       return .f.                                        && fail
endcase
In other words, you can remove objects in Form's Init (not in Object Init). All object initializations are done before form's Init fires.

Actually, when this application becomes my application, I did another trick: I saved both grids as independant classes and instead of removing one object, I add object in Run-time. This works like a charm and I also save time of instantiating this object. Perhaps, this solution could be used in your case too.

Best wishes,
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform