比如弹出的对话框中有确定和取消两个按钮不过还有一个Exit编辑框,我可以在里面输入一些信息,例如:定时。然后可以在程序中将其取出!
谢谢各位!
谢谢各位!
解决方案 »
- 请问Combobox如何设置文本垂直居中?
- 高手请进!!!!!!!!
- 自定义函数中,不能带两个不同数据类型的参数吗?
- 请教:在使用DELPHI 5 制作DLL时,如何同时生成DLL文件及LIB文件?
- 如何将数据库的日期字段用DateTimePicker显示出来,并将DateTimePicker修改的日期写入数据库中
- DBGrid和StringGrid的问题,高手请进。
- 翻遍了所有贴子都没有谁能解决对Ado多表联结查询结果更新时,Ado自作主张将多表都进行更新的问题,请斑竹主持公道……
- 数据库排序
- 如何模拟按键?
- 一个比较难的问题,谁能将这段VC的代码转成Delphi的。。。高手请进
- 怎样把WebBrowser1浏览的网页生成为一幅图片
- 怎么样在任务态栏关闭程序的时候有提示?
s:string;
begin
s:=InputBox('Input Box', 'Prompt', 'Default string');
showmessage( s );
end;
var
s:string;
function InputQuery(const ACaption, APrompt: string;
var Value: string): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
function 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;
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);
Position := poScreenCenter;
Prompt := TLabel.Create(Form);
with Prompt do
begin
Parent := Form;
Caption := APrompt;
Left := MulDiv(8, DialogUnits.X, 4);
Top := MulDiv(8, DialogUnits.Y, 8);
Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
WordWrap := True;
end;
Edit := TEdit.Create(Form);
with Edit do
begin
Parent := Form;
Left := Prompt.Left;
Top := Prompt.Top + Prompt.Height + 5;
Width := MulDiv(164, DialogUnits.X, 4);
MaxLength := 255;
Text := Value;
SelectAll;
end;
ButtonTop := Edit.Top + Edit.Height + 15;
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := '确定';
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := '取消';
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
ButtonWidth, ButtonHeight);
Form.ClientHeight := Top + Height + 13;
end;
if ShowModal = mrOk then
begin
Value := Edit.Text;
Result := True;
end;
finally
Form.Free;
end;
end;
begin
InputQuery('标题', '标签',s);
showmessage( s );
end;