Jump to content

Make GUICtrlSetOnEvent Call a function with an argument


florian
 Share

Recommended Posts

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...