Sign in to follow this  
Followers 0
FinalVersion

Select, Case Problems.

8 posts in this topic

Current Code:

Func CheckCmd()
    $Check = GUICtrlRead($Main)
    Select
        Case $Check = "Help"
            GUICtrlSetData($Main, "Line1" & @CRLF & "Line2")
        Case $Check = "Clear"
            GUICtrlSetData($Main, "")
    EndSelect
EndFunc     ;==>CheckCmd

When help is typed enter pushed, Line1 Line2 should show etc. Help is appreciated.

Share this post


Link to post
Share on other sites



i got this from AutoIT examples folder

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
                ;When button is pressed, label text is changed
                ;to combobox value
            Case $msg = $button1
                $data = GUICtrlRead($Combo_2)
                GUICtrlSetData($Label_1, $data)
        EndSelect
    WEnd

Hope it helps you.


UnderWorldVN- Just play the way you like it

Share this post


Link to post
Share on other sites

i got this from AutoIT examples folder

While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
                ;When button is pressed, label text is changed
                ;to combobox value
            Case $msg = $button1
                $data = GUICtrlRead($Combo_2)
                GUICtrlSetData($Label_1, $data)
        EndSelect
    WEnd

Hope it helps you.

$Main is a edit box.

Share this post


Link to post
Share on other sites

#include <Constants.au3>
#include <EditConstants.au3> 
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate('Title', 300, 100)
$Edit = GUICtrlCreateEdit('', 10, 20, 280, 60, BitOR($ES_WANTRETURN, $__EDITCONSTANT_WS_HSCROLL,$ES_AUTOHSCROLL))
$hEdit = GUICtrlGetHandle(-1)

$hOldProc = _WinAPI_GetWindowLong($hEdit, $GWL_WNDPROC)
$hFunc = DllCallbackRegister('WndProc', 'long', 'hwnd;uint;wparam;lparam')
$pFunc = DllCallbackGetPtr($hFunc)

_WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $pFunc)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete()
DllCallbackFree($hFunc)
Exit

Func CheckCmd($sString)
    
EndFunc  ;==>CheckCmd

Func WndProc($hwnd, $iMsg, $iwParam, $ilParam)
    If $iMsg = $WM_CHAR Then
        If $iwParam = 13 Then
            Switch GUICtrlRead($Edit)
                Case "help"
                    GUICtrlSetData($Edit, "Line1" & @CRLF & "Line2")
                Case "clear"
                    GUICtrlSetData($Edit, "")
            EndSwitch
        EndIf
    EndIf
    
    Return _WinAPI_CallWindowProc($hOldProc, $hwnd, $iMsg, $iwParam, $ilParam)
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Your code is OK.

Are you sure the function CheckCmd() is called?

You can see that it works:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 347, 120, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Main = GUICtrlCreateEdit("", 8, 8, 329, 65)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Button1", 136, 88, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "CheckCmd")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func CheckCmd()
    $Check = GUICtrlRead($Main)
    Select
        Case $Check = "Help"
            GUICtrlSetData($Main, "Line1" & @CRLF & "Line2")
        Case $Check = "Clear"
            GUICtrlSetData($Main, "")
    EndSelect
EndFunc
Func Form1Close()
    Exit
EndFunc
Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

#include <Constants.au3>
#include <EditConstants.au3> 
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate('Title', 300, 100)
$Edit = GUICtrlCreateEdit('', 10, 20, 280, 60, BitOR($ES_WANTRETURN, $__EDITCONSTANT_WS_HSCROLL,$ES_AUTOHSCROLL))
$hEdit = GUICtrlGetHandle(-1)

$hOldProc = _WinAPI_GetWindowLong($hEdit, $GWL_WNDPROC)
$hFunc = DllCallbackRegister('WndProc', 'long', 'hwnd;uint;wparam;lparam')
$pFunc = DllCallbackGetPtr($hFunc)

_WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $pFunc)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete()
DllCallbackFree($hFunc)
Exit

Func CheckCmd($sString)
    
EndFunc  ;==>CheckCmd

Func WndProc($hwnd, $iMsg, $iwParam, $ilParam)
    If $iMsg = $WM_CHAR Then
        If $iwParam = 13 Then
            Switch GUICtrlRead($Edit)
                Case "help"
                    GUICtrlSetData($Edit, "Line1" & @CRLF & "Line2")
                Case "clear"
                    GUICtrlSetData($Edit, "")
            EndSwitch
        EndIf
    EndIf
    
    Return _WinAPI_CallWindowProc($hOldProc, $hwnd, $iMsg, $iwParam, $ilParam)
EndFunc

Thank you.

@enaiman

Its called by _ispressed func.

Share this post


Link to post
Share on other sites

Its called by _ispressed func.

Then why it failed if it was really called?

I guess you didn't bother to look at my example to see that your function works. Better for me to avoid wasting my time in the future :)


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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  
Followers 0