florian Posted September 26, 2006 Share Posted September 26, 2006 Hi all, I need the GUICtrlSetOnEvent to call a function with an argument. In my program, I created a listview containing IP addresses. I want to create a contextual Menu which allows me to lauch a telnet or ssh connection to the ListView Item selected. here is a piece of my code. $tablehost[$j][4] = GUICtrlCreateContextMenu($itemid) $tablehost[$j][5] = GUICtrlCreateMenuitem("telnet " & $tablehost[$j][1], $tablehost[$j][4]) $tablehost[$j][6] = GUICtrlCreateMenuitem("ssh " & $tablehost[$j][1], $tablehost[$j][4]) GUICtrlSetOnEvent($tablehost[$j][5], telnet($j)) GUICtrlSetOnEvent($tablehost[$j][6], ssh($j)) [...] Func telnet($var) msgbox(0,"debug", "telnetting to " & $var) EndFunc [...] [...] Func ssh($var) msgbox(0,"debug", "launching ssh to " & $var) EndFunc [...] and this does not work. It seems that when the Listview item is created, It launches the telnet function (which is not what I want) and then fails... I dont understand why. I also tried to set the syntax like: GUICtrlSetOnEvent($tablehost[$j][5], "telnet(" & $j & ")") but it reports erros when launched : ==> Unknown function name.: GUICtrlSetOnEvent($tablehost[$j][5], "telnet(" & $j & ")") Any help would be greatly appreciated. Best regards Florian Link to comment Share on other sites More sharing options...
xcal Posted September 26, 2006 Share Posted September 26, 2006 (edited) Why can't you just use _GUICtrlListViewGetItemText inside your functions? edit - oops, wrong function Edited September 26, 2006 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
florian Posted October 4, 2006 Author Share Posted October 4, 2006 I succeeded to do what I wanted using _GUICtrlListViewGetItemText. Thanks for your help xcal.FlorianWhy can't you just use _GUICtrlListViewGetItemText inside your functions?edit - oops, wrong function Link to comment Share on other sites More sharing options...
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