Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Like many other FoxPro Properties, Enabled can be used to Set and Get values.Is there a way in FP (and maybe VFP) to test the status of a push button, that is to return whether a button is ENABLED or DISABLED?
IF MyButton.Enabled
MyButton.Enabled = .F.
ELSE
MyButton.Enabled = .T.
ENDIF
Better:Like many other FoxPro Properties, Enabled can be used to Set and Get values.
So you can do things like this...
Code:IF MyButton.Enabled MyButton.Enabled = .F. ELSE MyButton.Enabled = .T. ENDIF
Normally, the "dimmed" appearance of the button tells you its Enabled status. All you have to do is reference the Enabled property maybe with something like this:Is there a way in FP (and maybe VFP) to test the status of a push button, that is to return whether a button is ENABLED or DISABLED?
I agree. I just wanted the easiest way to illustrate reading the value and setting the value, so I opted for simple independent IF and = lines to make it easy to read.Better:
MyButton.Enabled = not MyButton.Enabled
Programmatically You can check the Status of this button as above mentioned.
But if You like to react at runtime for click on this button while !enabled, there is no event what fires. Neither MouseDown- nor Click-Event.
The only events who fires are MouseEnter-/Leave. those are not blocked with !Enabled because to react with ToolTipText.
Thanks. You have given me some ideas to try.Like many other FoxPro Properties, Enabled can be used to Set and Get values.
So you can do things like this...
Code:IF MyButton.Enabled MyButton.Enabled = .F. ELSE MyButton.Enabled = .T. ENDIF
I'm sorry, I was trying to simplify by using essentially Pseudo code, since I don't know the name of your button, or where it is.Thanks. You have given me some ideas to try.
Your code throws "Alias 'MyButton' not found" error which makes sense since MyButton.Enabled is trying to find the 'Enabled' field in a table named 'MyButton'.
IF MyButton = 'ENABLED' throws "Operator/operand mismatch" error.
I am thinking that I will need to use OBJNUM() in some way to get what I need.
When I get more time I will do more testing.
Yes, I changed 'MyButton' in your code to the actual name of my button.
BTW, I deliberately did not state exactly which version I am using because I wanted ideas from any version that might point me in the right direction.
That said, I am using FPM 2.6b.
Basically, I need to do something like this (which obviously will not work ):
IF MyButton = ENABLED
SHOW GET MyButton DISABLED
ENDIF
If thisform.MyPageFrame.Page2.MyContainer.MyButton.Enabled
thisform.MyPageFrame.Page2.MyContainer.MyButton.Enabled = .F.
Else
thisform.MyPageFrame.Page2.MyContainer.MyButton.Enabled = .T.
Endif
With thisform.MyPageFrame.Page2.MyContainer.MyButton
If .Enabled
.Enabled = .F.
Else
.Enabled = .T.
Endif
EndWith
Local loButton
loButton = thisform.MyPageFrame.Page2.MyContainer.MyButton
If loButton.Enabled
loButton.Enabled = .F.
Else
loButton.Enabled = .T.
Endif
BTW, I deliberately did not state exactly which version I am using because I wanted ideas from any version that might point me in the right direction.
That said, I am using FPM 2.6b.
Basically, I need to do something like this (which obviously will not work ):
IF MyButton1 = ENABLED
SHOW GET MyButton2 DISABLED
ENDIF
I didn't notice the version.BTW, I deliberately did not state exactly which version I am using because I wanted ideas from any version that might point me in the right direction.
That said, I am using FPM 2.6b.
Basically, I need to do something like this (which obviously will not work ):
IF MyButton1 = ENABLED
SHOW GET MyButton2 DISABLED
ENDIF
That's exactly right. Believe it or not, I still have some legacy code that uses @ SAY / GETs in sections and the approach I used there was to clear the screen, create an endless loop with DO WHILE .T. that paints the screen with all sorts of conditional variations and continues to loop after READ potentially re-painting with different effects, then after the user hits a key such as F10, Exits the loop. That's exactly what the OP needs to do here.Do you have a help file about FPM 2.6b?
It may help to refer to it - https://www.vfphelp.com/help/_5wn12pwjw.htm has a legacy help chapter on @...GET Buttons.
I have read through and it describes how to create disabled buttons, but there is no mention about getting the status. So as Joe suggested you'd have to keep track of what you designed a button (set) to be reagarding enabled/disabled.
As far as I understand legacy FP screen logic, you'll have to use a READ or READ CYCLE for points a user can interact with the UI as it is (with disabled or enabled buttons besides anything else), so if I understand this correctly you can only deal with changes after a user interaction ends a READ and at that stage you may recreate the buttons in the new state yoiu want them, but not change their status, So you'd vary the @...GET command button calls to then create a buttont or button set that has disabled/enabled as you need it as the aftermath of the last interaction.