Jump to content

List of checkboxes?


Overkill
 Share

Recommended Posts

I'm writing a script that will allow a user to select which file(s) of several hundred that they want to use. Is there any way to create a list of checkboxes so that I have plenty of room left in my GUI for other things?

Sorry if I'm not making sense, I'll try and elaborate further at a later time....need sleep...

Link to comment
Share on other sites

  • Moderators

Overkill,

Use a ListBox to list the files. Multiple selections are allowed if required.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Overkill,

Use a ListBox to list the files. Multiple selections are allowed if required.

M23

I can't select multiple files using GUICtrlCreateList, and I don't see anything in the sytles/extended styles on how to do it.

Now that I've had plenty of sleep, I'll tell you what I have so far:

FileList("directory" [,include subdirectories[,"file type"]]) - a UDF I wrote for this app, returns an array.

$array[0] is the number of files found, $array[1] to $array[$array[0]] are strings that give the full path of files that match the query.

$dir = "C:\Music\Skindred"
$FileList = Filelist($dir,1,"mp3")

GUICreate("GUI",482,302)
GUISetState()
$list=GUICtrlCreateList("",1,1,480,300)

For $i=1 to $test[0]
     If $FileList[$i]<>"" Then GUICtrlSetData($list,FileList[$i])
Next

While 1
    $m = GUIGetMsg()
    If $m = $GUI_EVENT_CLOSE Then Exit
WEnd
Edited by Overkill
Link to comment
Share on other sites

I can't select multiple files using GUICtrlCreateList, and I don't see anything in the sytles/extended styles on how to do it.

Now that I've had plenty of sleep, I'll tell you what I have so far:

FileList("directory" [,include subdirectories[,"file type"]]) - a UDF I wrote for this app, returns an array.

$array[0] is the number of files found, $array[1] to $array[$array[0]] are strings that give the full path of files that match the query.

$dir = "C:\Music\Skindred"
$FileList = Filelist($dir,1,"mp3")

GUICreate("GUI",482,302)
GUISetState()
$list=GUICtrlCreateList("",1,1,480,300)

For $i=1 to $test[0]
     If $FileList[$i]<>"" Then GUICtrlSetData($list,FileList[$i])
Next

While 1
    $m = GUIGetMsg()
    If $m = $GUI_EVENT_CLOSE Then Exit
