Jump to content

Change state of Input field


Recommended Posts

I have 2 items (a field box and a bypass checkbox). every time the box is checked i need the field to become writable. unchecked is read only displaying some text.

this is as far as i got as I am stuck at making it read/write toggle

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

$hGUI = GUICreate("Test", 500, 500)

Global $hCombo = GUICtrlCreateInput("", 10, 10, 200, 20, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetBkColor($hCombo,0xe7e5e5)

Global $cbox = GUICtrlCreateCheckbox ("", 40,50,10,20)
GUICtrlSetState($cbox, $GUI_Unchecked)
GUISetState()

Global $sCurrCombo = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cbox
            If GUICtrlRead($cbox) <> $sCurrCombo Then
                $sCurrCombo = GUICtrlRead($cbox)
                GUICtrlSetStyle ($hCombo, $SS_LEFTNOWORDWRAP)
                GUICtrlSetBkColor($hCombo,0xFFFFFF)
                MsgBox(0, "Choice", "PLease enter the text")
            EndIf
    EndSwitch
WEnd

 

Link to comment
Share on other sites

Hi,

How about having it this way:

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cbox
            If GUICtrlRead($cbox) <> $GUI_UNCHECKED Then
                $sCurrCombo = GUICtrlRead($cbox)
                GUICtrlSetStyle ($hCombo, $SS_LEFTNOWORDWRAP)
                GUICtrlSetBkColor($hCombo,0xFFFFFF)
                MsgBox(0, "Choice", "PLease enter the text")
             ElseIf GUICtrlRead($cbox) <> $GUI_CHECKED Then
                GUICtrlSetState($hCombo, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
            EndIf
    EndSwitch
WEnd

Would that suffice you?

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

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

$hGUI = GUICreate("Test", 500, 500)

Global $hCombo = GUICtrlCreateInput("", 10, 10, 200, 20)
GUICtrlSetState($hCombo, $GUI_DISABLE)

Global $cbox = GUICtrlCreateCheckbox ("", 40,50,10,20)

GUISetState()

Global $sCurrCombo = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cbox
            if GUICtrlRead($cbox) = $GUI_CHECKED Then
                GUICtrlSetState($hCombo, $GUI_ENABLE)
                MsgBox(0, "Choice", "PLease enter the text")
            Else
                GUICtrlSetState($hCombo, $GUI_DISABLE)
            EndIf
    EndSwitch
WEnd

 

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

×
×
  • Create New...