Jump to content

Require edit box input


Monoxide
 Share

Recommended Posts

I am using MessageLoop mode for the GUI.

I have multiple groups of yes/no radio box.

Once Group1 has a selection, Group2 is un-hid. Group3 is hidden until Group2 has a selection. The Edit1 box is never hidden.

I need to require input in the Edit1 box if either or both Group1 is "yes" or Group2 is "no" before Group3 is displayed.

I seem to be drawing a blank on how to accomplish this.

How can I add a check to see if the Edit1 box has data so Group2 or Group3 can then be un-hid?

Link to comment
Share on other sites

I am using MessageLoop mode for the GUI.

I have multiple groups of yes/no radio box.

Once Group1 has a selection, Group2 is un-hid. Group3 is hidden until Group2 has a selection. The Edit1 box is never hidden.

I need to require input in the Edit1 box if either or both Group1 is "yes" or Group2 is "no" before Group3 is displayed.

I seem to be drawing a blank on how to accomplish this.

How can I add a check to see if the Edit1 box has data so Group2 or Group3 can then be un-hid?

I would probably use $EN_CHANGE notification to detect when something in the edit has changed, and at that time check there is something in the edit and set a global variable which you can use to decide whether or not to show group3.

; *** Start added by AutoIt3Wrapper ***
#include <WindowsConstants.au3>
; *** End added by AutoIt3Wrapper ***
#AutoIt3Wrapper_Add_Constants=n
#include <editconstants.au3>

$edit1hastext = False

$g1 = guicreate("edit change")
$edit1 = GUICtrlCreateEdit("", 10, 10, 300, 200)
$b1 = GUICtrlCreateButton("any text?", 100, 240)
GUISetState()

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND");so we can catch the $EN_CHANGE

While 1
    $Msg = GUIGetMsg()
    if $msg = -3 then Exit

    If $Msg = $b1 Then
        If $edit1hastext Then
            MsgBox(262144, "Text in edit?", "yes")
        Else
            MsgBox(262144, "Text in edit?", "no")
        EndIf
    EndIf
WEnd




Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF) ; LoWord - this gives the control which sent the message
    Local $iCode = BitShift($wParam, 16) ; HiWord - this gives the message that was sent
    If $iCode = $EN_CHANGE Then ; If we have the correct message
        Switch $iIDFrom ; See if it comes from $Edit1
            Case $edit1
                $edit1hastext = GUICtrlRead($edit1) <> ''

        EndSwitch
    EndIf
    
EndFunc   ;==>MY_WM_COMMAND
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...