Xandy Posted July 7, 2011 Share Posted July 7, 2011 (edited) I got to playing with guictrlcreatelist and didn't know how to access cells of the list. I need to access cells of the list to check against cells of the list and or remove cells. before asking for help I found a way to do it by storing a string to represent contents of the list, but shouldn't the list already know what's inside it? there must be a better way. Here is what I wrote so far, and it works. The complete script uses Melba23's _RecFileListToArray which is the only udf I found that lets me drop my entire 'My Music' folder into my hotkey gui. Very nice udf thank you Melba23. expandcollapse popup#include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <ListboxConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #Include <GuiListView.au3> #include <Misc.au3> global $dragdropinclude= "*.wma;*.ogg;*.flac;*.mp3;*.wav;*.mid;*.midi" showsettings(100, 100, 610, 430, "settings") func showsettings($winx, $winy, $winw, $winh, $caption) $settingswindow= GUICreate($caption, $winw, $winh, $winx, $winy);make window $settingdescription= GUICtrlCreateEdit("", 50, 20, 500, 80);field for descriptions of fields GuiCtrlSendMsg($settingdescription, $EM_SETREADONLY, 1, 0);don't allow users to modify $settingdescription field $tab= GUICtrlCreateTab(5, 120, 600, 200) ;$tab1= GUICtrlCreateTabItem("general") ;loaddialogtab(@ScriptDir&"\system\settings dialog\tab1 dialog control map.txt", $controls, $controlsonpage);not needed in example $tab2= GUICtrlCreateTabItem("drag n drop") GUICtrlSetState($tab2, $gui_show) ;setup tab2 controls and labels GUICtrlCreateLabel("Only include these extensions:", 33, 156) GUICtrlCreateLabel("add extensions to list", 190, 176) $inputinclude= GUICtrlCreateInput("", 205, 195, 100, 20) $buttoninclude= GUICtrlCreateButton("<", 190, 195, 15, 20) $buttonincluderemove= GUICtrlCreateButton("remove", 33, 266, 100, 20) $listinclude= GUICtrlCreateList("", 33, 176, 150, 90, $LBS_NOTIFY+$WS_VSCROLL) ;load dragdropinclude to $listinclude $extarray= StringSplit($dragdropinclude, ";") $stringincludelist= "";this string is used to reflect contents of $listinclude for $i= 1 to $extarray[0] $stringincludelist= $stringincludelist&$extarray[$i]&";" GUICtrlSetData($listinclude, $extarray[$i]&"|") next $stringincludelist= stringleft($stringincludelist, StringLen($stringincludelist)-1);remove trailing ';' from $stringincludelist GUICtrlCreateLabel("exclude these extensions:", 330, 156) $listexclude= GUICtrlCreateList("", 330, 176, 150, 90, $LBS_NOTIFY+$WS_VSCROLL);undeveloped GUICtrlCreateTabItem("") GUISetState() do $controlfocus= ControlGetFocus($settingswindow) $settingsmsg= GUIGetMsg($settingswindow) if $settingsmsg= $buttoninclude or (_IsPressed("0d") and ControlGetFocus($settingswindow)= "edit2") Then $temp= GUICtrlRead($inputinclude);read ext from input field if $temp<> "" then;inserting null cleared my list, and that's no good for this $extarray= StringSplit($stringincludelist, ";") $addtolist= 1 for $i= 1 to $extarray[0];look for extension already in list before adding if $temp= $extarray[$i] Then;on match don't add extension to list $addtolist= 0; ExitLoop endif next if $addtolist= 1 then $stringincludelist= $stringincludelist&";"&$temp;append ext to include list string GUICtrlSetData($listinclude, $temp&"|");append ext to $listinclude endif endif endif if $settingsmsg= $buttonincluderemove Then $extarray= StringSplit($stringincludelist, ";") $temp= GUICtrlRead($listinclude) for $i= 1 to $extarray[0];loop through array to find target to remove if $temp= $extarray[$i] then;if target found remove extension from list $stringincludelist= "";clear $stringincludelist guictrlsetdata($listinclude, "");clear $listinclude for $ii= $i to $extarray[0]-1;shift array left at target $extarray[$ii]= $extarray[$ii+1] next $extarray[0]= $extarray[0]-1 for $ii= 1 to $extarray[0];remake $stringincludelist and $listinclude $stringincludelist= $stringincludelist&$extarray[$ii]&";" GUICtrlSetData($listinclude, $extarray[$ii]&"|") next $stringincludelist= stringleft($stringincludelist, StringLen($stringincludelist)-1);remove trailing ';' endif next endif ;ConsoleWrite(ControlGetFocus($settingswindow));tool to output whatever ControlGetFocus() returns ;if $controlfocus<> ControlGetFocus($settingswindow) Then if _IsPressed("01") then switch $controlfocus case "Listbox1" GUICtrlSetData($settingdescription, "click 'remove' button to remove "&GUICtrlRead($listinclude)&" from include list.") GUICtrlSetData($buttonincluderemove, "remove "&GUICtrlRead($listinclude)) case "Listbox2" GUICtrlSetData($settingdescription, "under construction; undeveloped") case "edit2" GUICtrlSetData($settingdescription, "type a new extension to add to list"&@crlf&"remember to use wildcards. Example: *.ext"&@crlf&"then press ENTER") EndSwitch endif Until $settingsmsg= $gui_event_close $dragdropinclude= $stringincludelist MsgBox(0, "$dragdropinclude file string =", $dragdropinclude) GUIDelete($settingswindow) EndFunc; showsettings() Edited July 7, 2011 by songersoft Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 7, 2011 Moderators Share Posted July 7, 2011 songersoft,Thank you for the compliments. Take a look at the GuiListBox UDF - _GUICtrlListBox_DeleteString, _GUICtrlListBox_FindString and _GUICtrlListBox_AddString look like the functions you might need. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Xandy Posted July 7, 2011 Author Share Posted July 7, 2011 Thanks Melba23, this (_GUICtrlListBox_*) will simplify things. Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) 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