Markus21 Posted September 15, 2008 Share Posted September 15, 2008 Hi, I was in need of a listbox, where I can select several items. The solution was _GUICtrlListBox, but now the problem is, that I cant assign a Contextmenu to it. Is there any alternative or is there something wrong (It works for normal list..)? $usersinuo = _GUICtrlListBox_Create($GUI, "", 300, 20, 100, 200, $LBS_EXTENDEDSEL) _GUICtrlListBox_AddString($usersinuo, "Michael") _GUICtrlListBox_AddString($usersinuo, "Hans") $contextmenu2 = GUICtrlCreateContextMenu($usersinuo) $submenu2 = GUICtrlCreateMenu("Move To", $contextmenu2) Thanks for help! Bye, Markus Link to comment Share on other sites More sharing options...
rasim Posted September 16, 2008 Share Posted September 16, 2008 Markus21Example:#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> $GUI = GUICreate("Test GUI", 300, 200) $hListBox = GUICtrlCreateList("", 10, 10, 280, 180, $LBS_EXTENDEDSEL) _GUICtrlListBox_AddString($hListBox, "Michael") _GUICtrlListBox_AddString($hListBox, "Hans") $contextmenu2 = GUICtrlCreateContextMenu($hListBox) $submenu2 = GUICtrlCreateMenuItem("Move To", $contextmenu2) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $submenu2 $Index = _GUICtrlListBox_GetCurSel($hListBox) If $Index <> -1 Then ConsoleWrite('!> String: "' & _GUICtrlListBox_GetText($hListBox, $Index) & '" has moved' & @LF) EndSwitch WEnd Link to comment Share on other sites More sharing options...
Markus21 Posted September 16, 2008 Author Share Posted September 16, 2008 Thank you, that works, but how come that you can combine autoitlistbox with udf listbox? Link to comment Share on other sites More sharing options...
rasim Posted September 16, 2008 Share Posted September 16, 2008 Markus21Controls created with functions GUICtrlCreateList() and _GUICtrlListBox_Create() is window with ListBox style. You can send messages to this window, so:For native listbox control_SendMessage(GuiCtrlGetHandle($hListBox), $LB_GETCURSEL) ;Or GUICtrlSendMsg($hWnd, $LB_GETCURSEL, 0, 0)for UDF listbox_SendMessage($hListBox, $LB_GETCURSEL) 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