Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I save/restore control settings in a toolbar

Classes and Objects

How can I save/restore control settings in a toolbar

by  ChrisRChamberlain  Posted    (Edited  )
Should you need to temporarily disable controls in a custom toolbar class, [color blue].SetAll([Enabled],.F.)[/color] provides a simple solution.

If you wish to retain the original settings and only re-enable controls that were previously enabled, try the following.

Add a two dimensional array to the class named [color blue]aControls[1,2][/color]

Add two methods named [color blue].mSaveForm()[/color] and [color blue].mRestForm()[/color].

In [color blue].mSaveForm()[/color] put :-
[color blue]
WITH THISFORM
[tab]DIMENSION .aControls[.ControlCount,2]
[tab]FOR i = 1 TO .ControlCount
[tab][tab].aControls[i,1] = .Controls(i).Name
[tab][tab].aControls[i,2] = IIF(.Controls(i).Enabled,.T.,.F.)
[tab]ENDF
[tab].SetAll([Enabled],.F.)
ENDW
[/color]
In [color blue].mRestForm()[/color] put :-
[color blue]
WITH THISFORM
[tab]FOR i = 1 TO .ControlCount
[tab][tab]IF .aControls[i,2] = .T.
[tab][tab][tab]lcExpr = [THISFORM] + .aControls[i,1] + [.Enabled = .T.]
[tab][tab][tab]&lcExpr
[tab][tab]ENDI
[tab]ENDF
ENDW
[/color]
To use, put :-
[color blue]
tbrMain.mSaveForm()
[color green]
* Code
* Code
[color blue]
tbrMain.mRestForm()
[color black]
Have fun!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top