Delphi Inputbox 输入时显示*号


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

const InputboxMessage = WM_USER + 200;   //定义消息

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
  procedure InputboxPassword(var MSG: TMessage); message InputBoxMessage;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PostMessage(Handle,InputboxMessage,0,0);             //发送消息
  inputbox('a','b','ssss')
end;

procedure TForm1.InputboxPassword(var MSG: TMessage);
var
  InputForm,Hedit: THandle;
begin
  InputForm:= Screen.Forms[0].Handle;
  if InputForm <> 0 then
  begin
  Hedit:= FindWindowEx(InputForm,0,'Tedit',nil);
  SendMessage(Hedit,EM_SETPASSWORDCHAR,Ord('*'),0);
end;

end;

end.

例:
procedure TForm2.Image1DblClick(Sender: TObject);
begin
    PostMessage(Handle,InputboxMessage,0,0);
  if (inputbox('授权','请输入授权码','')='5avip.net') then
     Label5.Visible :=true
   else
   begin
     exit;
     Application.Terminate;
   end;
end;

相关阅读 >>

Delphi 控制台读写

Delphi xe 减少程序体积!

Delphi ado组件动态连接access数据库

Delphi 7中ado控件打开access数据库文件

Delphi httpclient async异步获取网页代码

Delphi获取闲置时间

dekphi qq自动发消息源码

Delphi copy 从字符串中复制指定范围中的字符

Delphi shgetfileinfo函数

Delphi 改变位图图片大小

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...