Jewtus Posted April 16, 2015 Posted April 16, 2015 I am trying to make it so when an array is passed to a function, the function then looks up some more info and adds some GUI tabs, labels, etc. Below is my sample code. The loop seems to be functional, but only 1 tab is ever added and none of the other elements are added. expandcollapse popup#include <GUITab.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> Example() Func Example() $MainForm = GUICreate("TEST", 631, 327, 192, 114, -1) $TypeLabel = GUICtrlCreateLabel("Search Type", 8, 8, 65, 17) $SearchInput = GUICtrlCreateCombo("", 16, 26, 257, 25) GUICtrlSetData(-1, "Name|ID") $InputValLabel = GUICtrlCreateLabel("Input Value", 8, 56, 58, 17) $InputVal = GUICtrlCreateInput("", 16, 80, 257, 21) $StartSearch = GUICtrlCreateButton("Search", 8, 284, 75, 25) $bEnterDummy = GUICtrlCreateDummy() Local $bAccelKeys[1][2] = [["{ENTER}", $bEnterDummy]] GUISetAccelerators($bAccelKeys) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $StartSearch, $bEnterDummy SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) $type=GUICtrlRead($SearchInput) $Parameter=GUICtrlRead($InputVal) GUICtrlSetData($InputVal,"") Local $result[1][4]=[["This","Is","A","Test"]] SplashOff() If UBound($Result)>0 Then AddTabsResult($Result) EndIf EndSwitch WEnd EndFunc Func AddTabsResult($array) Global $NameLabel[UBound($array)] Global $NameInput[UBound($array)] Global $NotesLabel[UBound($array)] Global $NotesInput[UBound($array)] Global $ResultList[UBound($array)] Global $Tab[UBound($array)] For $p=0 to UBound($array)-1 Local $Fullresult[2][4]=[["This","Is","A","Test"],["This","Too","Is A","Test"]] $tabctrl=GUICtrlCreateTab(288, 16, 329, 297) $tab[$p]=GUICtrlCreateTabItem($Fullresult[0][0]) $NameLabel[$p] = GUICtrlCreateLabel("Name", 296, 43, 32, 17) $NameInput[$p] = GUICtrlCreateInput("", 330, 39, 169, 21) $NotesLabel[$p] = GUICtrlCreateLabel("Notes", 296, 123, 32, 17) $NotesInput[$p] = GUICtrlCreateInput("", 336, 120, 273, 21) $ResultList[$p] = GUICtrlCreateListView("", 296, 144, 313, 161) _ArrayDisplay($Fullresult) Next EndFunc What am I missing here?
Jewtus Posted April 16, 2015 Author Posted April 16, 2015 Found another issue. I isolated my script above to test it, and when I swapped the start array and made it multi-row, it did what I wanted. expandcollapse popup#include <GUITab.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> Example() Func Example() $MainForm = GUICreate("TEST", 631, 327, 192, 114, -1) $TypeLabel = GUICtrlCreateLabel("Search Type", 8, 8, 65, 17) $SearchInput = GUICtrlCreateCombo("", 16, 26, 257, 25) GUICtrlSetData(-1, "Name|ID") $InputValLabel = GUICtrlCreateLabel("Input Value", 8, 56, 58, 17) $InputVal = GUICtrlCreateInput("", 16, 80, 257, 21) $StartSearch = GUICtrlCreateButton("Search", 8, 284, 75, 25) $bEnterDummy = GUICtrlCreateDummy() Local $bAccelKeys[1][2] = [["{ENTER}", $bEnterDummy]] GUISetAccelerators($bAccelKeys) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $StartSearch, $bEnterDummy SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) $type=GUICtrlRead($SearchInput) $Parameter=GUICtrlRead($InputVal) GUICtrlSetData($InputVal,"") Local $result[2][4]=[["This","Is","A","Test"],["This","Too","Is A","Test"]] SplashOff() If UBound($Result)>0 Then AddTabsResult($Result) EndIf EndSwitch WEnd EndFunc Func AddTabsResult($array) local $NameLabel[UBound($array)] local $NameInput[UBound($array)] local $NotesLabel[UBound($array)] local $NotesInput[UBound($array)] local $ResultList[UBound($array)] local $Tab[UBound($array)] For $p=0 to UBound($array)-1 Local $Fullresult[2][4]=[["This","Is","A","Test"],["This","Too","Is A","Test"]] $tabctrl=GUICtrlCreateTab(288, 16, 329, 297) $tab[$p]=GUICtrlCreateTabItem($Fullresult[0][0]) $NameLabel[$p] = GUICtrlCreateLabel("Name", 296, 43, 32, 17) $NameInput[$p] = GUICtrlCreateInput("", 330, 39, 169, 21) $NotesLabel[$p] = GUICtrlCreateLabel("Notes", 296, 123, 32, 17) $NotesInput[$p] = GUICtrlCreateInput("", 336, 120, 273, 21) $ResultList[$p] = GUICtrlCreateListView("", 296, 144, 313, 161) _ArrayDisplay($Fullresult) Next EndFunc Then I tried it in my primary script and it starts acting weird expandcollapse popup#include <GUITab.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> ;Begin Main Gui Global $Home = GUICreate("Welcome", 635, 477, 192, 114, $WS_MAXIMIZEBOX) ;Menus $MenuFile = GUICtrlCreateMenu("File") $Start= GUICtrlCreateMenuItem("Start", $MenuFile) GUICtrlCreateMenuItem("", $MenuFile ) ; Create a separator line $ExitMenu = GUICtrlCreateMenuItem("Exit", $MenuFile) GUISetState(@SW_SHOW) WinSetState($Home,'',@SW_MAXIMIZE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $ExitMenu Exit Case $Start Example() EndSwitch WEnd Func Example() $MainForm = GUICreate("TEST", 631, 327, 192, 114, -1) $TypeLabel = GUICtrlCreateLabel("Search Type", 8, 8, 65, 17) $SearchInput = GUICtrlCreateCombo("", 16, 26, 257, 25) GUICtrlSetData(-1, "Name|ID") $InputValLabel = GUICtrlCreateLabel("Input Value", 8, 56, 58, 17) $InputVal = GUICtrlCreateInput("", 16, 80, 257, 21) $StartSearch = GUICtrlCreateButton("Search", 8, 284, 75, 25) $bEnterDummy = GUICtrlCreateDummy() Local $bAccelKeys[1][2] = [["{ENTER}", $bEnterDummy]] GUISetAccelerators($bAccelKeys) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $StartSearch, $bEnterDummy SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) $type=GUICtrlRead($SearchInput) $Parameter=GUICtrlRead($InputVal) GUICtrlSetData($InputVal,"") Local $result[2][4]=[["This","Is","A","Test"],["This","Too","Is A","Test"]] SplashOff() If UBound($Result)>0 Then AddTabsResult($Result) EndIf EndSwitch WEnd EndFunc Func AddTabsResult($array) local $NameLabel[UBound($array)] local $NameInput[UBound($array)] local $NotesLabel[UBound($array)] local $NotesInput[UBound($array)] local $ResultList[UBound($array)] local $Tab[UBound($array)] For $p=0 to UBound($array)-1 Local $Fullresult[2][4]=[["This","Is","A","Test"],["This","Too","Is A","Test"]] $tabctrl=GUICtrlCreateTab(288, 16, 329, 297) $tab[$p]=GUICtrlCreateTabItem($Fullresult[0][0]) $NameLabel[$p] = GUICtrlCreateLabel("Name", 296, 43, 32, 17) $NameInput[$p] = GUICtrlCreateInput("", 330, 39, 169, 21) $NotesLabel[$p] = GUICtrlCreateLabel("Notes", 296, 123, 32, 17) $NotesInput[$p] = GUICtrlCreateInput("", 336, 120, 273, 21) $ResultList[$p] = GUICtrlCreateListView("", 296, 144, 313, 161) _ArrayDisplay($Fullresult) Next EndFunc I'm not quite sure why this is happening, could anyone point me in the right direction?
MikahS Posted April 16, 2015 Posted April 16, 2015 (edited) You are using the parameter $array in AddTabsResult and Ubound($array). Well, since this is a 2d array, Ubound is by default only going to grab the first column, which is 1. Making it so it will only loop once. So, you'll need to change your Ubound calls to Ubound($array, 2) like so: expandcollapse popup#include <GUITab.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> Global $tabctrl = True Example() Func Example() $MainForm = GUICreate("TEST", 631, 327, 192, 114, -1) $TypeLabel = GUICtrlCreateLabel("Search Type", 8, 8, 65, 17) $SearchInput = GUICtrlCreateCombo("", 16, 26, 257, 25) GUICtrlSetData(-1, "Name|ID") $InputValLabel = GUICtrlCreateLabel("Input Value", 8, 56, 58, 17) $InputVal = GUICtrlCreateInput("", 16, 80, 257, 21) $StartSearch = GUICtrlCreateButton("Search", 8, 284, 75, 25) $bEnterDummy = GUICtrlCreateDummy() Local $bAccelKeys[1][2] = [["{ENTER}", $bEnterDummy]] GUISetAccelerators($bAccelKeys) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $StartSearch, $bEnterDummy SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) $type = GUICtrlRead($SearchInput) $Parameter = GUICtrlRead($InputVal) GUICtrlSetData($InputVal, "") Local $result[1][4] = [["This", "Is", "A", "Test"]] SplashOff() If UBound($result) > 0 Then AddTabsResult($result) EndIf EndSwitch WEnd EndFunc ;==>Example Func AddTabsResult($array) Local $NameLabel[UBound($array, 2)] Local $NameInput[UBound($array, 2)] Local $NotesLabel[UBound($array, 2)] Local $NotesInput[UBound($array, 2)] Local $ResultList[UBound($array, 2)] Local $NameLabelEx[UBound($array, 2)] Local $NameInputEx[UBound($array, 2)] Local $NotesLabelEx[UBound($array, 2)] Local $NotesInputEx[UBound($array, 2)] Local $ResultListEx[UBound($array, 2)] Local $Tab[UBound($array, 2)] Local $TabEx[UBound($array, 2)] For $p = 0 To UBound($array, 2) - 1 Local $Fullresult[2][4] = [["This", "Is", "A", "Test"], ["This", "Too", "Is A", "Test"]] If $tabctrl = True Then $tabctrl = GUICtrlCreateTab(288, 16, 329, 297) $tabctrl = False EndIf $Tab[$p] = GUICtrlCreateTabItem($Fullresult[0][$p]) $NameLabel[$p] = GUICtrlCreateLabel("Name", 296, 43, 32, 17) $NameInput[$p] = GUICtrlCreateInput("", 330, 39, 169, 21) $NotesLabel[$p] = GUICtrlCreateLabel("Notes", 296, 123, 32, 17) $NotesInput[$p] = GUICtrlCreateInput("", 336, 120, 273, 21) $ResultList[$p] = GUICtrlCreateListView("", 296, 144, 313, 161) _ArrayDisplay($Fullresult) If $p = UBound($array, 2) - 1 Then For $q = 0 To UBound($array, 2) - 1 $TabEx[$q] = GUICtrlCreateTabItem($Fullresult[1][$q]) $NameLabelEx[$q] = GUICtrlCreateLabel("Name", 296, 43, 32, 17) $NameInputEx[$q] = GUICtrlCreateInput("", 330, 39, 169, 21) $NotesLabelEx[$q] = GUICtrlCreateLabel("Notes", 296, 123, 32, 17) $NotesInputEx[$q] = GUICtrlCreateInput("", 336, 120, 273, 21) $ResultListEX[$q] = GUICtrlCreateListView("", 296, 144, 313, 161) Next EndIf GUISetState() Next EndFunc ;==>AddTabsResult Also, added a for loop for the other values in the 2D array. All good? EDIT: As a best practice, you should be declaring any variable inside a function as Local. Edited April 16, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use.                                                                              Forum FAQ Â
Jewtus Posted April 16, 2015 Author Posted April 16, 2015 MikahS, Thank you for that, but its not really what I'm looking for. I want to loop to create the tabs and elements in each tab. I was able to figure out how to make it work with a Child GUI: expandcollapse popup#include <GUITab.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #include <GUIListView.au3> ;Begin Main Gui Global $Home = GUICreate("Welcome", 635, 477, 192, 114, $WS_MAXIMIZEBOX) ;Menus $MenuFile = GUICtrlCreateMenu("File") $Start= GUICtrlCreateMenuItem("Start", $MenuFile) GUICtrlCreateMenuItem("", $MenuFile ) ; Create a separator line $ExitMenu = GUICtrlCreateMenuItem("Exit", $MenuFile) GUISetState(@SW_SHOW) WinSetState($Home,'',@SW_MAXIMIZE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $ExitMenu Exit Case $Start Example() EndSwitch WEnd Func Example() $MainForm = GUICreate("DAS Search Utility", 925, 327, 192, 114, -1, $WS_EX_MDICHILD,$Home) $TypeLabel = GUICtrlCreateLabel("Search Type", 8, 8, 65, 17) $SearchInput = GUICtrlCreateCombo("", 16, 26, 257, 25) GUICtrlSetData(-1, "Person Name|ID search|Entity Name") $InputValLabel = GUICtrlCreateLabel("Input Value", 8, 56, 58, 17) $InputVal = GUICtrlCreateInput("", 16, 80, 257, 21) $StartSearch = GUICtrlCreateButton("Search", 8, 284, 75, 25) $aLabel = GUICtrlCreateLabel("Date", 8, 112, 84, 17) $aInput = GUICtrlCreateDate("", 19, 132, 259, 21,(0x00)) $aReportBox = GUICtrlCreateCheckbox("Generate report", 11, 168, 169, 17) GUICtrlSetState(-1,$GUI_HIDE) $MarkDead = GUICtrlCreateCheckbox("Mark Dead", 11, 192, 169, 17) GUICtrlSetState(-1,$GUI_HIDE) $UserOutput = GUICtrlCreateButton("Output", 188, 284, 75, 25) GUICtrlSetState($UserOutput,$GUI_HIDE) $bEnterDummy = GUICtrlCreateDummy() Local $bAccelKeys[1][2] = [["{ENTER}", $bEnterDummy]] GUISetAccelerators($bAccelKeys) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $ExitMenu GUIDelete($MainForm) ExitLoop Case $StartSearch, $bEnterDummy If GUICtrlRead($InputVal)="" Then MsgBox(0,"ERROR","You must input a parameter") Else SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) $type=GUICtrlRead($SearchInput) $Parameter=GUICtrlRead($InputVal) GUICtrlSetData($InputVal,"") Local $IDs[2][2]=[["1","A"],["2","B"]] SplashOff() If UBound($IDs)>0 Then SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) local $ResultList[UBound($IDs)] local $Tab[UBound($IDs)] $AcctResults= GUICreate("", 620, 344, 294, 0,$WS_CHILD,-1,$MainForm) $Tabs=_GUICtrlTab_Create($AcctResults, 0, 10, 609, 300) ;Loop for each Result For $p=0 to UBound($IDs)-1 Local $Fullresult[3][7]=[[Random(1,10),"Tester","123456",GUICtrlRead($aInput),'','',''],["Hello","There","My","Fine","Friend","",""],["GoodBye","There","My","Hated","Enemy","",""]] $Tab[$p] = _GUICtrlTab_InsertItem($Tabs,$p,$Fullresult[0][0]) $ResultList[$p] = GUICtrlCreateListView("", 7, 128, 594, 174) _GUICtrlListView_AddColumn($ResultList[$p],'Col0') _GUICtrlListView_AddColumn($ResultList[$p],'Col1') _GUICtrlListView_AddColumn($ResultList[$p],'Col2') _GUICtrlListView_AddColumn($ResultList[$p],'Col3') _GUICtrlListView_AddColumn($ResultList[$p],'Col4') _GUICtrlListView_AddColumn($ResultList[$p],'Col5') _GUICtrlListView_AddColumn($ResultList[$p],'Col6') Local $aWriter=$Fullresult _ArrayDelete($aWriter,0) _GUICtrlListView_AddArray($ResultList[$p],$aWriter) Next Hide(1,$aLabel,$aInput,$UserOutput,$aReportBox,$MarkDead) SplashOff() GUISetState(@SW_SHOW) While 2 ExitLoop WEnd EndIf EndIf Case $UserOutput If _GUICtrlTab_GetItemState($Tabs,0) = 1 Then; First tab MsgBox(0,"",_GUICtrlTab_GetItemText($Tabs,0)) $test=_GUICtrlListView_CreateArray($Tab[0]) _ArrayDisplay($test) EndIf EndSwitch WEnd EndFunc Func Hide($toggle,$aLabel,$aInput,$UserOutput,$aReportBox,$MarkDead) GUICtrlSetState($aLabel, $toggle=1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($aInput, $toggle=1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($UserOutput, $toggle=1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($aReportBox, $toggle=1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($MarkDead, $toggle=1 ? $GUI_SHOW : $GUI_HIDE) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_CreateArray ; Description ...: Creates a 2-dimensional array from a listview. ; Syntax ........: _GUICtrlListView_CreateArray($hListView[, $sDelimeter = '|']) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sDelimeter - [optional] One or more characters to use as delimiters (case sensitive). Default is '|'. ; Return values .: Success - The array returned is two-dimensional and is made up of the following: ; $aArray[0][0] = Number of rows ; $aArray[0][1] = Number of columns ; $aArray[0][2] = Delimited string of the column name(s) e.g. Column 1|Column 2|Column 3|Column nth ; $aArray[1][0] = 1st row, 1st column ; $aArray[1][1] = 1st row, 2nd column ; $aArray[1][2] = 1st row, 3rd column ; $aArray[n][0] = nth row, 1st column ; $aArray[n][1] = nth row, 2nd column ; $aArray[n][2] = nth row, 3rd column ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArray  This one is working the way I wanted it to, but I'm struggling to get guinness's Listview to array function working... '?do=embed' frameborder='0' data-embedContent>>
MikahS Posted April 16, 2015 Posted April 16, 2015 (edited) MikahS, Thank you for that, but its not really what I'm looking for. I want to loop to create the tabs and elements in each tab.  That is exactly what I just wrote for you. I am trying to make it so when an array is passed to a function, the function then looks up some more info and adds some GUI tabs, labels, etc. Below is my sample code. The loop seems to be functional, but only 1 tab is ever added and none of the other elements are added.  My solution is exactly as described, so can you tell me what your end goal here is? EDIT: It's my pleasure, just would like to make sure I'm not going through the, "There's a hole in my bucket" scenario. Edited April 16, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use.                                                                              Forum FAQ Â
Jewtus Posted April 16, 2015 Author Posted April 16, 2015 (edited) Mikah, When I ran your script, It added elements for all the items in the list (one tab for every single item). Think of it like an inventory list. Column 0 Is the inventory name, and the rest of the columns are components like price,cost,etc. I was trying to make it count the rows, then add a tab for each row headed with col 0 value then have various boxes/listview data display in each tab. I then want to be able to edit the list views and parse them back into an array for writing to a report. I think I have resolved the GUI loop at this point by using the child GUI (I posted my script in case someone else can make use of it). I'm going to create a different thread for figuring out how to read the listview into an array. I'm sure I'm just using the syntax incorrectly. Edited April 16, 2015 by Jewtus
MikahS Posted April 16, 2015 Posted April 16, 2015 I think I understand what you are going for, but if you have got yourself a solution. That is good to hear. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Forum FAQ Â
Jewtus Posted April 16, 2015 Author Posted April 16, 2015 Turns out that my script... doesn't create different list views on the different tabs....
Solution MikahS Posted April 16, 2015 Solution Posted April 16, 2015 (edited) Use the AutoIt tabs and not the UDF like so: expandcollapse popup#include <GUITab.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #include <GUIListView.au3> ;Begin Main Gui Global $Home = GUICreate("Welcome", 635, 477, 192, 114, $WS_MAXIMIZEBOX) ;Menus $MenuFile = GUICtrlCreateMenu("File") $Start = GUICtrlCreateMenuItem("Start", $MenuFile) GUICtrlCreateMenuItem("", $MenuFile) ; Create a separator line $ExitMenu = GUICtrlCreateMenuItem("Exit", $MenuFile) GUISetState(@SW_SHOW) WinSetState($Home, '', @SW_MAXIMIZE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $ExitMenu Exit Case $Start Example() EndSwitch WEnd Func Example() $MainForm = GUICreate("DAS Search Utility", 925, 327, 192, 114, -1, $WS_EX_MDICHILD, $Home) $TypeLabel = GUICtrlCreateLabel("Search Type", 8, 8, 65, 17) $SearchInput = GUICtrlCreateCombo("", 16, 26, 257, 25) GUICtrlSetData(-1, "Person Name|ID search|Entity Name") $InputValLabel = GUICtrlCreateLabel("Input Value", 8, 56, 58, 17) $InputVal = GUICtrlCreateInput("", 16, 80, 257, 21) $StartSearch = GUICtrlCreateButton("Search", 8, 284, 75, 25) $aLabel = GUICtrlCreateLabel("Date", 8, 112, 84, 17) $aInput = GUICtrlCreateDate("", 19, 132, 259, 21, (0x00)) $aReportBox = GUICtrlCreateCheckbox("Generate report", 11, 168, 169, 17) GUICtrlSetState(-1, $GUI_HIDE) $MarkDead = GUICtrlCreateCheckbox("Mark Dead", 11, 192, 169, 17) GUICtrlSetState(-1, $GUI_HIDE) $UserOutput = GUICtrlCreateButton("Output", 188, 284, 75, 25) GUICtrlSetState($UserOutput, $GUI_HIDE) $bEnterDummy = GUICtrlCreateDummy() Local $bAccelKeys[1][2] = [["{ENTER}", $bEnterDummy]] GUISetAccelerators($bAccelKeys) GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $ExitMenu GUIDelete($MainForm) ExitLoop Case $StartSearch, $bEnterDummy If GUICtrlRead($InputVal) = "" Then MsgBox(0, "ERROR", "You must input a parameter") Else SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) $type = GUICtrlRead($SearchInput) $Parameter = GUICtrlRead($InputVal) GUICtrlSetData($InputVal, "") Local $IDs[2][2] = [["1", "A"], ["2", "B"]] SplashOff() If UBound($IDs) > 0 Then SplashTextOn("Processing...", "Processing" & @CRLF & @CRLF & "Please wait", 200, 150, Default, Default, 1, Default, 25) Local $ResultList[UBound($IDs)] Local $Tab[UBound($IDs)] $AcctResults = GUICreate("", 620, 344, 294, 0, $WS_CHILD, -1, $MainForm) $Tabs = GUICtrlCreateTab(0, 10, 609, 300) ;Loop for each Result For $p = 0 To UBound($IDs) - 1 Local $Fullresult[3][7] = [[Random(1, 10), "Tester", "123456", GUICtrlRead($aInput), '', '', ''], ["Hello", "There", "My", "Fine", "Friend", "", ""], ["GoodBye", "There", "My", "Hated", "Enemy", "", ""]] $Tab[$p] = GUICtrlCreateTabItem($Fullresult[0][0]) $ResultList[$p] = GUICtrlCreateListView("", 7, 128, 594, 174) _GUICtrlListView_AddColumn($ResultList[$p], 'Col0') _GUICtrlListView_AddColumn($ResultList[$p], 'Col1') _GUICtrlListView_AddColumn($ResultList[$p], 'Col2') _GUICtrlListView_AddColumn($ResultList[$p], 'Col3') _GUICtrlListView_AddColumn($ResultList[$p], 'Col4') _GUICtrlListView_AddColumn($ResultList[$p], 'Col5') _GUICtrlListView_AddColumn($ResultList[$p], 'Col6') Local $aWriter = $Fullresult _ArrayDelete($aWriter, 0) _GUICtrlListView_AddArray($ResultList[$p], $aWriter) Next Hide(1, $aLabel, $aInput, $UserOutput, $aReportBox, $MarkDead) SplashOff() GUISetState(@SW_SHOW) While 2 ExitLoop WEnd EndIf EndIf Case $UserOutput If _GUICtrlTab_GetItemState($Tabs, 0) = 1 Then; First tab MsgBox(0, "", _GUICtrlTab_GetItemText($Tabs, 0)) $test = _GUICtrlListView_CreateArray($Tab[0]) _ArrayDisplay($test) EndIf EndSwitch WEnd EndFunc ;==>Example Func Hide($toggle, $aLabel, $aInput, $UserOutput, $aReportBox, $MarkDead) GUICtrlSetState($aLabel, $toggle = 1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($aInput, $toggle = 1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($UserOutput, $toggle = 1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($aReportBox, $toggle = 1 ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($MarkDead, $toggle = 1 ? $GUI_SHOW : $GUI_HIDE) EndFunc ;==>Hide ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_CreateArray ; Description ...: Creates a 2-dimensional array from a listview. ; Syntax ........: _GUICtrlListView_CreateArray($hListView[, $sDelimeter = '|']) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sDelimeter - [optional] One or more characters to use as delimiters (case sensitive). Default is '|'. ; Return values .: Success - The array returned is two-dimensional and is made up of the following: ; $aArray[0][0] = Number of rows ; $aArray[0][1] = Number of columns ; $aArray[0][2] = Delimited string of the column name(s) e.g. Column 1|Column 2|Column 3|Column nth ; $aArray[1][0] = 1st row, 1st column ; $aArray[1][1] = 1st row, 2nd column ; $aArray[1][2] = 1st row, 3rd column ; $aArray[n][0] = nth row, 1st column ; $aArray[n][1] = nth row, 2nd column ; $aArray[n][2] = nth row, 3rd column ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArray Not sure why it doesn't work with the Tabs UDF functions. Edited April 16, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use.                                                                              Forum FAQ Â
Moderators Melba23 Posted April 16, 2015 Moderators Posted April 16, 2015 MikahS,Not sure why it doesn't work with the Tabs UDF functionsThe Tabs tutorial in the Wiki explains the difference - and how to manage it. 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 Â
MikahS Posted April 16, 2015 Posted April 16, 2015 Thank you, Melba. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use.                                                                              Forum FAQ Â
Jewtus Posted April 16, 2015 Author Posted April 16, 2015 That did it! NOTE: Anyone who is trying to use this script, make sure to add the GUICtrlCreateTabItem("") before the next command because if you don't, the added elements will stack outside the tabs.
MikahS Posted April 16, 2015 Posted April 16, 2015 Glad to hear it. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Forum FAQ Â
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