Jump to content

Disable Button until value is selected in 2 comboboxes


Recommended Posts

I'm trying to disable a button, until two comboboxes contain values.

I can get it to work, but then the buttons flickers at mouse movement.

Anyone an idea how to do this without the button flickering?

This is my code until now:

While 1
$msg = GUIGetMsg()  

If GUICtrlRead($sList) = "" Then
    GUICtrlSetState($doImage, $GUI_DISABLE)
ElseIf  GUICtrlRead($dList) = "" Then
    GUICtrlSetState($doImage, $GUI_DISABLE)
Else
    GUICtrlSetState($doImage, $GUI_ENABLE)
EndIf

Select
    Case $msg = $GUI_EVENT_CLOSE
        GUIDelete()
        ExitLoop
    Case $msg = $doImage
        Image()
Case $msg = $restartbtn
        GUIDelete()
        ExitLoop
EndSelect
WEnd
Link to comment
Share on other sites

Set the button and the second combo to disabled when they are created then do a check in your Loop

Case $Msg = $Combo1 Then
    If GUICtrlRead($Msg) <> "" ThenGUICtrlSetState($Combo2, BitOR($GUI_ENABLE, GUI_FOCUS))
Case $Msg = Combo2
    If GUICtrlRead($Msg) <> "" Then GUICtrlSetState($Button, $GUI_ENABLE)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

No problem. You may also want to do more checks in case the correct conditions are not met.

For example if the button has already been enabled and someone goes back and selects an empty item in a combo then you will want to disable the button again but only if it is already enabled. To do that use

If BitAnd(GUICtrlGetState($Button, $GUI_ENABLE) = $GUI_ENABLE Then GuiCtrlSetState($Button, GUI_DISABLE)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...