Jump to content

Loop to create submenu items


Jewtus
 Share

Recommended Posts

I'm attempting to perform a loop to create a sub menu for each drive on a machine and then I want to call a function using the selected drive name. This is an example of my menu:

$mBuild = GUICtrlCreateMenu("Create Share folder")
    $aDrivesList = DriveGetDrive('ALL')
    _ArrayColInsert($aDrivesList, 1)
    For $x = 1 To UBound($aDrivesList) - 1
        $aDrivesList[$x][1]=GUICtrlCreateMenuItem(StringUpper($aDrivesList[$x][0] & "\"), $mBuild)
    Next

When I do my case statement in the gui... how do I make the case trigger based off which one was selected? If I can figure out the index of the one selected, I can use the array to pull back the text.

 

This is the case statement for my UI:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $mExit
            GUIDelete($MachineSelectorGUI)
            ExitLoop
        Case $mBuild
            BuildShare()
    EndSwitch
WEnd

 

Link to comment
Share on other sites

; Assuming that $aDrivesList is already filled with menu items
; the Case statement should look something like this:
Case $aDrivesList[1][1] To $aDrivesList[UBound($aDrivesList)-1][1]
  $x = $nMsg - $aDrivesList[1][1] + 1 ; $x is index in $aDrivesList

 

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...