Jump to content
Sign in to follow this  
cueclub

edit's question

Recommended Posts

cueclub

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

Share this post


Link to post
Share on other sites
somdcomputerguy

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.

Share this post


Link to post
Share on other sites
cueclub

ah ok i didn't even think about that. Will give it a try, wonder if I could use it for multiple lines. I will look into it and post again if i hit a snag.

Thanks Somd j/k somdcomputerguy

Cue

Share this post


Link to post
Share on other sites
somdcomputerguy

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.

Share this post


Link to post
Share on other sites
cueclub

lol glad I'm not the only one who made the mistake.

Thanks for the suggestion

Cue

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.