MyEarth Posted July 1, 2013 Share Posted July 1, 2013 (edited) Hi guys, The GUITab UDF is very useful in many situation, but i think is "stupid" ( sorry for stupid, i don't want offend anyone ) to use it when the GUI is created by yourself I need to for a tab with the specific text, if exist or not and the return the value of tab index So i have think to create and array of tab and tab names in this way: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Global $AddTab = -1, $Tab, $Name_Tab $Form1 = GUICreate("Form1", 324, 272, 191, 133) $hTab = GUICtrlCreateTab(8, 8, 305, 193) $TabSheet_Defautl = GUICtrlCreateTabItem("Default") ; this is the default tab, i don't want to include in the search or array GUICtrlCreateTabItem("") $Button = GUICtrlCreateButton("Find Tab", 40, 224, 75, 25) $Input = GUICtrlCreateInput("MYNAME", 136, 224, 121, 21) GUISetState(@SW_SHOW) _ADDTAB("MYNAME") ConsoleWrite($Name_Tab[0]) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button ;Func here EndSwitch WEnd Func _ADDTAB($Name) If Not IsArray($Tab) Then Dim $Tab[1], $Name_Tab[1] Else ReDim $Tab[UBound($Tab) + 1] ReDim $Name_Tab[UBound($Name_Tab) + 1] EndIf $Tab[UBound($Tab) - 1] = GUICtrlCreateTabItem($Name) GUICtrlCreateTabItem("") $Name_Tab[UBound($Name_Tab) - 1] = $Name $AddTab = -1 EndFunc Now i don't know how to continue, i need to create 2d array for the name? ( one for index and one for name ) or the arrays i have created is fine. Anyway now i need to search if tab exist and then return the index. Some advice? Many thanks Edited July 1, 2013 by MyEarth Link to comment Share on other sites More sharing options...
water Posted July 1, 2013 Share Posted July 1, 2013 What do you need the name or index for? The handle returned by GUICtrlCreateTabitem is what you need to switch to another tab. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
MyEarth Posted July 1, 2013 Author Share Posted July 1, 2013 (edited) I need the index ( returned by the name ) because i have inside the tab some edit ( created in the same way ) so i need to write in right edit based on the name of the tab ( so by his index ) I don't need to switch it Edited July 1, 2013 by MyEarth Link to comment Share on other sites More sharing options...
guinness Posted July 1, 2013 Share Posted July 1, 2013 Firstly the UDF isn't "stupid", it's designed around Microsoft's API for manipulating tab controls. Secondly, why not create the 2d array first and then loop through check the name and then return the index. It shouldn't be too difficult considering you pretty much have the basics down. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
guinness Posted July 1, 2013 Share Posted July 1, 2013 What do you need the name or index for? The handle returned by GUICtrlCreateTabitem is what you need to switch to another tab.If MyEarth uses _GUICtrlTab_SetCurSel then they will need the index value, the controlid returned by GUICtrlCreateTabItem doesn't work in this instance. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
MyEarth Posted July 1, 2013 Author Share Posted July 1, 2013 (edited) I don't have say that udf is stupid, is well coded and i'll never create something like that in my entire life. I have say is stupid to use it when you create the control by yourself, i read everytime "if you can, use the internal autoit function" and now is my mantra lol Anyway, is not possible to get the index using a 1d array? With a 1d array i can know a position of a text? Like: Var = 'name1,name2' Name1 is 0 Name2 is 1 Sorry but i'm on a phone Edited July 1, 2013 by MyEarth Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted July 1, 2013 Moderators Solution Share Posted July 1, 2013 MyEarth, If, for some peculiar reason, I needed to search for my own tabs by name I would do it something like this: #include <GUIConstantsEx.au3> Global $aTab_Name[5][2] $hGUI = GUICreate("Test", 500, 500) $cTab = GUICtrlCreateTab(10, 10, 480, 300) For $i = 0 To UBound($aTab_Name) - 1 $aTab_Name[$i][0] = GUICtrlCreateTabItem("Tab " & $i) $aTab_Name[$i][1] = "Tab " & $i Next GUICtrlCreateTabItem("") $cInput = GUICtrlCreateInput("", 10, 350, 200, 20) $cButton = GUICtrlCreateButton("Select Tab", 10, 400, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $sTab_Name = GUICtrlRead($cInput) For $i = 0 To UBound($aTab_Name) - 1 If $sTab_Name = $aTab_Name[$i][1] Then GUICtrlSetState($aTab_Name[$i][0], $GUI_SHOW) ExitLoop EndIf Next EndSwitch WEnd 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...
water Posted July 1, 2013 Share Posted July 1, 2013 If MyEarth uses _GUICtrlTab_SetCurSel then they will need the index value, the controlid returned by GUICtrlCreateTabItem doesn't work in this instance. He didn't tell that he wants to use _GUICtrlTab_SetCurSel. Hence I asked. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
MyEarth Posted July 1, 2013 Author Share Posted July 1, 2013 (edited) I don't use _GUICtrlTab_SetCurSel, i don't use ( in this case ) that UDF at all I don't need to select nothing, this is what i have do for this little project: 1-- Check folder for .txt file 2-- If a txt named "Water" and a TabItem is called "Water" then fill the edit with text content 3-- Don't switch, don't change the focus etc but stay on Default Item ( it's the main part of the script ) and if Point 2 = True fill the edit of corresponding TabItem (based on index), i'll check manually later if i need to read that edit. With the Malba's example of 2D arrays i can continue, but thanks to all for the effort. Edited July 1, 2013 by MyEarth 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