Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to disable a Toolbar
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00826377
Message ID:
00826546
Views:
23
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
Previous
Reply
Map
View

Click here to load this message in the networking platform