Art*_*hur 14 delphi mask textinput inputbox
输入框:
answer:=Inputbox('a','b','c');
工作得很好,但我正在寻找一个蒙面的,就像一个密码盒,你只看到小星星而不是键入的字符.
Rem*_*eau 34
在XE2中,InputBox()并且InputQuery()更新为本机支持屏蔽TEdit输入,尽管尚未记录该功能.如果APrompt参数的第一个字符设置为任何值< #32则将TEdit.PasswordChar设置为*,例如:
answer := InputBox('a', #31'b', 'c');
ove*_*ked 26
您可以将Windows消息发送到由其创建的编辑控件InputBox,该消息将标记用于输入密码的编辑控件.以下代码摘自http://www.swissdelphicenter.ch/en/showcode.php?id=1208:
const
   InputBoxMessage = WM_USER + 200;
type
   TForm1 = class(TForm)
     Button1: TButton;
     procedure Button1Click(Sender: TObject);
   private
     procedure InputBoxSetPasswordChar(var Msg: TMessage); message InputBoxMessage;
   public
   end;
var
   Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.InputBoxSetPasswordChar(var Msg: TMessage);
var
   hInputForm, hEdit, hButton: HWND;
begin
   hInputForm := Screen.Forms[0].Handle;
   if (hInputForm <> 0) then
   begin
     hEdit := FindWindowEx(hInputForm, 0, 'TEdit', nil);
     {
       // Change button text:
       hButton := FindWindowEx(hInputForm, 0, 'TButton', nil);
       SendMessage(hButton, WM_SETTEXT, 0, Integer(PChar('Cancel')));
     }
     SendMessage(hEdit, EM_SETPASSWORDCHAR, Ord('*'), 0);
   end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
   InputString: string;
begin
   PostMessage(Handle, InputBoxMessage, 0, 0);
   InputString := InputBox('Input Box', 'Please Enter a Password', '');
end;
| 归档时间: | 
 | 
| 查看次数: | 21827 次 | 
| 最近记录: |