kwibus Posted February 14, 2016 Share Posted February 14, 2016 Hi, I am learning AutoIt, and I find this "SQlite Browser" a nice example to try out my skills this far. Although the last addition to this subject is now exactly 8 years old! I have cut out a part that does not work for me: my question, simply "why doesn't this work?". I get the message: "0 item(s) selected". And there is no text read, as a consequence. ; select from a list #include <GUIConstants.au3> #include <GuiListbox.au3> $gui_Form = GUICreate("SQLite Browser test", 622, 460, 199, 135, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) $gui_Tables = GUICtrlCreateList("", 8, 8, 121, 318, -1, $WS_EX_CLIENTEDGE) $hGui_Tables = ControlGetHandle($gui_Form, "", $gui_Tables) _GUICtrlListBox_AddString($hGui_Tables, "Item 1") _GUICtrlListBox_AddString($hGui_Tables, "Item 2") _GUICtrlListBox_AddString($hGui_Tables, "Item 3") $btn = GUICtrlCreateButton("&Test", 8, 330, 121) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn $a = _GUICtrlListBox_GetSelItemsText($hGui_Tables) MsgBox(0, "", $a[0] & " item(s) selected") EndSelect WEnd Can someone help? What is wrong with this code? Link to comment Share on other sites More sharing options...
AutoBert Posted February 14, 2016 Share Posted February 14, 2016 This is not a SQLite specific problem. Test this: ; select from a list #include <GUIConstants.au3> #include <GuiListbox.au3> $gui_Form = GUICreate("SQLite Browser test", 622, 460, 199, 135, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX)) $gui_Tables = GUICtrlCreateList("", 8, 8, 121, 318, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL), $WS_EX_CLIENTEDGE) $hGui_Tables = ControlGetHandle($gui_Form, "", $gui_Tables) _GUICtrlListBox_AddString($hGui_Tables, "Item 1") _GUICtrlListBox_AddString($hGui_Tables, "Item 2") _GUICtrlListBox_AddString($hGui_Tables, "Item 3") $btn = GUICtrlCreateButton("&Test", 8, 330, 121) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn $a = _GUICtrlListBox_GetSelItemsText($hGui_Tables) MsgBox(0, "", $a[0] & " item(s) selected") EndSelect WEnd In 8 years AutoIt UDFs are changing in syntax. In the actual stable you can also use the ControlID ($gui_Tables) instead of the Handle ($hGui_Tables) for using the functions of GuiListBox.au3. Link to comment Share on other sites More sharing options...
kwibus Posted February 14, 2016 Share Posted February 14, 2016 @AutoBert OK, thank you. I see: - I understand that this is not SQLite specific. - the $LBS_STANDARD and $LBS_EXTENDEDSEL styles are needed for the reading of selected item(s) to be enabled. - the handle $hGui_Tables is not really needed. Ad 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