Jewtus Posted April 16, 2015 Share Posted April 16, 2015 I have been trying to make this GUI do some of the stuff I need but it is getting quickly more complicated and I'm not even sure how to proceed with debugging my next step. I'm using >guinness's Listview_CreateArray script and it works like a charm in other places, but when I try to use it on my tabbed GUI, It just kicks back a few 0s. Here is my code 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("Test", 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, "Name|ID") $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,$LVS_EDITLABELS) _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) GUICtrlCreateTabItem("") 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 $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 Anyone have suggestions on what I'm doing wrong? I tried to put in a If _GUICtrlTab_GetItemState($Tabs, 0) = 1 to make sure it was binding to the tabs and that I could control the index's, but I'm not sure where I'm going wrong. Link to comment Share on other sites More sharing options...
Solution mLipok Posted April 16, 2015 Solution Share Posted April 16, 2015 I'am not sure what you want to achieve. but here are some question: Why you use TabItem as a parameter to function $test = _GUICtrlListView_CreateArray($Tab[0]) when expected is: ; Parameters ....: $hListView - Control ID/Handle to the control Cheers. mLipok btw. please read Best coding practices Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Jewtus Posted April 17, 2015 Author Share Posted April 17, 2015 That would be it... used the wrong param... I'll study the coding practices... I often cant figure out what to name variables so this will be helpful. 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