WEndoÝ÷ Ûú®¢×ºÚ"µÍÚ[ÛYH    ÑÕRPÛÛÝ[Ñ^]LÉÝÂÚ[ÛYH ÕÚ[ÝÜÐÛÛÝ[Ë]LÉÝÂÚ[ÛYH ÑÝZPÛÛÝ[Ñ^]LÉÝÂÚ[ÛYH ÑÝZSÝY]Ë]LÉÝÂÌÍÙH ][ÝÐÎÌLÓ]ÚXÉÌLÔÚÚ[Y  ][ÝÂÌÍÑ[SÝHÑ[[Ý
    ÌÍÙ  ][ÝÛÉ][ÝÊBÕRPÜX]J    ][ÝÑÕRI][ÝË
ÌBÕRTÙ]Ý]J
BÌÍÛÝQÕRPÝÜX]SÝY]Ê ][ÝÉ][ÝËKK
Ì
BÑÕRPÝÝY]×ÔÙ]^[YÝY]ÔÝ[J   ÌÍÛÝÂ]Ô   ÌÍÓ×ÑVÑÔQSTË    ÌÍÓ×ÑVÐÔTÑSPÕÂÌÍÓ×ÑVÐÒPÒÐÖTÈ
JBÑÕRPÝÝY]×Ò[ÙÛÛ[[ ÌÍÛÝ    ][ÝÑ[[Ý  ][ÝË

ÍJBYÐ^J   ÌÍÑ[SÝ
H[Ü    ÌÍÚHHHÈ ÌÍÑ[SÝÌHÝBÑÕRPÝÝY]×ÐY][J    ÌÍÛÝ    ÌÍÑ[SÝÉÌÍÒWK    ÌÍÒHHJB^[YÚ[HB  ÌÍÛHHÕRQÙ]ÙÊ
BY  ÌÍÛHH    ÌÍÑÕRWÑUSÐÓÔÑH[^]Ñ[[ÈÑ[[Ý
    ÌÍÑT ÌÍÙ^[Ú[ÛBØØ[ ÌÍÛÝÌWBÌÍÛÝÌHH[PÚ[ÙQ
    ÌÍÑT
BÌÍÜÙXÚH[Q[Ý[J    ][ÝÊ][ÝÈ    [È ÌÍÙ^[Ú[ÛHY ÌÍÜÙXÚHLH[]LBÚ[HB ÌÍÙ[HH[Q[^[J ÌÍÜÙXÚ
HYÜ[^]ÛÜQ[H  ÌÍÛÝÉÌÍÛÝÌH
ÈBIÌÍÛÝÉÌÍÛÝÌH
ÈWHH   ÌÍÙ[BIÌÍÛÝÌHH   ÌÍÛÝÌH
ÈBÑ[[PÚ[ÙQ
ØÜ
B]  ÌÍÛÝ[[

صرح السماء كان هنا

 

Link to comment
Share on other sites

  • Moderators

Overkill,

I said ListBox, not List.

An example:

#include <GuiConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListBoxConstants.au3>
#include <WindowsConstants.au3>

Global $aSelected[1]

Global $hGUI = GUICreate("FLV Processing", 200, 180)
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

Global $hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 10, 30, 180, 90, BitOR($WS_BORDER, $LBS_HASSTRINGS, $LBS_MULTIPLESEL))

_GUICtrlListBox_BeginUpdate($hListBox)
_GUICtrlListBox_ResetContent($hListBox)
_GUICtrlListBox_InitStorage($hListBox, 100, 4096)
_GUICtrlListBox_EndUpdate($hListBox)

_GUICtrlListBox_AddString($hListBox,"Tom")
_GUICtrlListBox_AddString($hListBox,"Dick")
_GUICtrlListBox_AddString($hListBox,"Harry")

Global $hButton = GUICtrlCreateButton("Select", 60, 130, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $hButton;$guimsg; = 
            $aSelected = _GUICtrlListBox_GetSelItems($hListBox)
            If $aSelected[0] = 1 Then
                $sItem = " item"
            Else
                $sItem = " items"
            EndIf
            MsgBox(0, "", "You Chose " & $aSelected[0] & $sItem)
            $sItems = ''
            For $i = 1 To $aSelected[0]
                $sItems &= "Item Index: " & $aSelected[$i] & " - Item Text: " & _GUICtrlListBox_GetText($hListBox,$aSelected[$i]) & @CRLF
            Next
            MsgBox(4160, "Information", $sItems)
        
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks wolf =)

This works, minus a couple of details (which I worked around in my UDF before posting):

1) I often need to list all contents of a subdirectory with the same function. I already wrote the UDF, but I learned a better method of defining the array by seeing your example so thanks =)

2) I need the full path, not just the file name (though one of my goals is to display only the file names, w/o extensions or paths...probably using StringInStr + StringMid).

I also need a way to figure out how to determine which boxes are checked; having a difficult time with that. GUICtrlRead($list) is giving me a 0.

Goal of app:

I format my HDD's music differently than I do on my MP3 player, MP3 DVDs, etc.

On my HDD: \Music\Artist\Album\Track - Title (Album - Artist).mp3

Elsewhere: \Artist\Title (Album - Artist).mp3

App will control which files to copy (the reason for the checkboxes), the renaming process, etc.

Also, to everybody, thanks for being an awesome community =) It's good to know I can come here when I'm stuck and somebody can throw an idea at me to get things rolling again :)

------

EDIT:

You posted while I was typing, M...grr!

Let me digest your post and I'll edit again.

Also, I couldn't find ListBox in the help file so I started with list =)

------

EDIT:

M - Your idea was right on the money...not the 'ideal' GUI that I wanted but it will certainly accomplish what I need it to.

TO DO: (I'll work on these on my own and if I need help I'll reply here)

Format list to show partial path or only file name

Multiple tabs (one per artist)

Options menu

Save selections to INI file

Other features I haven't thought of yet

Edited by Overkill
Link to comment
Share on other sites

  • Moderators

Overkill,

I hope you do not have any more problems, but if you do I would suggest opening a new thread unless it is very closely associated with the ListBox problems we have been discussing here. It helps others when they search (should any of them ever do such a weird thing!) if separate problems are dealt with in different threads.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Overkill,

I hope you do not have any more problems, but if you do I would suggest opening a new thread unless it is very closely associated with the ListBox problems we have been discussing here. It helps others when they search (should any of them ever do such a weird thing!) if separate problems are dealt with in different threads.

M23

Noted.

Link to comment
Share on other sites

Well, here's a listbox problem:

The listbox is not behaving well when I try to use it in a tab:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIListBox.au3>
#include <ListBoxConstants.au3>
#include <OvKFileList.au3>
#include <TabConstants.au3>

Opt("TrayIconDebug",1)

$FileList = FileList("C:\Music\Skindred",1,"mp3")
$mbtext=""
For $i=1 to $FileList[0]
    $mbtext&=$FileList[$i] & @CRLF
Next
MsgBox(0,"",$mbtext)
$MAINGUI = GUICreate("FileList GUI",482,302)
GUISetState()
GUICtrlCreateTab(1,1,480,300,BitOr($GUI_SS_DEFAULT_TAB,$TCS_BUTTONS,$TCS_MULTILINE,$TCS_RIGHTJUSTIFY))
$MAINTAB = GUICtrlCreateTabItem("Main Tab")
GUICtrlCreateButton("Test",1,22)

GUICtrlCreateTabItem("Second Tab")

$hListBox = _GUICtrlListBox_Create($MAINGUI, "42", 90, 25, 300, 200, BitOR($LBS_HASSTRINGS, $LBS_MULTIPLESEL))

_GUICtrlListBox_BeginUpdate($hListBox)
_GUICtrlListBox_ResetContent($hListBox)
_GUICtrlListBox_InitStorage($hListBox, $FileList[0], 102400)
_GUICtrlListBox_EndUpdate($hListBox)

For $i=1 to $FileList[0]
_GUICtrlListBox_AddString($hListBox,$FileList[$i])
Next

$b1 = GUICtrlCreateButton("List",6,212,45,25)

While 1
    $m = GUIGetMsg()
    If $m = $GUI_EVENT_CLOSE Then Exit
    If $m = $b1 Then
        $sItems = ''
        $items = _GUICtrlListBox_GetSelItems($hListBox)
        For $i = 1 To $items[0]
                $sItems &= "Item Index: " & $items[$i] & " - Item Text: " & _GUICtrlListBox_GetText($hListBox,$items[$i]) & @CRLF
        Next
        MsgBox(4160, "Information", $sItems)
    EndIf
WEnd

OvKFileList.au3

Edited by Overkill
Link to comment
Share on other sites

  • Moderators

Overkill,

It does not look as if you can create ListBoxes in tabs. Every time I tried to use the ControlID of a tab I got an error. It seems it will only work with a "proper" GUI ID, which makes it part of the window and not the tab. That is what you get (sometimes) when you use UDFs and not the builtin commands.

So 2 choices: Change your GUI, or wait until (or if!) one of the gurus comes up with a solution. I know which I would do!

By the way, you had not closed your tabs properly - you need to add the line GUICtrlCreateTabItem("") when you have finished defining the tabs and items. In this case it did not matter because you did not create any more controls, but in a longer script you could find strange errors occuring and you wondering what is going on!

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Overkill,

It does not look as if you can create ListBoxes in tabs. Every time I tried to use the ControlID of a tab I got an error. It seems it will only work with a "proper" GUI ID, which makes it part of the window and not the tab. That is what you get (sometimes) when you use UDFs and not the builtin commands.

So 2 choices: Change your GUI, or wait until (or if!) one of the gurus comes up with a solution. I know which I would do!

By the way, you had not closed your tabs properly - you need to add the line GUICtrlCreateTabItem("") when you have finished defining the tabs and items. In this case it did not matter because you did not create any more controls, but in a longer script you could find strange errors occuring and you wondering what is going on!

M23

Well, if I could use the ListView approach wolf posted to select songs and somehow differentiate between checked/unchecked items, I'd be set :)

Thanks for pointing out the tab closing...I knew that just totally skipped my mind.

Link to comment
Share on other sites

  • Moderators

Overkill,

The only way i have found to get multiple selected items in a ListView is to do this:

Set up the ListView and then GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY"):

Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    
    Local $tNMHDR
    
    If $wParam = $hList Then 
        $tNMHDR = DllStructCreate("int;int;int", $lParam)
        If @error Then Return
        If DllStructGetData($tNMHDR, 3) = $NM_CLICK Then $fClick = True
        $tNMHDR = 0
    EndIf
    
EndFunc

Then when you click on an item in the ListBox, the NOTIFY function sets $fClick to True and in your main loop you do something like this:

If $fClick Then
; Get index number of clicked item
    Global $iIndex =  _GUICtrlListView_GetHotItem($hList)
; Highlight item
    _GUICtrlListView_SetItemDropHilited($hList, $iIndex)

; Here you need to store the index - up to you how you do this!

; Reset flag
    $fClick = False
EndIf

Once you are ready to go, loop through the stored indices and use _GUICtrlListView_GetItemText($hList, $iIndex) to get the values (or do it directly in the loop above)

When all is done, you need to clear the highlighting - I have found the best way is to empty the ListBox with _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hIncudeList)) - note you do need the double function - and then refill it.

Rather a roundabout way, but it is the only one I have ever found. There is a _GUICtrlListView_GetSelectedIndices function, but I have never got it to work - it only returns the last selected item even if I use _GUICtrlListView_SetItemSelected each time in the loop above. Beats me - but then so do a lot of things!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks a ton!

Without getting philosophical, all I can say is that fewer things beat you than beat me =) At least when it comes to AutoIt :)

I'm not sure if this will be able to accomplish my goal entirely, but we'll see...we'll see. I'll play around with it for a bit and see what I come up with.

Link to comment
Share on other sites

I was looking at GUICtrlRead() and saw something interesting, so I decided to revisit it and put together some sample code...still trying to make it work. Thoughts, comments, criticism?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
#include <ListviewConstants.au3>

$MAINGUI = GUICreate("FileList GUI",482,302)
GUISetState()

$listview = GUICtrlCreateListView("test",5,40,470,200)
_GUICtrlListView_SetExtendedListViewStyle(-1, BitOR($LVS_EX_BORDERSELECT , $LVS_EX_CHECKBOXES ))
_GUICtrlListView_InsertColumn(-1, 0, "Filelist", 465)
_GUICtrlListView_DeleteColumn("", 1)

$button = GUICtrlCreateButton("Button",5,260,100,25)

Dim $item[6]
$item[0] = 5
$item[1] = GUICtrlCreateListViewItem("1 of 5",$listview)
$item[2] = GUICtrlCreateListViewItem("2 of 5",$listview)
$item[3] = GUICtrlCreateListViewItem("3 of 5",$listview)
$item[4] = GUICtrlCreateListViewItem("4 of 5",$listview)
$item[5] = GUICtrlCreateListViewItem("5 of 5",$listview)

While 1
    $m = GUIGetMsg()
    If $m = $GUI_EVENT_CLOSE Then Exit
    If $m = $button Then
        For $i=1 to $item[0]
            ConsoleWrite("Item " & $i & " of " & $item[0] & ": ")
            ConsoleWrite(BitAND($GUI_UNCHECKED,GUICtrlRead($item[$i])) & @CRLF)
            Next
    EndIf
WEnd
Link to comment
Share on other sites

  • Moderators

Overkill,

Cannot help with the "checkbox" problem for the moment - I agree it is a very strange response. I will let you know how I get on.

However, I have at last worked out how to make multiple selections in a ListView. You need to keep the Ctrl key pressed while making the selections - then AutoIt keeps the selected items highlighted automatically and _GUICtrlListView_GetSelectedIndices works as advertised. The way I described above is more complicated, but does not require the Ctrl key to be pressed at all.

So, one down and another to go - no rest for the wicked!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Why don't you try GUICtrlCreateTreeView with TreeViewItems with checkbox-style?

A feasible option, but definitely not how I'd like to do things. I ... strongly dislike ... tree views.

Also, I expect it to work out like ListView + Checkboxes

Edited by Overkill
Link to comment
Share on other sites

  • Moderators

Overkill,

Solved the ListView and $LVS_EX_CHECKBOXES problem. You have to use the "advanced" parameter for GUICtrlRead - look in Help file for more explanation. I also had to change your ListBox creation code to get it to work properly:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
#include <ListviewConstants.au3>

$MAINGUI = GUICreate("FileList GUI",482,302)
GUISetState()

$listview = GUICtrlCreateListView("Filelist",5,40,470,200, -1, $LVS_EX_CHECKBOXES )
_GUICtrlListView_SetColumnWidth($listview, 0, $LVSCW_AUTOSIZE_USEHEADER)

$button = GUICtrlCreateButton("Button",5,260,100,25)

Dim $item[6]
$item[0] = 5
$item[1] = GUICtrlCreateListViewItem("1 of 5",$listview)
$item[2] = GUICtrlCreateListViewItem("2 of 5",$listview)
$item[3] = GUICtrlCreateListViewItem("3 of 5",$listview)
$item[4] = GUICtrlCreateListViewItem("4 of 5",$listview)
$item[5] = GUICtrlCreateListViewItem("5 of 5",$listview)

While 1
    $m = GUIGetMsg()
    If $m = $GUI_EVENT_CLOSE Then Exit
    If $m = $button Then
        For $i=1 to $item[0]
            If BitOR(GUICtrlRead($item[$i], 1), $GUI_CHECKED) = $GUI_CHECKED Then
                ConsoleWrite("Item " & $i & " - Checked" & @CRLF)
            Else
                ConsoleWrite("Item " & $i & " - Unchecked" & @CRLF)
            EndIf
        Next
    EndIf
WEnd

That now works perfectly for me.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Overkill,

Solved the ListView and $LVS_EX_CHECKBOXES problem. You have to use the "advanced" parameter for GUICtrlRead - look in Help file for more explanation. I also had to change your ListBox creation code to get it to work properly:

#include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <EditConstants.au3>
 #include <GuiListView.au3>
 #include <ListviewConstants.au3>
 
 $MAINGUI = GUICreate("FileList GUI",482,302)
 GUISetState()
 
 $listview = GUICtrlCreateListView("Filelist",5,40,470,200, -1, $LVS_EX_CHECKBOXES )
 _GUICtrlListView_SetColumnWidth($listview, 0, $LVSCW_AUTOSIZE_USEHEADER)
 
 $button = GUICtrlCreateButton("Button",5,260,100,25)
 
 Dim $item[6]
 $item[0] = 5
 $item[1] = GUICtrlCreateListViewItem("1 of 5",$listview)
 $item[2] = GUICtrlCreateListViewItem("2 of 5",$listview)
 $item[3] = GUICtrlCreateListViewItem("3 of 5",$listview)
 $item[4] = GUICtrlCreateListViewItem("4 of 5",$listview)
 $item[5] = GUICtrlCreateListViewItem("5 of 5",$listview)
 
 While 1
     $m = GUIGetMsg()
     If $m = $GUI_EVENT_CLOSE Then Exit
     If $m = $button Then
         For $i=1 to $item[0]
             If BitOR(GUICtrlRead($item[$i], 1), $GUI_CHECKED) = $GUI_CHECKED Then
                 ConsoleWrite("Item " & $i & " - Checked" & @CRLF)
             Else
                 ConsoleWrite("Item " & $i & " - Unchecked" & @CRLF)
             EndIf
         Next
     EndIf
 WEnd

That now works perfectly for me.

M23

BEAUTIFUL!

Now I have to go work back through my code, remember what it all does, and make it work :)

Also, next problem is resizing/repositioning:

http://www.autoitscript.com/forum/index.ph...=89332&st=0

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...