Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to acces ALL controls on a form
Message
De
26/07/1999 11:14:50
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, Royaume Uni
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00246080
Message ID:
00246086
Vues:
20
>I have a form ,which at rutime, I want to change the caption of each control, based on a parameter passed to the form.
>I am trying to do this in the INIT of the form with the following:
>for i = 1 to controlcount
> thisform.CONTROLS(lnFor).caption = somevalue
>ENDFOR
>
>Now this works fine for anything other than Contained controls. i.e. if I have a Pageframe, it does not give me access to each of the controls within the pageframe.
>
>Is there any way of accessing ALL controls on a form( .i.e. going to lowest level) ?
>
>Regards,
>Gerard

Hi,

You can use a method that call itself recursively to parse all controls

In your init, call the routine, passing your top-level container (the form) as a parameter
THISFORM.ProcessAll( THIS)

Here's some code I use in an app for something similar

*-- Form.ProcessAll method
LPARAMETERS toContainer
LOCAL lnLoop

IF PEMSTATUS( toContainer, "PageCount", 5)
*-- we are in a page frame, so just process each page.
FOR lnLoop = 1 TO toContainer.PageCount
THISFORM.ScatterContainer( toContainer.Pages( lnLoop))
ENDFOR
ELSE
*-- we are in some other type of container, so check each object
FOR lnLoop = 1 TO toContainer.ControlCount
DO CASE
CASE PEMSTATUS( toContainer.Controls( lnLoop), "Caption", 5)
******** Do whatever here
toContainer.Controls( lnLoop) = THISFORM.CaptionToUse
********
CASE PEMSTATUS( toContainer.Controls( lnLoop), "PageCount", 5)
*-- Object is a pageframe, so process it
THISFORM.ScatterContainer( toContainer.Controls( lnLoop))
CASE PEMSTATUS( toContainer.Controls( lnLoop), "ControlCount", 5)
*-- Object contains things, so process it
THISFORM.ScatterContainer( toContainer.Controls( lnLoop))
ENDCASE
ENDFOR
ENDIF

RETURN


This might not work for all controls (maybe not grids) but you can add the extra bits.
Regards
Mark

Microsoft VFP MCP
Menulib - OO Menus for VFP www.hidb.com/menulib
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform