Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to disable a Toolbar
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00826377
Message ID:
00826546
Vues:
24
I use this approach:

First, create a Toolbar Manager class which contains an array to hold
the toolbars (or collection on VFP8).

This class would open/close toolbars and provide access to each open toolbar.
It would also have a SetObjectStates method:
** METHOD: Toolbars.SetObjectStates
LPARAMETERS lEnabled

** Loop once for each array element
FOR nToolbar = 1 TO ALEN(This.aToolbars)

  ** Attempt to extract a toolbar reference from the array
  oToolbar = This.aToolbars[nToolbar]

  ** If the element contains a toolbar...
  IF TYPE("oToolbar") = "O" AND NOT ISNULL(oToolbar)
  
    ** Call the method on the toolbar to enable/disable buttons
    oToolbar.SetObjectStates(lEnabled)
 
  ENDIF

ENDFOR
Next, in the toolbar's SetObjectStates method:
** METHOD: ToolbarBase.SetObjectStates
LPARAMETERS lEnabled

** Loop once for each control on the toolbar
FOR nControl = 1 TO This.ControlCount

  ** Create a reference to the control
  oControl = This.Controls[nControl]

  ** If the control contains a SkipFor method...
  IF PEMSTATUS(oControl, "SkipFor", 5)
  
    ** Run the SkipFor condition
    lEnabled = oObject.SkipFor()

    ** Set the control's enabled state accordingly
    oObject.Enabled = lEnabled

  ENDIF

ENDFOR
Then, in the subclass for the tooblar button, add a SkipFor method. After placing
the control on the toolbar, add skipfor conditions as needed. The method needs to
return True for Enabled and False for disabled.

In the activate of modal screens:
oToolbars.SetObjectStates(.F.)
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform