Usually, buttons on main toolbar only call methods of active form. I've created a form class with custom methods like AddNewRecord(),EditRecord(), Save(), Revert(), Print(),..., and custom properties.
When a user click on the Add button on main toolbar, in its Click event code I have only _VFP.ActiveForm.AddNewRecord(), if Save button is clicked, in its click event code I have _VFP.ActiveForm.Save(). In Activate event of this form class I have code like this:
WITH oApp.MainToolbarRef
IF this.Mode = 'view'
.cmdAddNew.Enabled = .t.
.cmdEdit.Enabled = .t.
.cmdDelete.Enabled = .t.
.cmdSave.Enabled = .f.
.cmdRevert.Enabled = .f.
ELSE
.cmdAddNew.Enabled = .f.
.cmdEdit.Enabled = .f.
.cmdDelete.Enabled = .f.
.cmdSave.Enabled = .t.
.cmdRevert.Enabled = .t.
ENDIF
ENDWITH
The form property Mode is set in AddNewRecord, EditRecord methods to 'add' or 'edit' and set back to 'view' after user choose to save or revert changes.
The Tastrade application is built using something like this.
>And how do you update cut-copy-paste buttons?
>
>Thanks,
>Javier.
>
>>I have a reference to it stored in an application object property. Then, oApp.MainToolbarRef.Refresh is always possible when I need it.
>>
>>Dorin
>>
>>>I just wanted to know what is the recommended way to refresh a toolbar:
>>>- Timer
>>>- Inserting code in thisForm.init() and thisForm.destroy() methods.
>>>
>>>Thanks,
>>>Javier Borrajo.