Toolbar_All_Edit Class

The Toolbar_All_Edit class is the blueprint for the Standard VPM Enterprise Form Toolbar that includes an Edit button. It is a subclass of the Toolbar_All class.

Creating and Displaying the Form Toolbar

When a form based on the Form_Toolbar form class is run, and “TOOLBAR_ALL_EDIT” (without the quotes) has been entered in the form’s cToolbar property, here’s how the VPM Enterprise Standard Toolbar with Edit Button 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, in this case, Toolbar_All_Edit.

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

·                         This.oToolbar = CREATEOBJECT(stcToolbar)

·       The Show NavToolbar 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 with Edit Button is instantiated, controls are added 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 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_edit”

 

Custom Properties:

None

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

Runs the Toolbar_All Refresh method.

Disables the Edit button if in the edit mode or enables the Edit button if not in the edit mode.

Custom Methods:

 

DisableControls

Runs the Toolbar_All DisableControls method.

Disables the Edit button.

Toolbar Button Click Methods:

 

cmdEdit.Click

Sets the lEditModeOn property to .T. in the active form, signifying that the form is in edit mode.

Runs the EnableDisableControls method in the active form to enable controls on the form so that the fields can be edited.

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 SetFocusToFirst method in the active form to move the focus to the first editable control.

Runs the WriteBuffer method in the active form because some controls, like comboboxes, do not work after being enabled until the focus has been moved off and then back.

More:

Toolbar_App Class