Sign in to follow this  
Followers 0
florian

Make GUICtrlSetOnEvent Call a function with an argument

3 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why can't you just use _GUICtrlListViewGetItemText inside your functions?

edit - oops, wrong function :)

Edited by xcal

Share this post


Link to post
Share on other sites

I succeeded to do what I wanted using _GUICtrlListViewGetItemText. Thanks for your help xcal.

Florian

Why can't you just use _GUICtrlListViewGetItemText inside your functions?

edit - oops, wrong function :lmao:

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