想問一下,我創建的一個form的位置在edit的下方位置,如何做呢 也就是設它的絕對位置,如何做呢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 eidt下方放个panel,创建form的parent设置为该panel--------------------------------------------------------------------看尽悲伤,庸人自扰不平事。叹尽荒凉,海阔天空谁人知。狂风劲兮,百花飘扬乱舞香。捏花一笑,海不扬波断肠心! implementationuses unit2;procedure TForm1.Button1Click(Sender: TObject);begin form2.Top:=form1.Top+(form1.Height-form1.ClientHeight)+edit1.Top+edit1.Height; form2.ShowModal;end; 你看看吧!!!unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Edit1: TEdit; procedure Edit1Click(Sender: TObject); private { Private declarations } Function GetScreenZB(var Ed:TEdit;Form:TForm):TPoint; public { Public declarations } end;var Form1: TForm1;implementationuses Unit2;{$R *.DFM}Function TForm1.GetScreenZB(var Ed:TEdit;Form:TForm):TPoint;var iCont:TControl; xx,yy:integer; Ret:TPoint;begin xx:=ed.Left; yy:=ed.Top; iCont:=Ed; // while not(iCont is TForm) do begin iCont:=iCont.Parent; xx:=xx + icont.left; yy:=yy + iCont.Top; end; // xx:=xx + 4; yy:=yy + Ed.Height + 20; // if Screen.Width - xx <= Width then begin xx:= xx - (Form.Width - Ed.Width); end; if Screen.Height - yy <= Height then begin yy:= yy - (Form.Height + Ed.Height) +4 ; end; // if xx<0 then xx:=0; // if yy<0 then yy:=0; // Ret.x:=xx; Ret.y:=yy; Result:=Ret;end;procedure TForm1.Edit1Click(Sender: TObject);var pp:Tpoint;begin pp:=GetScreenZB(edit1,Form2); form2.left:=pp.x; form2.top:=pp.y; form2.showmodal;end;end. delphi 右键菜单问题 [求教]如何判断窗体里面是否存在某种控件 ConnectionString和PageControl(大虾过来) 求合并两表的SQL语句 如何启动程序的问题 惭愧呀,又诞生了一个两星水货~ 谁有FastReport报表导出控件PsFRExportFilters注册版? 怎么样让一个label中的两个字不是横着显示,而是竖着显示, 关于DataSet返回当前行的问题 北京资深程序员寻兼职,有展示作品! && 询个价 关于VirtualQueryEx函数。
--------------------------------------------------------------------
看尽悲伤,庸人自扰不平事。叹尽荒凉,海阔天空谁人知。狂风劲兮,百花飘
扬乱舞香。捏花一笑,海不扬波断肠心!
uses unit2;procedure TForm1.Button1Click(Sender: TObject);
begin
form2.Top:=form1.Top+(form1.Height-form1.ClientHeight)+edit1.Top+edit1.Height;
form2.ShowModal;
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
procedure Edit1Click(Sender: TObject);
private
{ Private declarations }
Function GetScreenZB(var Ed:TEdit;Form:TForm):TPoint;
public
{ Public declarations } end;var
Form1: TForm1;implementationuses Unit2;{$R *.DFM}Function TForm1.GetScreenZB(var Ed:TEdit;Form:TForm):TPoint;
var
iCont:TControl;
xx,yy:integer;
Ret:TPoint;
begin
xx:=ed.Left;
yy:=ed.Top;
iCont:=Ed;
//
while not(iCont is TForm) do
begin
iCont:=iCont.Parent;
xx:=xx + icont.left;
yy:=yy + iCont.Top;
end;
//
xx:=xx + 4;
yy:=yy + Ed.Height + 20;
//
if Screen.Width - xx <= Width then
begin
xx:= xx - (Form.Width - Ed.Width);
end;
if Screen.Height - yy <= Height then
begin
yy:= yy - (Form.Height + Ed.Height) +4 ;
end;
//
if xx<0 then xx:=0;
//
if yy<0 then yy:=0;
//
Ret.x:=xx;
Ret.y:=yy;
Result:=Ret;
end;procedure TForm1.Edit1Click(Sender: TObject);
var
pp:Tpoint;
begin
pp:=GetScreenZB(edit1,Form2);
form2.left:=pp.x;
form2.top:=pp.y;
form2.showmodal;
end;end.