Sign in to follow this  
Followers 0
guinness

Delete & Recreate an Item in Tab, but without it showing in other Tabs.

8 posts in this topic

#1 ·  Posted (edited)

Here is a list of Examples to Show/Hide a Password Input (I recommend V3)

V1: >>

V2: >>

V3: >>

This was the Original query before it was solved.

So the example below is 3 Tabs, with the 3rd Tab having a Password Input Box and a Button, it Hides/Shows the Password field. The problem of course is the style can't be changed "on the fly" so it has to be deleted and then recreated. I admit I took some code from M23 and reorganised. :(

Test: Select the Button and it will display the Password (without the ****) If the Button is selected again it will hide the Password (with the ****)

Problem: Selecting Tab_1 & Tab_2 you will see the Input Box isn't there (of course) but once the Input is Deleted and Recreated, Voila! it appears in the other Tabs. I can sort of understand why if the ID was different, but I thought the ID of the Control would be attached to the TabItem and since the ID is the same (check console in SciTE) I can't think of a workaround. Well the worst case scenario is delete all Tabs and recreate again! :graduated:

I would really appreciate it if some could advise of a possible workaround. (I did search, but with no luck.) Thank you.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $GUI, $Input, $Button, $Msg

    $GUI = GUICreate("GUI", 220, 120)
    GUICtrlCreateTab(10, 10, 200, 100)
    GUICtrlCreateTabItem("Tab_1")
    GUICtrlCreateTabItem("Tab_2")
    GUICtrlCreateTabItem("Tab_3")
    GUICtrlSetState(-1, $GUI_SHOW)
    $Input = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
    $Button = GUICtrlCreateButton("Show", 140, 50, 50)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)

    While 1
        $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $Msg = $Button Then
            ConsoleWrite("ID Of Input Before >> " & $Input & @CRLF)
            _DisplayPassword($GUI, $Input) ; Show/Hide Password Input.

            Switch GUICtrlRead($Button) ; Change Button Text.
                Case "Show"
                    GUICtrlSetData($Button, "Hide")

                Case "Hide"
                    GUICtrlSetData($Button, "Show")

            EndSwitch
            ConsoleWrite("ID Of Input After >> " & $Input & @CRLF)
            ConsoleWrite("THE SAME!" & @CRLF)
        EndIf

    WEnd
EndFunc   ;==>_Main

Func _DisplayPassword($dHandle, $dInput)
    If Not IsDeclared("Global_DisplayPassword") Then Global $Global_DisplayPassword = 0
    Local $dInputStyle = -1
    Switch $Global_DisplayPassword
        Case 0
            $Global_DisplayPassword = 1
        Case 1
            $dInputStyle = 0x0020
            $Global_DisplayPassword = 0
    EndSwitch
    Local $dInputRead = GUICtrlRead($dInput)
    Local $dInputGetPos = ControlGetPos($dHandle, "", $dInput)
    GUICtrlDelete($dInput)
    Return GUICtrlCreateInput($dInputRead, $dInputGetPos[0], $dInputGetPos[1], $dInputGetPos[2], $dInputGetPos[3], $dInputStyle)
EndFunc   ;==>_DisplayPassword

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites



guinness,

From the Tabs tutorial in the Wiki: :graduated:

If you need to add controls after having ended the tab structure definiton, then you must use GUISwitch with the tabitemID parameter to select the correct tab before you create the control or you will find that it is visible on all tabs.

That should solve your problem. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks for the advice and sorry for using your name in the OP, I wasn't specifying that you should help me, merely praising you for your original function :( I was hoping the Tab UDF would be a last resort but I suppose I knew it was coming :graduated: Thank you.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

guinness,

No need for the Tab UDF - just do as I said. Look for the <<<<<<<<<<<<<<<<<<< lines: :graduated:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>

Global $GUI, $tab3, $dInput ; make these Global <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_Main()

