Ich hab mich mal daran versucht:
Ich hab es hinbekommen den Style zu ändern, es hat aber nichts geändert. Deshalb geh ich mal davon aus, dass dieser Satz aus der Hilfe zu GuiCtrlSetStyle für $ES_PASSWORD gilt:
"Some styles cannot be changed dynamically, check MSDN documentation. $CBS_UPPERCASE combo style is one example."
Von daher bleibt vermutlich nur der Workaround, zwei Controls zu erstellen und miteinander auszutauschen:
AutoIt
#include <WinAPI.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
Global $iWidth = 800, $iHeight = 600, $iSpace = 10
Local $hGui = GUICreate("Test", $iWidth, $iHeight)
Local $iInputWidth = $iWidth-$iSpace*3-100
Local $hInputPW = GUICtrlCreateInput("", $iSpace, $iSpace,$iInputWidth, 25, $ES_PASSWORD)
Local $hInputPWShow = GUICtrlCreateInput("", $iSpace, $iSpace,$iInputWidth, 25)
GUICtrlSetState($hInputPWShow, $GUI_HIDE)
Local $hButton = GUICtrlCreateButton("SHOW", $iSpace*2+($iInputWidth), $iSpace, 100, 25)
GUISetState(@SW_SHOW, $hGui)
While True
Local $iMsg = GUIGetMsg()
If $iMsg=-3 Then Exit
If $iMsg=$hButton Then _switchInput($hInputPW, $hInputPWShow)
WEnd
Func _switchInput($hInput, $hInputShow)
If BitAND(GUICtrlGetState($hInput), $GUI_SHOW) Then
GUICtrlSetData($hInputShow, GUICtrlRead($hInput))
GUICtrlSetState($hInput, $GUI_HIDE)
GUICtrlSetState($hInputShow, $GUI_SHOW)
Else
GUICtrlSetData($hInput, GUICtrlRead($hInputShow))
GUICtrlSetState($hInputShow, $GUI_HIDE)
GUICtrlSetState($hInput, $GUI_SHOW)
EndIf
EndFunc
#cs
Func _switchInput($hInput)
Local $iStyle = GUICtrlGetStyle($hInput)[0]
ConsoleWrite("Res: "&$ES_PASSWORD&" >> "&BitAND($iStyle, $ES_PASSWORD)&@crlf)
If BitAND($iStyle, $ES_PASSWORD) Then
ConsoleWrite("ON: "&BitXOR($iStyle, $ES_PASSWORD)&@crlf)
GUICtrlSetStyle($hInput, BitXOR($iStyle, $ES_PASSWORD))
Else
ConsoleWrite("OFF: "&BitOr($iStyle, $ES_PASSWORD)&@crlf)
GUICtrlSetStyle($hInput, BitOr($iStyle, $ES_PASSWORD))
EndIf
EndFunc
; #FUNCTION# ====================================================================================================================
; Name ..........: GUICtrlGetStyle
; Description ...: Retrieves the Styles/ExStyles value(s) of a control.
; Syntax ........: GUICtrlGetStyle($hWnd)
; Parameters ....: $hWnd - Control ID/Handle to the control
; Return values .: $aArray[2] = [Style, ExStyle]
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func GUICtrlGetStyle($hWnd)
If Not IsHWnd($hWnd) Then
$hWnd = GUICtrlGetHandle($hWnd)
EndIf
Local $aReturn = [_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)]
Return $aReturn
EndFunc ;==>GUICtrlGetStyle
#ce
Alles anzeigen
Ich hab meine Versuch, den Style dynamisch zu wechseln mal drin gelassen. Vielleicht kann den mal jemand bei anderen Styles gebrauchen.
Ich hoffe das hilft dir weiter