ioa747 Posted May 4 Posted May 4 (edited) And an alternative because it was spinning in my mind (for more whimsical cases, like $id_CheckBox_Out2) expandcollapse popup; https://www.autoitscript.com/forum/topic/213665-how-can-i-detect-if-a-control-is-within-a-tab-control/#findComment-1552092 #AutoIt3Wrapper_UseX64=n #include <GuiTab.au3> #include <GUIConstantsEx.au3> #include <WinAPISysWin.au3> #include <Array.au3> ; initiate System DPI awareness DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", -2) Example() Func Example() Local $hGUI_Main = GUICreate("My GUI Tab", 400, 180) GUISetBkColor(0x808080) GUISetFont(9, 300) Local $id_Tab_Main = GUICtrlCreateTab(10, 10, 200, 100) Local $id_Tab_0 = GUICtrlCreateTabItem("Tab 0") Local $id_CheckBox_0 = GUICtrlCreateCheckbox("Checkbox 0", 20, 50) Local $id_Tab_1 = GUICtrlCreateTabItem("Tab 1") GUICtrlSetState(-1, $GUI_SHOW) ; will be display first Local $id_CheckBox_1 = GUICtrlCreateCheckbox("Checkbox 1", 20, 50) Local $id_Tab_2 = GUICtrlCreateTabItem("Tab 2") Local $id_CheckBox_2 = GUICtrlCreateCheckbox("Checkbox 2", 20, 50) Local $id_CheckBox_Out2 = GUICtrlCreateCheckbox("Checkbox outside the TAB area", 0, 150) GUICtrlCreateTabItem("") ; end tabitem definition Local $id_CheckBox_Out = GUICtrlCreateCheckbox("Checkbox outside the TAB area", 20, 120) GUISetState(@SW_SHOW) Local $aTabCtrls = _GetTabControlsMap_Advanced($hGUI_Main, $id_Tab_Main) ;~ _ArrayDisplay($aTabCtrls) If Not @error Then For $i = 0 To UBound($aTabCtrls) - 1 Local $aCtrls = StringSplit($aTabCtrls[$i], "|") ConsoleWrite("Tab:" & $i & " -> ctrls: ") For $j = 1 To $aCtrls[0] ConsoleWrite($aCtrls[$j] & ($j < $aCtrls[0] ? ", " : "")) Next ConsoleWrite("" & @CRLF) Next EndIf Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Func _GetTabControlsMap_Advanced($hGUI, $idTab) Local $iTotalTabs = _GUICtrlTab_GetItemCount($idTab) ConsoleWrite("- $iTotalTabs=" & $iTotalTabs & @CRLF) If $iTotalTabs < 2 Then Return SetError(1, 0, 0) Local $aTabMap[$iTotalTabs] Local $iActiveTab = GUICtrlRead($idTab) ; Save current position ConsoleWrite("- $iActiveTab=" & $iActiveTab & @CRLF) Local $aHide, $aHide2 $aHide = _GetControlsByState($hGUI) For $i = 0 To UBound($aTabMap) - 1 If $i = $iActiveTab Then ContinueLoop _GUICtrlTab_ClickTab($idTab, $i) Sleep(10) $aHide2 = _GetControlsByState($hGUI) Local $sTabInh = "" For $j = 1 To $aHide[0][0] If $aHide2[$j][1] & $aHide[$j][1] = "10" Then $sTabInh &= $aHide[$j][0] & "|" Next If StringRight($sTabInh, 1) = "|" Then $sTabInh = StringTrimRight($sTabInh, 1) $aTabMap[$i] = $sTabInh Next _GUICtrlTab_ClickTab($idTab, $iActiveTab) $sTabInh = "" If Not IsArray($aHide2) Then Return SetError(2, 0, 0) For $j = 1 To $aHide[0][0] If $aHide[$j][1] & $aHide2[$j][1] = "10" Then $sTabInh &= $aHide[$j][0] & "|" Next If StringRight($sTabInh, 1) = "|" Then $sTabInh = StringTrimRight($sTabInh, 1) $aTabMap[$iActiveTab] = $sTabInh Return $aTabMap EndFunc ;==>_GetTabControlsMap_Advanced Func _GetControlsByState($hGUI) Local $aChildHandles = _WinAPI_EnumChildWindows($hGUI, False) If @error Then Return SetError(1, 0, 0) Local $aFound[$aChildHandles[0][0] + 1][2] $aFound[0][0] = $aChildHandles[0][0] For $i = 1 To $aChildHandles[0][0] Local $hCtrl = $aChildHandles[$i][0] ; convert the Handle to ID Local $idCtrl = _WinAPI_GetDlgCtrlID($hCtrl) Local $bVisible = ControlCommand($hGUI, "", $hCtrl, "IsVisible", "") $aFound[$i][0] = $idCtrl $aFound[$i][1] = $bVisible Next Return $aFound EndFunc Edited May 4 by ioa747 update WildByDesign 1 I know that I know nothing
WildByDesign Posted May 4 Author Posted May 4 3 hours ago, ioa747 said: And an alternative because it was spinning in my mind (for more whimsical cases, like $id_CheckBox_Out2) You very often have wonderful and creative ideas. I like the way that you think. Thanks for sharing. ioa747 1
mLipok Posted May 6 Posted May 6 (edited) On 5/1/2026 at 4:01 PM, mLipok said: It seems that in C++, the programmer, as the application creator, determines by WM_NOTIFY that user is changing TAB from 0 to 1 and calls a function that hides or shows all controls inside TAB 0 or TAB 1. In this case, it seems that AutoIt handles this internally haa.... I think I was right. Take a look: https://www.autoitscript.com/wiki/Tabs Quote As you can see, the UDF created controls appear on every tab. Remember this is because they are not part of the internal AutoIt control management structure, so AutoIt does not know how to handle them. It is up to you to manage them by seeing which tab is active and hiding/showing these controls as required: and in: https://www.autoitscript.com/wiki/Tabs#Tabs_Created_With_UDFs and: https://www.autoitscript.com/wiki/Tabs#Adding_Controls_To_Tabs_After_Creation Edited May 6 by mLipok pixelsearch and WildByDesign 2 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
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