Func _Main()
    Local $Button, $Msg

    $GUI = GUICreate("GUI", 220, 120)
    GUICtrlCreateTab(10, 10, 200, 100)
    GUICtrlCreateTabItem("Tab_1")
    GUICtrlCreateTabItem("Tab_2")
    $tab3 = GUICtrlCreateTabItem("Tab_3")
    GUICtrlSetState(-1, $GUI_SHOW)
    $dInput = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
    $Button = GUICtrlCreateButton("Show", 140, 50, 50)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)

    While 1
        $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $Msg = $Button Then
            ConsoleWrite("ID Of Input Before >> " & $dInput & @CRLF)
            _DisplayPassword() ; Show/Hide Password Input.

            Switch GUICtrlRead($Button) ; Change Button Text.
                Case "Show"
                    GUICtrlSetData($Button, "Hide")

                Case "Hide"
                    GUICtrlSetData($Button, "Show")
            EndSwitch
            ConsoleWrite("ID Of Input After >> " & $dInput & @CRLF)
            ConsoleWrite("THE SAME!" & @CRLF)
        EndIf

    WEnd
EndFunc   ;==>_Main

Func _DisplayPassword()
    If Not IsDeclared("Global_DisplayPassword") Then Global $Global_DisplayPassword = 0
    Local $dInputStyle = -1
    Switch $Global_DisplayPassword
        Case 0
            $Global_DisplayPassword = 1
        Case 1
            $dInputStyle = 0x0020
            $Global_DisplayPassword = 0
    EndSwitch
    Local $dInputRead = GUICtrlRead($dInput)
    Local $dInputGetPos = ControlGetPos($GUI, "", $dInput)
    GUICtrlDelete($dInput)
    GUISwitch($GUI, $tab3) ; Switch to the correct tab <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $dInput = GUICtrlCreateInput($dInputRead, $dInputGetPos[0], $dInputGetPos[1], $dInputGetPos[2], $dInputGetPos[3], $dInputStyle)
    GUICtrlCreateTabItem("") ; IMPORTANT - must reclose the tab definition here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    GUISwitch($GUI) ; Switch back to the main GUI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

EndFunc   ;==>_DisplayPassword

Told you! :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

THANKS! I have never heard of GUISwitch() I thought it meant the Switch...EndSwitch with GUIGetMsg() and then using the UDF InsertTab and check the CurrentFocus etc... So I learnt two things today. Wow! :graduated:

Example_1: (Thanks to Melba23)

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $hGUI, $iButton, $iInput, $iTab_3

    $hGUI = GUICreate("GUI", 220, 120)
    GUICtrlCreateTab(10, 10, 200, 100)
    GUICtrlCreateTabItem("Tab_1")
    GUICtrlCreateTabItem("Tab_2")
    $iTab_3 = GUICtrlCreateTabItem("Tab_3")
    GUICtrlSetState(-1, $GUI_SHOW)
    $iInput = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
    $iButton = GUICtrlCreateButton("Show", 140, 50, 50)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $iButton
                _DisplayPassword($hGUI, $iInput, $iTab_3) ; Show/Hide Password Input.

                Switch GUICtrlRead($iButton) ; Change Button Text.
                    Case "Show"
                        GUICtrlSetData($iButton, "Hide")

                    Case "Hide"
                        GUICtrlSetData($iButton, "Show")

                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func _DisplayPassword($hHandle, $iControlID, $iTab = -1)
    Local $aControlGetPos, $bExStyle = -1, $sRead
    If IsDeclared("Global_DisplayPassword") = 0 Then
        Global $Global_DisplayPassword = 0
    EndIf
    Switch $Global_DisplayPassword
        Case 0
            $Global_DisplayPassword = 1
        Case 1
            $bExStyle = 0x0020
            $Global_DisplayPassword = 0
    EndSwitch
    $sRead = GUICtrlRead($iControlID)
    $aControlGetPos = ControlGetPos($hHandle, "", $iControlID)
    GUICtrlDelete($iControlID)
    If $iTab <> -1 Then
        GUISwitch($hHandle, $iTab)
    EndIf
    $iControlID = GUICtrlCreateInput($sRead, $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], $bExStyle)
    If $iTab <> -1 Then
        GUICtrlCreateTabItem("")
        GUISwitch($hHandle)
    EndIf
    Return $iControlID
EndFunc   ;==>_DisplayPassword
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

guinness,

My pleasure as always. :graduated:

GUISwitch is one of those functions buried in the Help file that you very rarely use, but which is absolutely essential on certain occasions! :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

UPDATE: Now it supports Multiple Password Inputs. Before it was using a single Global Variable, but it has been optimised to use an Array to store the Input ControlID's and the respective state. See the Example for more details.

Example_2:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstantsEx.au3>

_Main()

Func _Main()
    Local $hGUI, $iButton_1, $iButton_2, $iButton_3, $iInput_1, $iInput_2, $iInput_3, $iTab_1, $iTab_3

    $hGUI = GUICreate("GUI", 220, 150)
    GUICtrlCreateTab(10, 10, 200, 100)
    $iTab_1 = GUICtrlCreateTabItem("Tab_1")
    $iInput_1 = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
    $iButton_1 = GUICtrlCreateButton("Show", 140, 50, 50)
    GUICtrlCreateTabItem("Tab_2")
    $iTab_3 = GUICtrlCreateTabItem("Tab_3")
    GUICtrlSetState(-1, $GUI_SHOW)
    $iInput_3 = GUICtrlCreateInput("", 20, 52.5, 110, 20, 0x0020)
    $iButton_3 = GUICtrlCreateButton("Show", 140, 50, 50)
    GUICtrlCreateTabItem("")
    $iInput_2 = GUICtrlCreateInput("", 20, 117.5, 110, 20, 0x0020)
    $iButton_2 = GUICtrlCreateButton("Show", 140, 115, 50)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit

            Case $iButton_1
                _DisplayPassword($hGUI, $iInput_1, $iTab_1) ; Show/Hide Password Input.

                Switch GUICtrlRead($iButton_1) ; Change Button Text.
                    Case "Show"
                        GUICtrlSetData($iButton_1, "Hide")

                    Case "Hide"
                        GUICtrlSetData($iButton_1, "Show")

                EndSwitch

            Case $iButton_2
                _DisplayPassword($hGUI, $iInput_2) ; Show/Hide Password Input. And Because It's Not In A Tab, We Don't Specify The Tab Variable.

                Switch GUICtrlRead($iButton_2) ; Change Button Text.
                    Case "Show"
                        GUICtrlSetData($iButton_2, "Hide")

                    Case "Hide"
                        GUICtrlSetData($iButton_2, "Show")

                EndSwitch

            Case $iButton_3
                _DisplayPassword($hGUI, $iInput_3, $iTab_3) ; Show/Hide Password Input.

                Switch GUICtrlRead($iButton_3) ; Change Button Text.
                    Case "Show"
                        GUICtrlSetData($iButton_3, "Hide")

                    Case "Hide"
                        GUICtrlSetData($iButton_3, "Show")

                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func _DisplayPassword($hHandle, $iControlID, $iTab = -1)
    Local $aControlGetPos, $bExStyle = -1, $iIndex = -1, $iType = 0, $sRead

    If IsDeclared("Global_DisplayPassword") = 0 Then
        Global $Global_DisplayPassword[1][2] = [[0, 2]]
    EndIf
    For $A = 1 To $Global_DisplayPassword[0][0]
        If @error Then
            ExitLoop
        EndIf
        If $Global_DisplayPassword[$A][0] = $iControlID Then
            $iIndex = $A
            $iType = $Global_DisplayPassword[$iIndex][1]
            ExitLoop
        EndIf
    Next

    If $iIndex = -1 Then
        If $Global_DisplayPassword[0][0] <= UBound($Global_DisplayPassword, 1) + 1 Then
            ReDim $Global_DisplayPassword[($Global_DisplayPassword[0][0] + 1) * 2][$Global_DisplayPassword[0][1]]
        EndIf
        $Global_DisplayPassword[0][0] += 1
        $iIndex = $Global_DisplayPassword[0][0]
        $Global_DisplayPassword[$iIndex][0] = $iControlID
        $Global_DisplayPassword[$iIndex][1] = $iType
    EndIf

    Switch $iType
        Case 0
            $Global_DisplayPassword[$iIndex][1] = 1
        Case 1
            $bExStyle = 0x0020
            $Global_DisplayPassword[$iIndex][1] = 0
    EndSwitch
    $sRead = GUICtrlRead($iControlID)
    $aControlGetPos = ControlGetPos($hHandle, "", $iControlID)
    GUICtrlDelete($iControlID)
    If $iTab <> -1 Then
        GUISwitch($hHandle, $iTab)
    EndIf
    $iControlID = GUICtrlCreateInput("", $aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[2], $aControlGetPos[3], $bExStyle)
    If $iTab <> -1 Then
        GUICtrlCreateTabItem("")
        GUISwitch($hHandle)
    EndIf
    GUICtrlSetData($iControlID, $sRead)
    Return $Global_DisplayPassword[$iIndex][1]
EndFunc   ;==>_DisplayPassword
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks entirely to smartee for pointing out this little trick. You can find the initial forum post here >> '?do=embed' frameborder='0' data-embedContent>>

Example_3:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI = GUICreate('GUI', 220, 120)
    GUICtrlCreateTab(10, 10, 200, 100)
    GUICtrlCreateTabItem('Tab_1')
    GUICtrlCreateTabItem('Tab_2')
    GUICtrlCreateTabItem('Tab_3')
    GUICtrlSetState(-1, $GUI_SHOW)
    Local $iInput = GUICtrlCreateInput('', 20, 52.5, 110, 20, $ES_PASSWORD)
    Local $iShow = GUICtrlCreateButton('Show', 140, 50, 50)
    GUICtrlCreateTabItem('')

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $iShow
                GUICtrlSetData($iShow, (_ShowPassword($hGUI, $iInput) ? 'Hide' : 'Show')) ; Show/Hide Password Input.

        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _ShowPassword($hWnd, $iControlID)
    Local Const $iPasswordCharacter = ((GUICtrlSendMsg($iControlID, $EM_GETPASSWORDCHAR, 0, 0) > 0) ? 0 : 9679) ; ChrW(9679) is the small bullet point.
    GUICtrlSendMsg($iControlID, $EM_SETPASSWORDCHAR, $iPasswordCharacter, 0)
    Local Const $aControlGetPos = ControlGetPos($hWnd, '', $iControlID) ; GUICtrlSetState($iControlID, $GUI_FOCUS)
    If Not @error Then
        Local Enum $CONTROLGETPOS_XPOS, $CONTROLGETPOS_YPOS, $CONTROLGETPOS_WIDTH, $CONTROLGETPOS_HEIGHT
        Local Const $tRECT = DllStructCreate($tagRECT)
        DllStructSetData($tRECT, 'Left', $aControlGetPos[$CONTROLGETPOS_XPOS])
        DllStructSetData($tRECT, 'Top', $aControlGetPos[$CONTROLGETPOS_YPOS])
        DllStructSetData($tRECT, 'Right', $aControlGetPos[$CONTROLGETPOS_XPOS] + $aControlGetPos[$CONTROLGETPOS_WIDTH])
        DllStructSetData($tRECT, 'Bottom', $aControlGetPos[$CONTROLGETPOS_YPOS] + $aControlGetPos[$CONTROLGETPOS_HEIGHT])
        _WinAPI_InvalidateRect($hWnd, $tRECT, False)
    EndIf
    Return $iPasswordCharacter = 0
EndFunc   ;==>_ShowPassword
Update: Thanks to >smartee. Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0