Toolbar_All Class

The Toolbar_All class is the blueprint for the standard VPM Enterprise Form Toolbar. The “_All” suffix signifies that this class contains all of the VPM Enterprise toolbar buttons. In later versions, we may include toolbar classes that only contain subsets of the VPM Enterprise toolbar buttons. Those future toolbar classes will have names with identifying suffixes.

Creating and Displaying the Form Toolbar

When a form based on the Form_Toolbar form class is run, here’s how the VPM Enterprise Standard Toolbar is created and displayed:

·       The form’s Init and Activate events call the ShowNavToolbar method of the form. The setting of the form’s lShowNavToolbarInit property determines at what point the toolbar is instantiated. If .T., the toolbar is instantiated when the form’s ShowNavToolbar method is called from the Init event. If .F. (the default), the toolbar is instantiated when the form’s ShowNavToolbar method is called from the Activate event. To instantiate the toolbar the ShowNavToolbar method of the application’s Application class (ProApp) is called.

·       The form properties cToolbar, cToolbar_ClassLibrary, and Name are passed to the ShowNavToolbar method. The cToolbar and cToolbar_ClassLibrary properties identify the toolbar class that will be used to create the form’s toolbar. The name of the toolbar class is, of course, normally Toolbar_All.

Tip: If you want to use a different toolbar with a form based on the Form_Toolbar class, store the name of the class and class library from which the toolbar should be created in the form’s cToolbar and cToolbar_ClassLibrary properties.

·       The ShowNavToolbar method in the ProApp class first instantiates the toolbar object from the Toolbar_All class. The code looks like this:

·                         This.oToolbar = CREATEOBJECT(stcToolbar)

·       The ShowNavToolbar method then displays the toolbar object with this line of code, which calls the Show method of the toolbar object:

·                         This.oToolbar.Show()

When the form closes, the form’s Destroy method calls the ReleaseNavToolbar method of the ProApp Application class to release the toolbar.

How the Toolbar Controls are Fired

When the Standard Form Toolbar is instantiated, controls are added to the toolbar as CommandButtons. When a toolbar button is clicked, the Click method of the button calls a method in the active form that contains the functionality of the toolbar button. For example, when you click on the Next button, the Next method in the active form is run. The Next method contains code that moves the record pointer to the next record.

Tip: The code that defines the functionality of a toolbar button is contained in a method in the Form_Toolbar class. Generally, the method has the same name as the toolbar button. Because the code that defines the functionality of a toolbar button is contained in a form method, you can modify the functionality of a toolbar button at the form level for each form in your application.

Properties

The following table lists the class properties. The properties listed include the standard Visual FoxPro class properties that the VPM Enterprise class uses and the VPM Enterprise custom properties. Where appropriate, the Comments column of the table describes a property and provides suggestions for its use.

Property & Initial Value

Comments

Standard Properties Used:

 

Caption = “Standard Toolbar”

 

ControlBox = .F.

 

Name = “toolbar_all”

 

Custom Properties:

 

lFormToolbar = .T.

Identifies whether or not the toolbar works in conjunction with a form.

lUpdateAllow = .F.

Property is used to make sure the “lAllow” properties are set according to the results of the Control Security check only once.

Methods

The following table lists the class methods. The methods listed include the standard Visual FoxPro class methods that the VPM Enterprise class uses and the VPM Enterprise custom methods. Where appropriate, the Comments column of the table describes a method and provides suggestions for its use.

Method

Comments

Standard Methods Used:

 

Refresh

Makes sure the active cursor of the active form is selected.

Checks Control Security for each control on the toolbar and sets the “lAllow” properties of the active form.

Determines if currently in Parent Mode. The active form’s RFParentValue property will not be empty if there is a Related Forms situation in which the active form’s cursor is the child of another form’s cursor.

Determines if at end-of-file or beginning-of-file.

Determines if the current record is the first or last record.

Updates the toolbar button properties, enabling and disabling the buttons.

Custom Methods:

 

DisableControls

When in the “add mode” or a form containing a modified record is reactivated, disables all buttons except the Save, Restore and More.

GridListDisable

If the current control on the active form is a Grid List, disables the navigation buttons.

Toolbar Button Click Methods:

 

cmdParent.Click

Toggles the active form’s lRFParentMode property, signifying the Parent Mode on/off status.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdFind.Click

Runs the Find method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdLocate.Click

Runs the Locate method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdList.Click

Runs the List method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdFilter.Click

Runs the Filter method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdOrder.Click

Runs the Order method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdPrint.Click

Runs the Print_Toolbar method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdFirst.Click

Runs the First method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdPrior.Click

Runs the Prior method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdNext.Click

Runs the Next method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdLast.Click

Runs the Last method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdNew.Click

Runs the AddNew method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s DisableControls method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdCopy.Click

Runs the Copy method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s DisableControls method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdDelete.Click

Runs the Delete method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdGroupDelete.Click

Runs the GroupDelete method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

cmdMore.Click

Runs the Save and AddNew methods in the active form.

If the new record is added:

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s DisableControls method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

If the new record is not added:

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the active form’s RefreshForm method to redisplay the previous record, the one that was saved.

cmdSave.Click

Runs the Save method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the active form’s RefreshForm method to redisplay the saved record.

cmdRestore.Click

Runs the Restore method in the active form.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the toolbar’s Refresh method.

Runs the EnableDisableToolbarControls method in the active form so toolbar controls can be conditionally enabled and disabled.

Runs the active form’s RefreshForm method to redisplay the restored or previous record.

cmdClose.Click

Runs the QueryUnload and Release methods in the active form.

More:

Toolbar_All_Edit Class