Jump to content

Search the Community

Showing results for tags 'listbox array'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. For those who use ListBoxes and wish to call a Function to grab the contents of the ListBox into a 1D array, then _GUICtrlListBox_CreateArray() is for you. It will Return an array with the contents of the ListBox inc. the number of rows. Simply run the Example to get an idea of the output. Thanks. Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListBox_CreateArray ; Description ...: Creates a 1-dimensional array from a listbox. ; Syntax ........: _GUICtrlListBox_CreateArray($hListBox) ; Parameters ....: $hListBox - Control ID/Handle to the control ; Return values .: Success - The array returned is one-dimensional and is made up of the following: ; $aArray[0] = Number of rows ; $aArray[1] = 1st row ; $aArray[2] = 2nd row ; $aArray[n] = nth row ; Author ........: guinness ; Remarks .......: GUICtrlListBox.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListBox_CreateArray($hListBox) Local $iItemCount = _GUICtrlListBox_GetCount($hListBox) Local $aReturn[$iItemCount + 1] = [$iItemCount] For $i = 0 To $iItemCount - 1 $aReturn[$i + 1] = _GUICtrlListBox_GetText($hListBox, $i) Next Return SetError(Number($aReturn[0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListBox_CreateArrayExample use of Function: #include <Array.au3> ; Required only for _ArrayDisplay(). #include <GUIListBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $iWidth = 600, $iHeight = 400, $iListBox = 0 Local $hGUI = GUICreate('_GUICtrlListBox_CreateArray()', $iWidth, $iHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) _CreateListBox($hGUI, $iListBox) Local $iGetArray = GUICtrlCreateButton('Get Array', $iWidth - 90, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) Local $iRefresh = GUICtrlCreateButton('Refresh', $iWidth - 180, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW, $hGUI) Local $aReturn = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iGetArray $aReturn = _GUICtrlListBox_CreateArray($iListBox) _ArrayDisplay($aReturn, '_GUICtrlListBox_CreateArray() array.') Case $iRefresh GUICtrlDelete($iListBox) _CreateListBox($hGUI, $iListBox) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _CreateListBox($hGUI, ByRef $iListBox) Local $aClientSize = WinGetClientSize($hGUI) $iListBox = GUICtrlCreateList('', 0, 0, $aClientSize[0], $aClientSize[1] - 30) GUICtrlSetResizing($iListBox, $GUI_DOCKBORDERS) Sleep(250) __ListBoxFill($iListBox, Random(25, 100, 1)) ; Fill the ListBox with Random data. EndFunc ;==>_CreateListBox Func __ListBoxFill($hListBox, $iRows) ; Required only for the Example. If Not IsHWnd($hListBox) Then $hListBox = GUICtrlGetHandle($hListBox) EndIf _GUICtrlListBox_BeginUpdate($hListBox) For $i = 0 To $iRows - 1 _GUICtrlListBox_AddString($hListBox, 'Row ' & $i + 1) Next _GUICtrlListBox_EndUpdate($hListBox) EndFunc ;==>__ListBoxFill
×
×
  • Create New...