Jump to content

Multiple selection return value


Recommended Posts

Ok, with GUI-commands I think it's not possible.

But maybe it's possible to modify the GUIRead()-function a little bit so that the return value could be a single- or multiline value.

Like in RegRead:

When reading a REG_MULTI_SZ key the multiple entries are seperated by @LF - use with StringSplit(..., @LF) to get each entry.

I try to test it in the later evening....

Regards Holger :ph34r:

Link to comment
Share on other sites

Hi redndahead,

here is just a small example to show how I use the LB_GET...stuff for multiple selects.

$LBS_EXTENDEDSEL = 0x800
FileChangeDir(@ScriptDir)
GUICreate("Title", 220, 300)
$listbox1 = GuiSetControl ("list", "", 10,10,200,200,$LBS_EXTENDEDSEL)
GUISetControlData($listbox1,"Item1|Item2|Item3|Item4|Item5|Item6")

$OK = GUISetControl ("button", "OK", 10,200,100,20)
GuiSetControlNotify()
;-------------------------------------------------

GuiShow()
While GUIMsg() <> -3
$msg = GuiRead()

Select

case $msg = $OK

$LB_GETCOUNT = 0x0000018B
$LB_GETSELCOUNT = 0x00000190
$LB_GETSEL = 0x00000187
$LB_GETTEXT = 0x00000189

$n = GUISendMsg($listbox1, $LB_GETCOUNT ,0, 0);count all items
$n_sel = GUISendMsg($listbox1, $LB_GETSELCOUNT ,0, 0);count selected items

;-----------------------
If $n_sel > 0 Then

DIM $arr_sel_names[$n_sel]

$i_sel = 0
for $i = 0 to $n-1
$selected = GUISendMsg($listbox1, $LB_GETSEL ,$i, 1);get state of each item
IF $selected = 1 Then
$arr_sel_names[$i_sel] = GUIRecvMsg($listbox1, $LB_GETTEXT ,$i, 1);if state is 1 (Item selected) get name of item and put into array
$i_sel = $i_sel + 1
EndIf

Next
;-----------------------

;---Output---------------------
$output = ""
For $i = 0 to Ubound($arr_sel_names)-1
$output = $output & $arr_sel_names[$i] & @CRLF
Next
MsgBox (0, "Selected Items:", $output)


EndIf

;-------------------------------------------------------------

EndSelect
Wend

arctor

Link to comment
Share on other sites

I tried running this wrapper and I get an error that on line 41 $LB_GETCOUNT is not declared but checking above it looks like  you declared it just fine.  Any thoughts?

red

:ph34r: What version of AutoIt?

At least Arctor's example should work for you if mine doesn't

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

  • 2 years later...

Nevermind. I found the UDF documentation at the end of the help file contents. Now working on the ADFunctions ADTools.au3, adapting it to allow me to change multiple users' properties while I'm waiting to upgrade to server 2003 in a year and a half...

Jeff

Hi Arctor-

I tried running your sample code below, but many of the commands seem to be wrong. Is this written in AutoIT3 or is it pseudo code? For example I can't find any of these in the help files:

GuiSetControl, GuiSetControlData, GuiShow, GuiSendMsg, GuiRecvMsg....

Can you please translate?

Thanks!

Hi redndahead,

here is just a small example to show how I use the LB_GET...stuff for multiple selects.

$LBS_EXTENDEDSEL = 0x800
FileChangeDir(@ScriptDir)
GUICreate("Title", 220, 300)
$listbox1 = GuiSetControl ("list", "", 10,10,200,200,$LBS_EXTENDEDSEL)
GUISetControlData($listbox1,"Item1|Item2|Item3|Item4|Item5|Item6")

$OK = GUISetControl ("button", "OK", 10,200,100,20)
GuiSetControlNotify()
;-------------------------------------------------

GuiShow()
While GUIMsg() <> -3
$msg = GuiRead()

Select

case $msg = $OK

$LB_GETCOUNT = 0x0000018B
$LB_GETSELCOUNT = 0x00000190
$LB_GETSEL = 0x00000187
$LB_GETTEXT = 0x00000189

$n = GUISendMsg($listbox1, $LB_GETCOUNT ,0, 0);count all items
$n_sel = GUISendMsg($listbox1, $LB_GETSELCOUNT ,0, 0);count selected items

;-----------------------
If $n_sel > 0 Then

DIM $arr_sel_names[$n_sel]

$i_sel = 0
for $i = 0 to $n-1
$selected = GUISendMsg($listbox1, $LB_GETSEL ,$i, 1);get state of each item
IF $selected = 1 Then
$arr_sel_names[$i_sel] = GUIRecvMsg($listbox1, $LB_GETTEXT ,$i, 1);if state is 1 (Item selected) get name of item and put into array
$i_sel = $i_sel + 1
EndIf

Next
;-----------------------

;---Output---------------------
$output = ""
For $i = 0 to Ubound($arr_sel_names)-1
$output = $output & $arr_sel_names[$i] & @CRLF
Next
MsgBox (0, "Selected Items:", $output)
EndIf

;-------------------------------------------------------------

EndSelect
Wend

arctor

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...