Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Current control
Message
From
02/10/1998 07:50:44
 
 
To
01/10/1998 12:42:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00142885
Message ID:
00143159
Views:
25
Bill:
I had a situation where we use a custom toolbar that allows the user to press 1 of several buttons. Depending on the data pattern, some of the buttons are inappropriate (like delete when no records are present). I pass keywords to method of the toolbar called buttons. ( this code follows as well)

procedure CheckforEmpty
Select "someworkarea"
if eof()
with ThisForm.Entrytoolbar1
.buttons("Off",.btnEdit)
.buttons("Off",.btnDelete)
.buttons("Off",.btnPrint)
.refresh()
endwith
endif



* BEGIN EntryToolBar.Buttons()
* Description: Generic method to enable or disable all or specific
* buttons.
* Parameters: - tcOnOff - Looks for Exactly Equal "OFF". Parameter is uppercased before use.
* - tcWhichButton - Calling program can pass in a keyword (new, edit, delete, print or close)
* to set individual button or not pass any parameter to affect all buttons.
* Returns: -
* Notes: 1.
* 2.
* Revisions: 07/31/98 - MWT
* - Created

lparameters tcOnOff, toWhichButton
local llStatus

if upper(tcOnOff) == "OFF"
llStatus = .F.
else
llStatus = .T.
endif

if type("toWhichButton") = "L"
this.setall("Enabled",llStatus,"mvCommandButton")
*!* this.btnNew.Enabled = llStatus
*!* this.btnEdit.Enabled = llStatus
*!* this.btnDelete.Enabled = llStatus
*!* this.btnPrint.Enabled = llStatus
*!* this.btnClose.Enabled = llStatus
RETURN
endif

if type("toWhichButton") = "O"
toWhichButton.Enabled = llStatus
*!* do case && Begins loop
*!* CASE UPPER(tcWhichButton) = 'NEW'
*!* this.btnNew.Enabled = llStatus
*!* case upper(tcWhichButton) = 'EDIT'
*!* this.btnEdit.Enabled = llStatus
*!* CASE UPPER(tcWhichButton) = 'DELETE'
*!* This.btnDelete.Enabled = llStatus
*!* CASE UPPER(tcWhichButton) = 'PRINT'
*!* This.btnPrint.Enabled = llStatus
*!* CASE UPPER(tcWhichButton) = 'CLOSE'
*!* This.btnClose.Enabled = llStatus
*!* OTHERWISE
*!* RETURN
*!* ENDCASE && Ends loop
endif
* END EntryToolBar.Buttons()()

I'm not certain that this will work if you need to store some status that is selected by the user, but it works for situations that can be defined in advance.
HTH

Mike
Mike
Previous
Reply
Map
View

Click here to load this message in the networking platform