idbirch Posted September 2, 2008 Share Posted September 2, 2008 Is it possible to get a ListBox to behave like Windows Explorer does with files? i.e rather than just letting multiple items be clicked, make it so ctrl has to be held down? Also, it would be nice if all other items were deselected when clicking an item without Ctrl held down. Can any of this be done? Thanks. Link to comment Share on other sites More sharing options...
Nahuel Posted September 2, 2008 Share Posted September 2, 2008 (edited) Use the $LVS_EX_FULLROWSELECT ex-style as STYLE when creating the listview. Here's an example: #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> $Form1 = GUICreate("Form1", 288, 399, 193, 125) $ListView1 = GUICtrlCreateListView("Example items|another col", 10, 14, 259, 351,$LVS_EX_FULLROWSELECT);Note that it's not in the ex-style parameter GUICtrlCreateListViewItem("Item 1|Itemmm",$ListView1) GUICtrlCreateListViewItem("Item 2|Itemmm",$ListView1) GUICtrlCreateListViewItem("Item 3|Itemmm",$ListView1) GUICtrlCreateListViewItem("Item 4|Itemmm",$ListView1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Note that you can also select many of them by dragging the cursor from below and selecting an area like you do in windows explorer. So it does everything you want and more Edited September 2, 2008 by Nahuel Link to comment Share on other sites More sharing options...
smashly Posted September 2, 2008 Share Posted September 2, 2008 Use the $LVS_EX_FULLROWSELECT ex-style as STYLE when creating the listview. Here's an example: #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> $Form1 = GUICreate("Form1", 288, 399, 193, 125) $ListView1 = GUICtrlCreateListView("Example items|another col", 10, 14, 259, 351,$LVS_EX_FULLROWSELECT);Note that it's not in the ex-style parameter GUICtrlCreateListViewItem("Item 1|Itemmm",$ListView1) GUICtrlCreateListViewItem("Item 2|Itemmm",$ListView1) GUICtrlCreateListViewItem("Item 3|Itemmm",$ListView1) GUICtrlCreateListViewItem("Item 4|Itemmm",$ListView1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Note that you can also select many of them by dragging the cursor from below and selecting an area like you do in windows explorer. So it does everything you want and more I don't think it's what the op is after, I could be wrong but the op mentions a Listbox, Ctrl key and multiselect... Also you left a parameter out, your using the EX_Style in the Style parameters space$ListView1 = GUICtrlCreateListView("Example items|another col", 10, 14, 259, 351,$LVS_EX_FULLROWSELECT);Note that it's not in the ex-style parameteroÝ÷ Ù(hºW[y«¢+ØÀÌØí1¥ÍÑY¥ÜÄôU% Ñɱ ÉÑ1¥ÍÑY¥Ü ÅÕ½ÐíáµÁ±¥ÑµÍñ¹½Ñ¡È½°ÅÕ½Ðì°ÄÀ°ÄаÈÔä°ÌÔÄ°´Ä°ÀÌØí1YM}a}U11I=]M1 P¤ Cheers Link to comment Share on other sites More sharing options...
idbirch Posted September 3, 2008 Author Share Posted September 3, 2008 That's right smashly, I'm using GUICtrlCreateList, not GUICtrlCreateListView. Thanks though Nahuel. Any other suggestions? Link to comment Share on other sites More sharing options...
picaxe Posted September 3, 2008 Share Posted September 3, 2008 Something like $ListBox = GUICtrlCreateList("", 5, 5, 100, 200, BitOR($LBS_MULTIPLESEL, $LBS_EXTENDEDSEL)) Link to comment Share on other sites More sharing options...
Nahuel Posted September 3, 2008 Share Posted September 3, 2008 Also you left a parameter out, your using the EX_Style in the Style parameters space AutoIt$ListView1 = GUICtrlCreateListView("Example items|another col", 10, 14, 259, 351,$LVS_EX_FULLROWSELECT);Note that it's not in the ex-style parameter Should be AutoIt$ListView1 = GUICtrlCreateListView("Example items|another col", 10, 14, 259, 351, -1, $LVS_EX_FULLROWSELECT) Cheers Well... if you do it the way you say, it doesn't work. It doesn't allow multiselect and doesn't do what the op wanted. That's why I said: Use the $LVS_EX_FULLROWSELECT ex-style as STYLE Link to comment Share on other sites More sharing options...
idbirch Posted September 3, 2008 Author Share Posted September 3, 2008 Something like $ListBox = GUICtrlCreateList("", 5, 5, 100, 200, BitOR($LBS_MULTIPLESEL, $LBS_EXTENDEDSEL))That's it! I feel a bit of a fool now as it's so simple. I hadn't found the $LBS_EXTENDEDSEL style as I was looking at the GUICtrlCreateList article in the help file. Now you've shown me the name of the style I need, I've found it in the help file under _GUICtrlListBox_Create. I added the style to GUICtrlCreateList and it works fine so why is it not mentioned under the GUICtrlCreateList section of the help file? Anyway, nevermind that, thanks very much for your help. Link to comment Share on other sites More sharing options...
picaxe Posted September 3, 2008 Share Posted September 3, 2008 To get ListView multiple select you must disable the AutoIt default syle $LVS_SINGLESEL (0x4) bit flag. Extended style $LVS_EX_FULLROWSELECT (0x20) works as a style param because it clears bit 2, but it is effectively style $LVS_SORTDESCENDING. So something like $ListView1 = GUICtrlCreateListView("Example items|another col", 10, 14, 259, 351, 0, $LVS_EX_FULLROWSELECT)oÝ÷ ÚÚºÚ"µÍÌÍÓÝY]ÌHHÕRPÝÜX]SÝY]Ê ][ÝÑ^[H][ß[ÝÛÛ ][ÝËLMNKÍLK]Ü ÌÍÓ×ÔTÔ ÌÍÓ×ÔÒÕÔÑSSÐVTÊK ÌÍÓ×ÑVÑSÕÔÑSPÕ Maybe AutoIt help should mention this. 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