Input Eingabe sperren

  • Hallo,

    hab mal eine Frage wie man Inputboxen Sperren kann bei einem Knopf druck.

    Einmal editiert, zuletzt von Halfbax (22. September 2010 um 16:17)

  • Hab 2 Inputboxen via Koda gemacht.

    [autoit]

    ...
    $time = GUICtrlCreateInput("", 104, 54, 33, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_NUMBER))
    GUICtrlSetLimit(-1, 2)
    $hotkey= GUICtrlCreateInput("", 104, 96, 33, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL))
    GUICtrlSetLimit(-1, 1)
    ...

    [/autoit]
  • Mit

    [autoit]

    GUICtrlSetStyle

    [/autoit]

    und

    [autoit]

    $ES_READONLY

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Lieg ich da richtig

    [autoit]

    ...
    GUICtrlSetState($time, $ES_READONLY)
    GUICtrlSetState($hotkey, $ES_READONLY)
    ...

    [/autoit]

    Wie entsperr ich die Inputbox dann ?

  • Hier:

    Spoiler anzeigen
    [autoit]


    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 140, 146, 192, 124)
    $Input1 = GUICtrlCreateInput("Input1", 8, 8, 121, 21)
    $sperren = GUICtrlCreateButton("sperren", 8, 40, 75, 25, $WS_GROUP)
    $entsperren = GUICtrlCreateButton("entsperren", 8, 72, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $sperren
    GUICtrlSetStyle($Input1, $ES_READONLY)
    Case $entsperren
    GUICtrlSetStyle($Input1, "")
    EndSwitch
    WEnd

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Hi,
    ich hab dir mal ein kleines Bsp gemacht:

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    $Form1 = GUICreate("Form1", 633, 454, 271, 155)
    $Input1 = GUICtrlCreateInput("lalala", 176, 64, 169, 21)
    $Button1 = GUICtrlCreateButton("Sperren", 176, 88, 169, 33, $WS_GROUP)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Button1
    Switch GUICtrlRead($Button1)
    Case "Sperren"
    GUICtrlSetStyle($Input1, $ES_READONLY)
    GUICtrlSetData($Button1, "Entsperren")
    Case "Entsperren"
    GUICtrlSetStyle($Input1, 0)
    GUICtrlSetData($Button1, "Sperren")

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    EndSwitch
    WEnd

    [/autoit]

    //Edit: Zu langsam ;):D

  • Krieg folgenen Fehler

    [autoit]

    ERROR: $CONTROLID: undeclared global variable.
    GUICtrlSetState($time, $CONTROLID,

    [/autoit]
  • Weil GUICtrlSetState in dem Fall auch nicht das richtige ist. Nimm wie in den beiden Beispielen GUICtrlSetStyle. Wenn aber doch das State nehmen willst dann must das $CONTROLID durch das $time ersetzen.

    [autoit]

    GUICtrlSetState($time, 128) ; zum sperren
    GUICtrlSetState($time, 64) ; zum entsperren

    [/autoit]

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.