Hi All,
I have a listbox that has a context menu associated with it. When I right-click on the listbox the context menu pops up as expected. But I would like for the list item under the cursor to be selected, so that my context menu can take action on that item (such as "remove item"). I have culled my script down to the pertinent parts I think.
Can someone give me a pointer in the right direction on how to select / activate a list item under the cursor? Please overlook my #region definitions. It drives most people mad but it does help me.
#region Includes and Constants
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#endregion Includes and Constants
#region GUI Scaling
Local $hWidth = 615
Local $hHeight = 438
Local $hTop = (@DesktopHeight - 40 - $hHeight) / 2
Local $hLeft = (@DesktopWidth - $hWidth) / 2
#endregion
#region GUI section
Local $iTitle = "User Configuration Applet"
Local $hGUI = GUICreate($iTitle, $hWidth, $hHeight, $hLeft, $hTop,BitOR($GUI_SS_Default_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))
Local $tQuestion = GUICtrlCreateLabel("When I right-click in the listbox I would like the user below it to be selected but I'm not sure how.",5,5)
Local $hUsers = GUICtrlCreateList("", 16, 245, 227, 175)
_GUICtrlListBox_AddString($hUsers,"Joe Mama")
_GUICtrlListBox_AddString($hUsers,"John Public")
_GUICtrlListBox_AddString($hUsers,"Jane Doe")
_GUICtrlListBox_EndUpdate($hUsers)
Local $ContextMenuUsers = GUICtrlCreateContextMenu($hUsers)
Local $ContextRemove = GUICtrlCreateMenuItem("Remove User",$ContextMenuUsers)
GUISetState(@SW_SHOW)
#endregion
#region Monitor the GUI
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $ContextRemove
MsgBox(0,"User to remove","Need to have the user selected...")
EndSwitch
WEnd
#endregion