Code : Tout sélectionner
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
$Form1 = GUICreate("Change Password Style", 350, 150, 192, 125)
$Input1 = GUICtrlCreateInput("Password 1", 48, 32, 121, 21, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("Password 2", 48, 64, 121, 21, -1, $WS_EX_CLIENTEDGE)
$On1 = GUICtrlCreateButton("On", 200, 32, 55, 25)
$Off1 = GUICtrlCreateButton("Off", 260, 32, 55, 25)
$On2 = GUICtrlCreateButton("On", 200, 62, 55, 25)
$Off2 = GUICtrlCreateButton("Off", 260, 62, 55, 25)
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
case $msg = $On1
_GuiCtrlEditChangePasswordChar($Input1)
case $msg = $Off1
_GuiCtrlEditChangePasswordChar($Input1, '')
case $msg = $On2
_GuiCtrlEditChangePasswordChar2($Input2)
case $msg = $Off2
_GuiCtrlEditChangePasswordChar2($Input2, '')
Case Else
;
EndSelect
WEnd
Exit
Func _GuiCtrlEditChangePasswordChar(ByRef $h_edit, $s_newchar = '*')
Local const $EM_SETPASSWORDCHAR = 0xCC
GUISetState(@SW_LOCK)
If StringInStr(@OSVersion,"WIN_XP") And @NumParams = 1 Then
Local $s_text = GUICtrlRead($h_edit)
Local $pos = ControlGetPos(WinGetTitle(""),"",$h_edit)
GUICtrlDelete($h_edit)
$h_edit = GUICtrlCreateInput($s_text, $pos[0], $pos[1], $pos[2], $pos[3], $ES_PASSWORD, $WS_EX_CLIENTEDGE)
Else
GUICtrlSetStyle($h_edit, $ES_PASSWORD ,$WS_EX_CLIENTEDGE)
GUICtrlSendMsg($h_edit, $EM_SETPASSWORDCHAR, Asc($s_newchar), 0)
EndIf
GUISetState(@SW_UNLOCK)
EndFunc
Func _GuiCtrlEditChangePasswordChar2(ByRef $h_edit, $s_newchar = '*')
Local const $EM_SETPASSWORDCHAR = 0xCC
GUISetState(@SW_LOCK)
GUICtrlSetStyle($h_edit, $ES_PASSWORD ,$WS_EX_CLIENTEDGE)
GUICtrlSendMsg($h_edit, $EM_SETPASSWORDCHAR, Asc($s_newchar), 0)
GUISetState(@SW_UNLOCK)
EndFunc