delphi中的inpubox,如何能控制它的位置? 10
- https://zhidao.baidu.com/question/153270855.html
- delphi中的inpubox,如何能控制它的位置? 10
最佳答案
inputbox封装的是InputQuery函数,你可以查看InputQuery的源代码,发现在InputQuery函数里面动态创建了一个窗体,你可以把InputQuery函数的源代码复制出来,自己修改成可控制位置的就行了 unit inputboxExs; interface uses Windows, Graphics, Forms, StdCtrls, Consts, Dialogs, Controls; function InputQueryEx(const ACaption, APrompt: string;
var Value: string; X, Y: Integer): Boolean; function InputBoxEx(const ACaption, APrompt, ADefault: string; X, Y: Integer): string; implementation 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; function InputQueryEx(const ACaption, APrompt: string;
var Value: string; X, Y: Integer): 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);
Left := X;
Top := Y;
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 := SMsgDlgOK;
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := SMsgDlgCancel;
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; function InputBoxEx(const ACaption, APrompt, ADefault: string; X, Y: Integer): string;
begin
Result := ADefault;
InputQueryEx(ACaption, APrompt, Result, X, Y);
end; 以上是源代码,在Delphi源代码基础上稍微修改了下,我单独写在了一个文件中,使用时需要引用我这个单元文件,下面是调用示例:
uses inputboxExs; procedure TForm1.Button2Click(Sender: TObject);
var str1, str2: string;
begin
// 参数中的X,Y,就是你想设置的位置
str1 := InputBoxEx('注意', '输入数字', str2, 100, 10);
ShowMessage(str1);
end;
其他回答
为您推荐:
其他类似问题
- 2012-02-02delphi中运用输入消息框inputbox如何限制只能输入...
- 2009-04-20关于DELPHI的InputBox6
- 2015-12-12怎样让delphi的inputbox输入框显示密码代表符
- 2011-10-01Delphi中如果要在DBCombobox里边加入选项,应该...
- 2014-10-28delphi中用scrollbox怎么做房态图
delphi的相关知识
- 2009-12-29Delphi控件太多!!! 32
- 2010-12-13DELPHI连接数据库问题 38
- 2010-02-12DELPHI 的程序很大 9
- 2006-12-31delphi 字符串长度 14
- 2008-10-28delphi查找控件 12
还没有百度账号?
立即注册


精彩知识在知道
delphi中的inpubox,如何能控制它的位置? 10的更多相关文章
- 在Delphi中如何控制其它应用程序窗口
在编写Delphi的应用程序中,常常涉及对其它Windows应用程序的操作.例如,在数据库的管理系统中,财务人员需要使用计算器,即可调用Windows内含的计算器功能,若每次使用,均通过“开始/程序/ ...
- Delphi 中多线程同步的一些处理方法
Delphi 中多线程同步的一些处理方法 当创建了多个线程,并且多个线程都要访问同一资源,,就有可能出现混乱,于是用Synchronize来控制,使同一时间只有一个线程使用那部分资源,Synchr ...
- ActiveX数据对象之事务控制在VB和DELPHI中的应用
本文发表在中国人民解放军"信息工程大学"学报 2001年第3期. ActiveX数据对象之事务控制在VB和DELPHI中的应用 ...
- Delphi中控制Excel(转载)
用Delphi从数据库中取得资料,然后导出到Excel中做成报表是个不错的选择,因为Excel强大的报表功能那可是没话说前提Delphi中要 uses comobj;var Excel:Variant ...
- Delphi中exit、break、continue等跳出操作的区别
Delphi中表示跳出的有break,continue,abort,exit,halt,runerror等 1.break 强制退出最近的一层循环(注意:只能放在循环里:而且是只能跳出最近的一层循环) ...
- Delphi中CoInitialize之探究
CoInitialize(LPVOID),它将以特定参数调用CoInitializeEx,为当前单元初始化COM库,并标记协同模式为单线程模式.参数必须为NULL.这是关于OLE和COM的问题. Co ...
- 用SPCOMM 在 Delphi中实现串口通讯 转
用Delphi 实现串口通讯,常用的几种方法为:使用控件如MSCOMM和SPCOMM,使用API函数或者在Delphi 中调用其它串口通讯程序.利用API编写串口通信程序较为复杂,需要掌握大量通信 ...
- delphi中表示跳出的有break,continue, exit,abort, halt, runerror
1.break 强制退出循环(只能放在循环中),用于从For语句,while语句或repeat语句中强制退出. 2.continue 用于从For语句,while语句或repeat语句强行结束本次 ...
- Delphi中编辑word
其他(28) //启动Word try wordapplication1.connect; except messagedlg('word may not be ins ...
随机推荐
- php中引入facebook的messenger消息接口
前一段时间需要开发一个messenger的消息接口,但是facebook的官方文档似是而非,而且由于在国内比较小众,之前也没有另外的人写过中文的开发教程,只好自己进行了一番研究并完成了一个demo,希 ...
- k3 cloud注册插件的时候提示,请选择一个有效的插件程序集
插件类的访问类型需要是public类型的,由于你的插件类没有标记为public类型,所以注册的时候并没有发现有插件,就是下面的单据体没有加载出数据.标记public之后,下面会有你的插件,然后选择对应 ...
- 简单的物流项目实战,WPF的MVVM设计模式(一)
新建一个WPF项目,命名为WMS 然后分别新建文件夹,Data,Models,Views,ViewModels,Services,如下图所示 然后通过NuGet安装连个Nuget包,分别为SQLite ...
- vue创建项目配置脚手架vue-cli环境出错
1.at process._tickCallback (internal/process/next_tick.js:188:7) npm ERR! message: 'request to http ...
- PAT Advanced 1058 A+B in Hogwarts (20 分)
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- a ...
- PAT Advanced 1007 Maximum Subsequence Sum (25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to ...
- Listview四种视图VIEW
http://wenku.baidu.com/link?url=65Ac8WL6j8KZwDlN8LyoxqFF5Jynvg80LnKc4jqTPQTY-59wwRDKhqGySYwxf6gZ9_6T ...
- 3.docker镜像管理基础
一.docker镜像相关 1.About Docker Image Docker镜像含有启动容器所需要的文件系统及其内容,因此,其用于创建并启动docker容器. 采用分层构建机制,最底层为bootf ...
- 对includes的研究
1.includes() 方法用来判断一个数组是否包含一个指定的值,如果是返回 true,否则false. 2.let site = ['runoob', 'google', 'taobao']; s ...
- sql server 修改表字段
1.添加表说明 EXECUTE sp_addextendedproperty N'MS_Description','表说明',N'user',N'dbo',N'table',N'表名',NULL,NU ...

房价上海
网游客户端
吉他价格