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 ...
随机推荐
- Redis中的事务及乐观锁的实现
介绍 Redis中的事务(transaction)是一组命令的集合. 事务同命令一样都是Redis最小的执行单位,一个事务中的命令要么都执行,要么都不执行. Redis事务的实现需要用 ...
- Python 中Semaphore 信号量对象、Event事件、Condition
Semaphore 信号量对象 信号量是一个更高级的锁机制.信号量内部有一个计数器而不像锁对象内部有锁标识,而且只有当占用信号量的线程数超过信号量时线程才阻塞.这允许了多个线程可以同时访问相同的代码区 ...
- svn版本服务器的搭建和简单使用
⼀ 服务器搭建篇 1 在”应⽤用程序”⽂文件夹下,找到”实⽤用⼯工具”,打开”终端”APP 2 运⾏行svnadmin create repository,运⾏行完毕之后,可以在当前⺫⽬目录下找 到⼀ ...
- Spring基础09——Bean的自动装配
1.XML配置的Bean自动装配 SpringIOC容器可以自动装配Bean,需要做的仅仅是在<bean>的autowire属性里指定自动装配的模式,而不需要手工去指定要装配的Bean,a ...
- ElasticSearch - 解决ES的深分页问题 (游标 scroll)
https://www.jianshu.com/p/f4d322415d29 1.简介 ES为了避免深分页,不允许使用分页(from&size)查询10000条以后的数据,因此如果要查询第10 ...
- Thinkphp5 手册
thinkphp5 手册 https://www.kancloud.cn/manual/thinkphp5/118003
- 001-supervisor
supervisor 使用教程(转) 原文地址:https://word.gw1770df.cc/2016-08-04/linux/supervisor-%E4%BD%BF%E7%94%A8%E6%9 ...
- 路径path知识点
1. 获取当前文件的路径 test.py os.path.abspath(path) # 返回当前文件运行的绝对路径 print("程序的绝对路径是",os.path.abspat ...
- linux软件操作
操作 命令 ubuntu 源操作 源配置 https://www.cnblogs.com/wenlin-gk/p/11146228.html 源更新 sudo apt-get update 查看源中包 ...
- 一、创建并打包Cordova的App工程
1.创建ionic4 & Angular项目 ionic start myApp tabs --type=angular 2.添加ios和android平台 ionic cordova pre ...

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