Trystian Posted March 21, 2005 Posted March 21, 2005 Hello all,First post here. Please don't flame me for being a newb, all my fire extinguishers are empty. I'm trying to make an application which takes the selected ListView Item and populates an Inputbox. Unfortunately, it's not updating the Inputbox when I select a different ListView Item from the ListView Control. Is there any way to do this with Event Mode on?Thanks in advance,-TrystianSample:#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox GUICtrlSetOnEvent($ListView_1,"fcnSelected") GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename While 1 Sleep(5000) WEnd Func fcnSelected() Global $strSelFile $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|") GUICtrlSetData ($Input_1, $strSelFile[1]) EndFunc
GaryFrost Posted March 21, 2005 Posted March 21, 2005 I haven't seen a way of doing that on event but the following might work for you. #include <GuiConstants.au3> ;~ Opt("GUIOnEventMode", 1) GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox ;~ GUICtrlSetOnEvent($ListView_1,"fcnSelected") GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename Do $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_PRIMARYDOWN if(ControlListView("Video Selector", "", $ListView_1, "GetSelectedCount"))Then fcnSelected() EndIf EndSelect Until $MSG = $GUI_EVENT_CLOSE Func fcnSelected() Global $strSelFile $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|") GUICtrlSetData ($Input_1, $strSelFile[1]) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Trystian Posted March 21, 2005 Author Posted March 21, 2005 I was hoping onEvent mode had some way to handle this issue.Your solution does work well gafrost, thank you for the rapid response.Now to convert the rest of my application from onEvent Mode to MessageLoop mode. Once again, Thanx.-TrystianI haven't seen a way of doing that on eventbut the following might work for you.#include <GuiConstants.au3> ;~ Opt("GUIOnEventMode", 1) GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox ;~ GUICtrlSetOnEvent($ListView_1,"fcnSelected") GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents GUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents GUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView Contents Global $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected Filename Do $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_PRIMARYDOWN if(ControlListView("Video Selector", "", $ListVie w_1, "GetSelectedCount"))Then fcnSelected() EndIf EndSelect Until $MSG = $GUI_EVENT_CLOSE Func fcnSelected() Global $strSelFile $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|") GUICtrlSetData ($Input_1, $strSelFile[1]) EndFunc<{POST_SNAPBACK}>
GaryFrost Posted March 21, 2005 Posted March 21, 2005 Need to slap my own hands for answering that one so quickly, You might want to look into system events SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
jpm Posted March 21, 2005 Posted March 21, 2005 (edited) I was hoping onEvent mode had some way to handle this issue.Your solution does work well gafrost, thank you for the rapid response.Now to convert the rest of my application from onEvent Mode to MessageLoop mode. Once again, Thanx.-Trystian<{POST_SNAPBACK}>just add GUICtrlSetOnEvent(-1,"fcnSelected")after creating the GUICtrlCreateListViewItemno too elegant but remenber item are control that can be set independanly so react independantly.edit: you miss a GuiSetState() before the while loop Edited March 21, 2005 by jpm
sylvanie Posted March 21, 2005 Posted March 21, 2005 I was hoping onEvent mode had some way to handle this issue.Your solution does work well gafrost, thank you for the rapid response.Now to convert the rest of my application from onEvent Mode to MessageLoop mode. Once again, Thanx.-Trystian<{POST_SNAPBACK}>Hello, I think that it could be a solution :#include <GuiConstants.au3>Opt("GUIOnEventMode", 1)GuiCreate("Video Selector", 730, 420,(@DesktopWidth-730)/2, (@DesktopHeight-420)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)Global $ListView_1 = GuiCtrlCreateListView("Filename.Ext" & "|Size(Mb)|Date Modified", 20, 100, 380, 305); Filename ListViewbox;GUICtrlSetOnEvent($ListView_1,"fcnSelected")GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"fcnSelected")GUICtrlCreateListViewItem ("Test1.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView ContentsGUICtrlCreateListViewItem ("Test2.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView ContentsGUICtrlCreateListViewItem ("Test3.avi" & "|" & "350" & "|" & "03/21/05 10:00",$ListView_1); Add ListView ContentsGlobal $Input_1 = GuiCtrlCreateInput("Filename.ext", 430, 185, 285, 20); Selected FilenameGUISetState() ; don't forget !While 1 Sleep(5000)WEndFunc fcnSelected() Global $strSelFile $strSelFile = StringSplit(GUICtrlRead(GUICtrlRead($ListView_1)),"|") GUICtrlSetData ($Input_1, $strSelFile[1]) EndFuncIsn't it ?
GaryFrost Posted March 21, 2005 Posted March 21, 2005 (edited) that'll work, but I would think you want to make sure that the primary down was for the control specified GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SpecialEvents") Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN if(ControlGetFocus("Video Selector") == "SysListView321") then if(ControlListView("Video Selector", "", $ListView_1, "GetSelectedCount"))Then fcnSelected() EndIf EndIf EndSelect EndFunc Edited March 21, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Trystian Posted March 21, 2005 Author Posted March 21, 2005 This solution works perfectly for my needs. Thank you all for your help.-Trystianthat'll work, but I would think you want to make sure that the primary down was for the control specifiedGUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SpecialEvents") Func SpecialEvents() Select Case @GUI_CTRLID = $GUI_EVENT_PRIMARYDOWN if(ControlGetFocus("Video Selector") == "SysListView321") then if(ControlListView("Video Selector", "", $ListView_1, "GetSelectedCount"))Then fcnSelected() EndIf EndIf EndSelect EndFunc<{POST_SNAPBACK}>
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