如何隐藏编辑框中的密码文本?
我有一个输入框,希望用户输入密码,但同时隐藏它。
这可能吗?
到目前为止,这是我的代码:
var password : string;
begin
password := InputBox('Password: ', 'Please enter your password: ', password)
end;
I have an inputbox and would like the user to enter a password, but at the same time hide it.
Is this possible?
This is my code so far:
var password : string;
begin
password := InputBox('Password: ', 'Please enter your password: ', password)
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您“不能”使用
InputBox
来实现此目的,因为,嗯......显然这个函数不会隐藏文本。不过,标准 Windows 编辑控件具有“密码模式”。要对此进行测试,只需将
TEdit
添加到表单并将其PasswordChar
设置为*
。如果你想在输入框中使用这样的编辑,你必须自己编写这个对话框,就像我的“超级输入对话框”:
尝试一下:
You 'cannot' use
InputBox
for this, because, well... clearly this function doesn't hide the text.The standard Windows edit control has a 'password mode', though. To test this, simply add a
TEdit
to a form and set itsPasswordChar
to*
.If you want to use such an edit in an input box, you have to write this dialog yourself, like my 'super input dialog':
Try it:
这看起来像是在这里得到了回答:
Delphi InputBox 用于密码输入?
This looks like it was answered here:
Delphi InputBox for password entry?
不要使用
InputBox
。自己创建一个对话框,并确保将TEdit.PasswordChar
设置为#0
以外的其他值。也可以通过 Windows 消息获取 InputBox 的编辑控件的句柄并设置
PasswordChar
,但我不知道如何做到这一点(特别是因为InputBox 是一个阻塞调用)。Delphi XE 还有一个
密码对话框
表单可供在创建新表单时使用。旧版本可能也是如此,XE 恰好是我现在运行的。 (编辑 Delphi 2007 也有它。2007 和 XE 是我现在安装的唯一版本的 Delphi,所以我无法验证任何其他版本。)Don't use an
InputBox
. Create a dialog yourself and make sure to setTEdit.PasswordChar
to something other than#0
.It may also be possible to get a handle to the InputBox's Edit control and set the
PasswordChar
via a Windows message, but I don't know how to do that off the top of my head (especially since the InputBox is a blocking call).Delphi XE also has a
Password Dialog
form available to use when creating a new form. Older versions probably do too, XE just happens to be what I have running right now. (Edit Delphi 2007 also has it. 2007 & XE are the only versions of Delphi I have installed right now though, so I can't verify any other versions.)我认为您还需要设置:
至少对于 TdlcxLabeledDBTextEdit。
I think you also need to set:
At least for TdlcxLabeledDBTextEdit.