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 xe5 android 使用system.zip单元释放资源文件

Delphi 用firedac处理sqlite的日期型

Delphi 获取鼠标坐标大全方法

Delphi 防止程序重复执行(多种方法)

Delphi d10.x安卓app开发中简单使用原生toast

Delphi开发桌面图标列表查看程序

Delphi 2009 的反射单元(objauto):

Delphi编写dll(以及静态和动态方式调用)

Delphi 基础学习 字符串去掉回车符

Delphi 官方使用并行编程库介绍

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



打赏

取消

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

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

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

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

评论

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