(已解决)更改文本框输入的密码的显示状态,谢谢afan跟lynfr8
本帖最后由 xyhqqaa 于 2011-11-20 04:52 编辑新手,想更改文本框的显示状态,当星号打钩的时候,输入为星号字符。星号去掉的时候,则显示为明文状态。。。。搜索论坛好像没看到。。囧#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 108, 272, 233)
$Checkbox1 = GUICtrlCreateCheckbox("星号", 312, 32, 97, 57)
GUICtrlSetState($Checkbox1,$gui_checked)
$Input1 = GUICtrlCreateInput("Input1", 64, 48, 225, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd _GUICtrlEdit_SetPasswordChar() 回复 2# afan 谢谢A版哥。。您给的这个参数。俺慢慢消化下。。刚搜索看到顽固不化大哥的一个相类似的例子。。改了下可用。。但还是需要慢慢消化...谢谢您。。。。#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 108, 272, 233)
$Checkbox1 = GUICtrlCreateCheckbox("星号", 312, 32, 97, 57)
GUICtrlSetState($Checkbox1, $gui_checked)
$Input1 = GUICtrlCreateInput("Input1", 64, 48, 225, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
$yes = False
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
$a = GUICtrlRead($Input1)
GUICtrlDelete($Input1)
If $yes = False Then
$Input1 = GUICtrlCreateInput("",64, 48, 225, 21, $ES_AUTOHSCROLL)
$yes = True
Else
$Input1 = GUICtrlCreateInput("",64, 48, 225, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
$yes = False
EndIf
GUICtrlSetData($Input1, $a)
EndSwitch
WEnd _GUICtrlEdit_SetPasswordChar()看不懂- -阿门。。。。 回复 4# xyhqqaa #include <GuiEdit.au3>
$Form1 = GUICreate('Form1', 496, 108)
$Checkbox1 = GUICtrlCreateCheckbox('星号', 312, 32, 97, 57)
GUICtrlSetState(-1, 1)
$Input1 = GUICtrlCreateInput('Input1', 64, 48, 225, 21, $ES_PASSWORD)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Checkbox1
If GUICtrlRead($nMsg) = 4 Then
_GUICtrlEdit_SetPasswordChar($Input1)
Else
_GUICtrlEdit_SetPasswordChar($Input1, '*')
EndIf
GUICtrlSetState($Input1, 256)
_GUICtrlEdit_SetSel($Input1, -1, -1)
EndSwitch
WEnd _GUICtrlEdit_SetPasswordChar()看不懂- -阿门。。。。
xyhqqaa 发表于 2011-11-19 17:27 http://www.autoitx.com/images/common/back.gif
看帮助 回复 4# xyhqqaa #include <GuiEdit.au3>
$Form1 = GUICreate('Form1', 496, 108)
$Checkbox1 = GUICtrlCreateCheckbox('星号', 312, 32, 97, 57)
GUICtrlSetState(-1, 1)
$Input1 = GUICtrlCreateInput('Input1', 64, 48, 225, 21, $ES_PASSWORD)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Checkbox1
$show = GUICtrlRead($Input1)
GUICtrlDelete($Input1)
If GUICtrlRead($nMsg) = 4 Then
$Input1 = GUICtrlCreateInput($show, 64, 48, 225, 21)
Else
$Input1 = GUICtrlCreateInput($show, 64, 48, 225, 21, $ES_PASSWORD)
EndIf
EndSwitch
WEnd这个简单能看懂了吧? 回复 7# lynfr8
谢谢lynfr8大哥。。。谢谢。。。。伸手党鸭梨大。。。囧。。。 回复 6# lpxx
谢谢关注。。看了帮助看不明白用法。。。。A版那例子让俺活了囧。。知道伸手不好。。。 回复 9# xyhqqaa
_GUICtrlEdit_SetPasswordChar
--------------------------------------------------------------------------------
设置或清除编辑控件的密码字符
#Include <GuiEdit.au3>
_GUICtrlEdit_SetPasswordChar($hWnd[, $cDisplayChar = "0"])
参数
$hWnd 控件句柄
$cDisplayChar [可选参数] 用户输入字符的显示字符
如果此参数 0,则删除当前密码字符,显示用户直接输入的字符AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiEdit.au3>
#include <GuiConstantsEx.au3>
Opt('MustDeclareVars', 1)
$Debug_Ed = False ; 检查传递给 Edit 函数的类名, 设置为True,并使用另一个控件句柄,看看它的工作.
_Main()
Func _Main()
Local $hEdit
; 创建 GUI
GUICreate("(Internal) Edit 设置或清除编辑控件的密码字符", 400, 300)
$hEdit = GUICtrlCreateInput("控件内部测试", 2, 2, 394, 25, $ES_PASSWORD)
GUISetState()
MsgBox(4096, "提示", "密码字符: " & _GUICtrlEdit_GetPasswordChar($hEdit))
_GUICtrlEdit_SetPasswordChar($hEdit, "$") ; 更改密码字符为 $
MsgBox(4096, "提示", "密码字符: " & _GUICtrlEdit_GetPasswordChar($hEdit))
_GUICtrlEdit_SetPasswordChar($hEdit) ; 用户输入的显示字符.
MsgBox(4096, "提示", "密码字符: " & _GUICtrlEdit_GetPasswordChar($hEdit))
; 循环到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
帮助文件已经表达得够清楚了 回复 10# lynfr8
恩恩 - -.//之前看了例子,脑子没反应过来///{:face (368):} 新手努力中....谢谢 又知道了_GUICtrlEdit_SetPasswordChar()
页:
[1]