Jump to content

auto enable button after input is fill


shai
 Share

Recommended Posts

  • Moderators

shai,

That is quite easy to do. :)

Use GUICtrlSetState(Button_ControlID, $GUI_DISABLE) immediately after the button is created.

Then you can either use GUICtrlRead on the input within your idle loop or, more sexily, look for an $EN_CHANGE message from the input - either will show that data has been entered into the input. :idiot:

Once you have data in the input, use GUICtrlSetState(Button_ControlID, $GUI_ENABLE) to enable the button.

Piece of cake! Try it and see how you get on. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

this is my code.

Func uninstallmode()
    GUICreate ("remove tool", 150, 165, 0, 0, $WS_CAPTION)
    $serial = GUICtrlCreateInput("", 10, 10, 130, 20, $ES_NUMBER+$ES_PASSWORD)
    $ok_btn = GUICtrlCreateButton("ok", 10, 35, 130, 20)
    $next_next = GUICtrlCreateButton("next...", 10, 85, 130, 20)
    $after_uninstall = GUICtrlCreateButton("clear", 10, 110, 130, 20)   
    GUICtrlSetState($ok_btn,$GUI_DISABLE)
    GUISetBkColor(0xFFFFFF) 
    GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $cancel_btn
            GUIDelete()
        Case $ok_btn
            If GUICtrlRead($serial) = "000000" Then
                uninstall()
                exit
            EndIf   
        Case $next_next
            aotuuninstall()
        Case $after_uninstall
            afteruninstall()
    EndSwitch
WEnd                
EndFunc

you can show my example?

thanks

Link to comment
Share on other sites

  • Moderators

shai,

After giving you a step-by-step explanation, I would have expected you to make at least an attempt at coding this yourself! :)

However, if I must:

Using GUICtrlRead:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

uninstallmode()

Func uninstallmode()
    GUICreate("remove tool", 150, 165, 0, 0, $WS_CAPTION)
    $serial = GUICtrlCreateInput("", 10, 10, 130, 20, $ES_NUMBER + $ES_PASSWORD)
    $ok_btn = GUICtrlCreateButton("ok", 10, 35, 130, 20)
    $next_next = GUICtrlCreateButton("next...", 10, 85, 130, 20)
    $after_uninstall = GUICtrlCreateButton("clear", 10, 110, 130, 20)
    $cancel_btn = GUICtrlCreateButton("cancel", 10, 135, 130, 20)
    GUICtrlSetState($ok_btn, $GUI_DISABLE)
    GUISetBkColor(0xFFFFFF)
    GUISetState()

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $cancel_btn
                GUIDelete()
                Exit
            Case $ok_btn
                If GUICtrlRead($serial) = "000000" Then
                    ConsoleWrite("uninstall()" & @CRLF)
                    Exit
                EndIf
            Case $next_next
                ConsoleWrite("aotuuninstall()" & @CRLF)
            Case $after_uninstall
                ConsoleWrite("afteruninstall()" & @CRLF)
        EndSwitch

        If GUICtrlRead($serial) <> "" And Not BitAnd(GUICtrlGetState($ok_Btn), $GUI_ENABLE) Then GUICtrlSetState($ok_btn, $GUI_ENABLE)

    WEnd
EndFunc   ;==>uninstallmode

Using GUIRegisterMsg (look at the GUIRegisterMsg tutorial in the Wiki if you are unsure about what this function does ;) ):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

Global $serial, $ok_btn

uninstallmode()

Func uninstallmode()
    GUICreate("remove tool", 150, 165, 0, 0, $WS_CAPTION)
    $serial = GUICtrlCreateInput("", 10, 10, 130, 20, $ES_NUMBER + $ES_PASSWORD)
    ConsoleWrite($serial & @CRLF)
    $ok_btn = GUICtrlCreateButton("ok", 10, 35, 130, 20)
    $next_next = GUICtrlCreateButton("next...", 10, 85, 130, 20)
    $after_uninstall = GUICtrlCreateButton("clear", 10, 110, 130, 20)
    $cancel_btn = GUICtrlCreateButton("cancel", 10, 135, 130, 20)
    GUICtrlSetState($ok_btn, $GUI_DISABLE)
    GUISetBkColor(0xFFFFFF)
    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "On_WM_COMMAND")

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $cancel_btn
                GUIDelete()
                Exit
            Case $ok_btn
                If GUICtrlRead($serial) = "000000" Then
                    ConsoleWrite("uninstall()" & @CRLF)
                    Exit
                EndIf
            Case $next_next
                ConsoleWrite("aotuuninstall()" & @CRLF)
            Case $after_uninstall
                ConsoleWrite("afteruninstall()" & @CRLF)
        EndSwitch

    WEnd

EndFunc   ;==>uninstallmode

Func On_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    If $nNotifyCode = $EN_UPDATE And $nID = $serial Then
        If Not BitAND(GUICtrlGetState($ok_btn), $GUI_ENABLE) Then GUICtrlSetState($ok_btn, $GUI_ENABLE)
    EndIf
EndFunc   ;==>On_WM_COMMAND

Note in both cases you need to check that the button is not already enabled before enabling it - if you do not do this you get "flashing" of the control, particularly when the mouse moves. :idiot:

M23

P.S. And next time, please post code that runs so I do not have to add a bunch of lines to get it to work. :idiot:

Edit: Typnig!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...