Jump to content

edit's question


Recommended Posts

If I were to use an edit box, Could I pull info or activate functions from within the edit box depending on what I type?

Here is what I have tried so far:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()


    Local $GUIWidth = 300, $GUIHeight = 250
    Local $Edit_1, $OK_Btn, $Cancel_Btn, $msg


    GUICreate("test edit", $GUIWidth, $GUIHeight)


    $Edit_1 = GUICtrlCreateEdit("", 10, 10, 280, 190)


    $OK_Btn = GUICtrlCreateButton("OK", 75, 210, 70, 25)


    $Cancel_Btn = GUICtrlCreateButton("Cancel", 165, 210, 70, 25)


    GUISetState(@SW_SHOW)


    While 1

        $msg = GUIGetMsg()

        Select


            Case $msg = $GUI_EVENT_CLOSE

                GUIDelete()

                Exit


            Case $msg = $OK_Btn
                If $edit_1 = "test" Then
                    MsgBox(0, "test edit", "You typed Test")
                EndIf


        EndSelect

    WEnd
EndFunc   ;==>_Main

Would I have to send it to an INI and then recall it later, or would it just act once I press enter?

Thanks

Cue

Link to comment
Share on other sites

I suppose $edit_1 could be processed after it is submitted (with StringInStr maybe?) and something done if something specific is found in that variable.

Here's an example using your code:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()


    Local $GUIWidth = 300, $GUIHeight = 250
    Local $Edit_1, $OK_Btn, $Cancel_Btn, $msg

    GUICreate("test edit", $GUIWidth, $GUIHeight)

    $Edit_1 = GUICtrlCreateEdit("", 10, 10, 280, 190)
    $OK_Btn = GUICtrlCreateButton("OK", 75, 210, 70, 25)
    $Cancel_Btn = GUICtrlCreateButton("Cancel", 165, 210, 70, 25)

    GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
                Exit
            Case $msg = $OK_Btn
                If StringInStr(GUICtrlRead($Edit_1), "test") > 0 Then
                    MsgBox(0, "", "'test' found")
                Else
                    MsgBox(0, "", "'test' not found")
            EndIf
        EndSelect
    WEnd
EndFunc   ;==>_Main
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

For multiple tests, it might be easier and better to use Select or Switch statements rather than If's, especially if there's alot of tests to do.

There was another reference to snow, so I figured it was just easier to change my userid rather than PM'ing everybody who says snow instead of snowmaker. :(

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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