SlimShady Posted January 10, 2005 Share Posted January 10, 2005 I applied the style to the listbox and it works. Now... How do you retrieve/use/find out all selected items? I tried GUICtrlSendMsg, doesn't work. Then I searched a bit and I saw that this-is-me often uses DllCall instead of GUICtrlSendMsg. So I tried the same method using DllCall. The problem is, is that the specific function needs a pointer to an array. I knew in advance this wouldn't work: expandcollapse popup#include <GUIConstants.au3> AutoItSetOption("TrayIconDebug", 1) ;Initialize variables Global $style1 Global $IniFile Global $GUIWidth Global $GUIHeight $GUIWidth = 300 $GUIHeight = 250 $IniFile = StringTrimRight(@ScriptFullPath, 3) & "ini" GUICreate("Synchro - Under Construction", $GUIWidth, $GUIHeight) $LBS_MULTIPLESEL = 0x0008 $MissFileList = GUICtrlCreateList("", 10, 5, 280, 200, $LBS_MULTIPLESEL) $Del_Btn = GUICtrlCreateButton("Delete", 20, 210, 70, 25) $Copy_Btn = GUICtrlCreateButton("Copy", 115, 210, 70, 25) $EXIT_Btn = GUICtrlCreateButton("Exit", 210, 210, 70, 25) GUICtrlSetData($MissFileList, "Item 0|Item 1|Item 2|Item 3|Item 4|Item 5|Item 6|Item 7|Item 8|Item 9") GUISetState(@SW_SHOW) While 1 Sleep(25) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE OR $msg = $EXIT_Btn GUIDelete() Exit Case $msg = $Del_Btn Dim $SelItems_buffer[10] $LB_GETSELITEMS = 0x0191 $Items = DllCall("user32.dll", "int", "SendMessage", "hWnd", $MissFileList, "int", $LB_GETSELITEMS, "int", 10, "ptr", $SelItems_buffer) If UBound($Items) > 1 Then For $i = 0 To UBound($Items) - 1 MsgBox(64, "Test", "$Items[" & $i & "] = " & $Items[$i]) Next Else MsgBox(64, "Debug Test", "Return value: " & @CRLF & $Items[0]) EndIf EndSelect WEnd I get strange results back. Random numbers in the $Items array. I'll do some more tests but I don't think I can make this work. What about you? Can you help me? Link to comment Share on other sites More sharing options...
CyberSlug Posted January 10, 2005 Share Posted January 10, 2005 I am going to look into the LB_GETSELITEMS... but for now, here is a workaround for you...Let me know if you can get this working.... I use the same workaround because LB_GETSELITEMS returns an array pointer or something. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
DirtyBanditos Posted January 10, 2005 Share Posted January 10, 2005 I applied the style to the listbox and it works.Now... How do you retrieve/use/find out all selected items?I tried GUICtrlSendMsg, doesn't work.Then I searched a bit and I saw that this-is-me often uses DllCall instead of GUICtrlSendMsg.So I tried the same method using DllCall. The problem is, is that the specific function needs a pointer to an array.I knew in advance this wouldn't work:Hi SlimShady nice script ,good to learn dll call on Autoit Thx to Share it out! Link to comment Share on other sites More sharing options...
SlimShady Posted January 10, 2005 Author Share Posted January 10, 2005 @Larry: Thanks for the help. @DirtyBanditos: My script doesn't work you know (the one I posted above). Link to comment Share on other sites More sharing options...
HighGuy Posted January 10, 2005 Share Posted January 10, 2005 Why are you using DllCall for finding all selected ListBox-Items? Isn't the ControlListView()-function doing what you want it to do? Have a look at the documentation and use ControlListView() with the command "GetSelected". Link to comment Share on other sites More sharing options...
SlimShady Posted January 10, 2005 Author Share Posted January 10, 2005 (edited) Hello? Did you read the title: Multiple selection ListboxFrom Microsoft.com:The Windows Forms ListView control displays a list of items with icons. You can use a list view to create a user interface like the right pane of Windows Explorer. Edited January 10, 2005 by SlimShady Link to comment Share on other sites More sharing options...
HighGuy Posted January 10, 2005 Share Posted January 10, 2005 Hello? Did you read the title: Multiple selection ListboxAh, I see . So we need a ControlList(Box)-function Link to comment Share on other sites More sharing options...
SlimShady Posted January 10, 2005 Author Share Posted January 10, 2005 Not necessarily. An addition to ControlCommand would be nice. Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 10, 2005 Administrators Share Posted January 10, 2005 yes... but the array it returns is defined completely differently than the array that you are used to in AutoIt. At this moment AutoIt is incompatible with this Sendmessage use. Also, you may have noticed I retrieve the $hwnd for the control... I don't think GUICreateCtrl returns a hWnd...Lar.It returns a Control ID, so you could get the handle with something likeControlGetHandle($myGuiHwnd, "", $controlID)Also of interest is the control IDs that the CtrlCreate functions return _are_ the same as the ones you read in au3spy. How cosy. Deployment Blog:Â https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming:Â https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
SlimShady Posted January 15, 2005 Author Share Posted January 15, 2005 I accidentally deleted my version of the GetSelected function. I just remade it. I'll post it here just in case. Func GetSelected($Ctrl_ID) Local $LB_GETSEL = 0x0187 Local $LB_GETCOUNT = 0x018B Local $total_items, $list, $sel, $i $total_items = GUICtrlSendMsg($Ctrl_ID, $LB_GETCOUNT, 0, 0) If $total_items < 1 Then Return StringSplit($list, ",") For $i = 0 To $total_items - 1 $sel = GUICtrlSendMsg($Ctrl_ID, $LB_GETSEL, $i, 0) If $sel Then $list = $list & $i & "," Next Return StringSplit(StringTrimRight($list, 1), ",") EndFunc Link to comment Share on other sites More sharing options...
SlimShady Posted January 17, 2005 Author Share Posted January 17, 2005 *I don't feel like opening amnother topic...* I have a script that uses my ListItemRename function with a multi-select List Box. It doesn't work. So I made a "small" test script and it still doesn't work. Then I changed the list box (and other things) to single-select. And it worked. Could you please check it out. It could be a bug. I can't remember if it worked yesterday or the day before. Test script is attached. Thanks in advance. Link to comment Share on other sites More sharing options...
SlimShady Posted January 18, 2005 Author Share Posted January 18, 2005 Really strange: I used DllCall+SendMessage with the same values and it worked. I'll attach the script. The ListItemRename UDF contains both methods so you can take a look. 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