inputbox的输入字符能否控制,比如让输入的字都是*号,像密码的那种?
解决方案 »
- FormatFloat
- 关于delphi的编码问题,请大家帮我分析一下。
- 请问packed关键字有何用处
- 编译一个软件,为什么题是错误没有 Projects/Bpl/Psock.pas NMsmtp.pas文件(在线等)
- 怎样将一个文件夹下的内容全部复制给另一个文件夹??
- 基本控件的用法,请回答
- 谁有flatstyle控件for D6的?50分大放送!
- 怎样编写动态生成的checkbox的click事件???
- 如何取得Edit控件框中的光标位置?
- Delphi的TCustomADODataSet.CacheSize属性为何不起作用?(200分)
- CancelUpdates 的小问题
- 模糊查询的语句如何写正确
//SysUtils,
Graphics,
Controls,
Forms, Shlobj,
StdCtrls;
function MyInputQuery(const ACaption, APrompt: string;var Value: string): Boolean;
function MyInputBox(const ACaption, APrompt, ADefault: string): string;
implementationfunction GetAveCharSize(Canvas: TCanvas): TPoint;
var
I: Integer;
Buffer: array[0..51] of Char;
begin
for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));
for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
Result.X := Result.X div 52;
end; // 一个调整了字体的查询对话框
function MyInputQuery(const ACaption, APrompt: string;var Value: string): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
Result := False;
Form := TForm.Create(Application);
with Form do
try
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
BorderStyle := bsDialog;
Caption := ACaption;
ClientWidth := MulDiv(180, DialogUnits.X, 4);
ClientHeight := MulDiv(63, DialogUnits.Y, 8);
Position := poScreenCenter;
Prompt := TLabel.Create(Form);
with Prompt do
begin
Parent := Form;
//ADD By Aiming
Font.Name := 'Times New Roman';
Font.Size := 9;
layout := tlCenter;
//change By Aiming
AutoSize := False;
Left := MulDiv(8, DialogUnits.X, 4);
Top := 0;
Width := Muldiv(180-2*8,DialogUnits.X,4);
Height := Muldiv(18,DialogUnits.Y,8); // _EDIT.Top := MulDiv(19, DialogUnits.Y, 8);
WordWrap := True;
{
AutoSize := True;
Top := MulDiv(8, DialogUnits.Y, 8);
Left := MulDiv(8, DialogUnits.X, 4);
}
Caption := APrompt;
end;
Edit := TEdit.Create(Form);
with Edit do
begin
Parent := Form;
Left := Prompt.Left;
Top := MulDiv(19, DialogUnits.Y, 8);
Width := MulDiv(164, DialogUnits.X, 4);
passwordchar:='*'; // 就是这里
MaxLength := 20; //255
Text := Value;
SelectAll;
end;
ButtonTop := MulDiv(41, DialogUnits.Y, 8);
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
//ADD By Aiming
Font.Name := 'Times New Roman';
Font.Size := 9;
//Change by Aiming
Caption := '确认';
//Caption := SMsgDlgOK;
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
//ADD By Aiming
Font.Name := 'Times New Roman';
Font.Size := 9;
//Change by Aiming
Caption := '放弃';
//Caption := SMsgDlgCancel;
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(92, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
if ShowModal = mrOk then
begin
Value := Edit.Text;
Result := True;
end;
finally
Form.Free;
end;
end;function MyInputBox(const ACaption, APrompt, ADefault: string): string;
begin
Result := ADefault;
MyInputQuery(ACaption, APrompt, Result);
end;
end.