Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Controlling the toolbar
Message
From
23/01/2003 03:48:23
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
 
 
To
18/12/2002 15:00:42
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00734215
Message ID:
00744629
Views:
9
I do, in my applications as follow:

I designed a form class with AddNewRecord(), EditRecord(), SaveChanges(), Revert(), Search(), etc. methods and some properties. One property store the current state of the form and can have values 'add', 'edit', 'view'
My application object have a property named ToolbarRef, main toolbar reference
Each click on the toolbar buttons will call the appropriate method of currently active form. (cmdSave button click method just call _vfp.ActiveForm.Save() method and so on...)
In the activate event of the form I have the following code that enable/disable buttons from main toolbar, so, if the form property state is currently in 'edit', or 'add', it will enable save and revert buttons and disable other buttons.
IF this.CurrentState = 'view'
	MySetAll(oApp.ToolbarRef.MainToolbarContainer , 'Enabled' , ;
		'CmdNew,CmdEdit,CmdDelete,CmdSave,CmdRevert,CmdSearch,CmdPreview,CmdPrint,CmdPrintAll', ;
		'.t.   ,.t.    ,.t.      ,.f.    ,.f.      ,.t.      ,.f.       ,.t.     ,.f.        ')
ENDIF

IF this.CurrentState = 'add' OR this.CurrentState = 'edit'
	MySetAll(oApp.ToolbarRef.MainToolbarContainer , 'Enabled' , ;
		'CmdNew,CmdEdit,CmdDelete,CmdSave,CmdRevert,CmdSearch,CmdPreview,CmdPrint,CmdPrintAll', ;
		'.f.   ,.f.    ,.f.      ,.t.    ,.t.      ,.f.      ,.f.       ,.t.     ,.f.        ')
ENDIF
DODEFAULT()
Note : MySetAll is a UDF which take form or container reference, the property that will be changed , list of objects and a list of values and change the values.
function MySetAll
LPARAMETERS toContainerRef, tcProperty, tcObjectList, tcValueList
LOCAL ARRAY laObjectList[1], laValueList[1]
LOCAL lnCnt, lnObjCnt, lnValCnt, lcPropRef, lcPropValue
lnObjCnt = ALINES(laObjectList, tcObjectList, .f., ',')
lnValCnt = ALINES(laValueList, tcValueList, .t., ',')
IF lnObjCnt = 0
	RETURN
ENDIF
IF lnObjCnt <> lnValCnt
	RETURN
ENDIF

FOR lnCnt= 1 TO lnObjCnt
	lcPropRef='toContainerRef'+'.'+laObjectList[lnCnt]+'.'+tcProperty
	lcPropValue = laValueList[lnCnt]
	IF TYPE(lcPropRef) = 'L'
		&lcPropRef = &lcPropValue
	ENDIF
	IF TYPE(lcPropRef) = 'C'
		IF TYPE(lcPropValue) = 'U'
			&lcPropRef = lcPropValue
		ELSE 
			&lcPropRef = EVALUATE(lcPropValue)
		endif
	ENDIF
	IF TYPE(lcPropRef) = 'D'
		lcPropValue = '{'+lcPropValue+'}'
		&lcPropRef = &lcPropValue
	ENDIF
	IF TYPE(lcPropRef) = 'N'
		&lcPropRef = VAL(lcPropValue)
	ENDIF
NEXT
>Hi,
>
>I have two forms using the same toolbar. Let's say I ran the first form and click on the edit button and the Undo & Save button are enabled. But before I clicked on Save or Undo; I decided to run the second form. In the second form I click on the Add button and add new record and click on the save button and close the second form. This will bring me back to the first form. How would I control what buttons were clicked on the first form prior to running the second form? TIA
Previous
Reply
Map
View

Click here to load this message in the networking platform