Guest JRowe_1 Posted November 28, 2006 Posted November 28, 2006 I can read the data from the list just fine, but how do I fire an event when the control is clicked? $HistoryListA =GUICtrlCreateList("", 389, 37, 225, 326, BitOR($WS_VSCROLL,$WS_BORDER)) GUICtrlSetFont(-1, 08, 400, 0, "Arial") GUICtrlSetOnEvent($HistoryListA, "PopulateJobView") Theres my code (used koda to build my gui) I want to call the function PopulateJobView when an item is clicked in the list. PopulateJobView reads the item that is selected, then returns details about the Job in question.
Guest JRowe_1 Posted November 28, 2006 Posted November 28, 2006 I set the data to the list, during the login function, etc. I am interested to see what the solution to this is, since I can't seem to find a simple function that can trigger an event when the control is in focus. I can think of workarounds, but I don't want to delve off into a tangent if there's a simple solution. Thanks for taking a look at it
jlorenz1 Posted November 28, 2006 Posted November 28, 2006 It doesn't work without an entry in the liust, but if you clicked the entry in the list - it will work - see example below. Johannes from Germany #include <GUIConstants.au3> Opt('GUIOnEventMode', 1) GUICreate('My GUI list', 250,500) ; will create a dialog box that when displayed is centered $HistoryListA = GUICtrlCreateList('word', 10, 37, 225, 326) ;BitOR($WS_VSCROLL,$WS_BORDER) GUICtrlSetOnEvent(-1, '_PopulateJobView') GUICtrlSetFont(-1, 08, 400, 0, 'Arial') $close=GUICtrlCreateButton ('my closing button', 70,360,175,25) GUICtrlSetOnEvent(-1, '_secondfunc') GUISetState () While 1 Sleep(1000) ; Idle around WEnd Func _PopulateJobView() MsgBox(4096,'it works','function PopulateJobView') EndFunc Func _secondfunc() MsgBox(4096,'it works','secondfunc') EndFunc Johannes LorenzBensheim, Germanyjlorenz1@web.de[post="12602"]Highlightning AutoIt Syntax in Notepad++ - Just copy in your Profile/application data/notepad++[/post]
Valuater Posted November 28, 2006 Posted November 28, 2006 jlorenz1... be sure to use code tags [ code] ; no spaces ; paste code [ /code] ; no spaces or replace the word "code" above with "autoit" or "quote" 8)
Guest JRowe_1 Posted November 28, 2006 Posted November 28, 2006 Ahh, excellent, thanks very much. Just needed to fire that event off real quick in order to display the details about the selected job. Although, your script example requires a workaround to be able to close the gui; $Form1 = GUICreate("AForm1", 633, 424, 191, 111) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")oÝ÷ Ù©Ýjëh×6Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow If @GUI_WINHANDLE = $Form1 Then _MySQLEnd($connect) Exit EndIf EndFunc That way it can close, otherwise it just loops indefinitely. Thanks again, man, I really appreciate that!
Guest JRowe_1 Posted December 1, 2006 Posted December 1, 2006 I think I can understand how to create a "Listen for double click" event, which would wait, say, 1 second after the first click, tag the time and then listen for a second, if the second wasn't recieved, set the state back to 0 and carry on... Haven't done it yet, working on it as we speak, does anyone know of a better way to get the list to respond to a double click (only on a selected item?.) I know I could set a handler in there, as well, to read the value of the control, and If $readValue = "" then Ignore double click event or whatever. Granted... it's only 20 lines or so of code, but I'd like to know if theres a built in, elegant way of handling this. I'll post the update shortly.
GaryFrost Posted December 1, 2006 Posted December 1, 2006 You should be able to modify it to fit your needs. expandcollapse popup#include <GuiConstants.au3> Global Const $DebugIt = 1 Global Const $WM_COMMAND = 0x0111 GUICreate("MyGUI", 460, 260, -1, -1) $Edit_1 = GUICtrlCreateEdit("Edit1", 10, 10, 360, 210) $Input_2 = GUICtrlCreateInput("Input2", 10, 230, 360, 20) $List_3 = GUICtrlCreateList("List3", 380, 10, 70, 240, BitOR($LBS_SORT, $LBS_NOINTEGRALHEIGHT, $LBS_NOTIFY, $WS_TABSTOP)) GUICtrlSetData($List_3, "item2") GUISetState() GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Exit Func List_DoubleClick() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$LBN_DBLCLK: " & GUICtrlRead($List_3)) ;---------------------------------------------------------------------------------------------- EndFunc ;==>List_DoubleClick Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Local $hCtrl = $lParam Local Const $LBN_ERRSPACE = (-2); Local Const $LBN_SELCHANGE = 1; Local Const $LBN_DBLCLK = 2; Local Const $LBN_SELCANCEL = 3; Local Const $LBN_SETFOCUS = 4; Local Const $LBN_KILLFOCUS = 5; Switch $nID Case $List_3 Switch $nNotifyCode Case $LBN_ERRSPACE _DebugPrint("$LBN_ERRSPACE") Case $LBN_SELCHANGE _DebugPrint("$LBN_SELCHANGE") Case $LBN_SELCANCEL _DebugPrint("$LBN_SELCANCEL") Case $LBN_SETFOCUS _DebugPrint("$LBN_SETFOCUS") Case $LBN_KILLFOCUS _DebugPrint("$LBN_KILLFOCUS") Case $LBN_DBLCLK List_DoubleClick() EndSwitch EndSwitch ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite("!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Guest JRowe_1 Posted December 1, 2006 Posted December 1, 2006 ok, so I decided to go with my own timestamp version of things. Simply because I like my logic directly in front of me, and this is a puzzler My problem thus far is that it reads just fine when you've clicked the control twice too slowly, but it won't fire if the second click comes in time. Func ListenForDoubleClick() If $ClickedOnce = True Then $ClickedTwice = True EndIf If $ClickedOnce = False Then $stamp = TimerInit() $ClickedOnce = True EndIf If $ClickedTwice = True Then $dif = TimerDiff($stamp) If $dif < 500 Then MsgBox(0,"Test", "Success!") $ClickedOnce = False $ClickedTwice = False EndIf If $dif > 500 Then MsgBox(0, "Test", "Not Fast Enough!") $ClickedTwice = False $ClickedOnce = False EndIf EndIf EndFunc There's my function
GaryFrost Posted December 1, 2006 Posted December 1, 2006 Suit yourself, many of us went down that road a long time ago. Now with events no need to do whats already taken care of for you. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Guest JRowe_1 Posted December 1, 2006 Posted December 1, 2006 I know, and your method works, but I wanted to see if I could do it myself. Since I hit a wall in the logic puzzle after spending some 4 hours on it, i decided to see if there was a solution someone else had come up with that paralleled my own little method, or if there was an unavoidable flaw somewhere in the process Not trying to disregard your help, and I appreciate it, but I want to explore a bit, too
GaryFrost Posted December 1, 2006 Posted December 1, 2006 I know, and your method works, but I wanted to see if I could do it myself. Since I hit a wall in the logic puzzle after spending some 4 hours on it, i decided to see if there was a solution someone else had come up with that paralleled my own little method, or if there was an unavoidable flaw somewhere in the process Not trying to disregard your help, and I appreciate it, but I want to explore a bit, too do a search for double click or doubleclick, but should be some old posts.I believe we used a registry setting for the mouse to determine the time between clicks. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now