Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing controls from a form
Message
De
09/03/2021 00:32:51
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01678811
Message ID:
01678814
Vues:
71
>Hi,
>
>I am wondering how others deal with the following situation. Here is how I do:
>
>I have a form where some customers need to see a row of controls (three labels and three textboxs). Other customer do not need to see or use them.
>I place these controls on the form and set the Visible of all to .T.
>At run time, when the form is initialized - based on some setting that calls for these controls not be be used - the code sets the property Visible of all controls to .F. Then, there is a LOOP through all controls and the TOP value is decreased by 26 (the space for these controls).
>This works. But I wonder how others would do it.
>
>TIA

Solution A
I put all the stuff into one container (transparent/ borderwidth 0 to make it invisible) and simply turn the containers visibility on / off

Solution B
I create a container class (the same thing) and add to the form on need.

The forms size must be changed, but rather then working in constants, I go relative to the lowest elements
For example, with container,
thisform.height = thisform.container.top+thisform.container.height+gap
For example, without container,

thisform.height = thisform.someobj.top+thisform.someobj.height+gap
and, for Solution B
<pre>
thisform.addobject(..
thisform.container.top = thisform.someobj.top+thisform.someobj.height+gap
thisform.height = thisform.container.top+thisform.container.height+gap
thisform.container.visible = .t.
gap might be in the form thisform.topmost_obj.top so the frame around the objs is even

I prefer to have such stuff on lower boundary - makes life more easy.

The other approach I use for some stuff where a lot if things turn on off looks like
lnTop = const
lnGap = const
if  .obj1.visible then
 .obj1.top = m.lnTop
 lnTop = m.lnTop + .obj1.height + m.lnGap
endif
if  .obj2.visible then
 .obj2.top = m.lnTop
 lnTop = m.lnTop + .obj2.height + m.lnGap
endif
You see one can iterate through this from an array, or, if in the right ZORDER, FOR EACH through it.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform