eEniquEe Posted July 9, 2011 Posted July 9, 2011 (edited) Hello everyone,I wonder if there's a way to change the $ES_PASSWORD style of an Input without having to delete, and re-create it? I did try to use the GUICtrlSetStyle() function, but it doesn't seem to work. For the convinience, I'll put what I have here. So basically, what I want is that the $ES_PASSWORD style of $Input2 will change in according with the user checking the checkbox. I can do it by deleting and re-creating the $Input2. But this seems not very covenient. Is there some other way to work around?expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\Travian Log-In.kxf Global $Blank[5] $Form1 = GUICreate("Log-in Form", 633, 130, -1, -1) $Label1 = GUICtrlCreateLabel("Please enter your log-in information below. If you forget your password, please click on the Forget Password button.", 8, 8, 545, 17) $Label2 = GUICtrlCreateLabel("Username:", 152, 40, 55, 17) $Label3 = GUICtrlCreateLabel("Pass:", 152, 64, 30, 17) $Input1 = GUICtrlCreateInput("Please enter your username here", 208, 37, 241, 21) GUICtrlSetFont(-1, 8, 400, 2, "MS Sans Serif") GUICtrlSetColor(-1, 0x808080) $Input2 = GUICtrlCreateInput("", 208, 61, 241, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Button1 = GUICtrlCreateButton("Log In", 136, 96, 113, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Forget Password", 264, 96, 113, 25, $WS_GROUP) $Button3 = GUICtrlCreateButton("Exit", 392, 96, 113, 25, $WS_GROUP) $Checkbox1 = GUICtrlCreateCheckbox("Show Password", 472, 64, 97, 17) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) For $Temp = 0 To 4 $Blank[$Temp] = 0 Next #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Button3 Exit Case $Checkbox1 CheckCheckBox() EndSwitch WEnd Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0xFFFF) $hCtrl = $lParam If $nID = $Input1 Then If $nNotifyCode = $EN_SETFOCUS Then If $Blank[0] = 0 Then GUICtrlSetData($Input1, "") GUICtrlSetFont($Input1, 8, 400, 0, "MS Sans Serif") GUICtrlSetColor($Input1, 0x000000) EndIf Else If $nNotifyCode = $EN_KILLFOCUS Then $a = GUICtrlRead($Input1) If $a <> "" And $a <> "Please enter your username here" Then $Blank[0] = 1 Else $Blank[0] = 0 GUICtrlSetData($Input1, "Please enter your username here") GUICtrlSetFont($Input1, 8, 400, 2, "MS Sans Serif") GUICtrlSetColor($Input1, 0x808080) EndIf EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Func CheckCheckBox() If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $a = GUICtrlRead($Input2) GUICtrlDelete($Input2) $Input2 = GUICtrlCreateInput($a, 208, 61, 241, 21) Else $a = GUICtrlRead($Input2) GUICtrlDelete($Input2) $Input2 = GUICtrlCreateInput($a, 208, 61, 241, 21, $ES_PASSWORD) EndIf EndFuncThanks everyone in advance, Edited July 9, 2011 by eEniquEe
Moderators Melba23 Posted July 9, 2011 Moderators Posted July 9, 2011 eEniquEe,Search (that little box at top right ) threw up this which should help you. 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 Â
eEniquEe Posted July 9, 2011 Author Posted July 9, 2011 OMG... I feel ssssssoooooo guilty for not noticing that Search Box. :D :D I'm sorry... Thank you very very much, that solves it. I'll search carefully before creating new thread from now on, I promise.
smartee Posted July 9, 2011 Posted July 9, 2011 You might also want to check out if you want neater and more re-usable code that doesn't throw focus onto the input
eEniquEe Posted July 11, 2011 Author Posted July 11, 2011 Sorry for my late respond. Thank you very much smartee. Your way is very elegant, and neat. Thanks,
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