| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1312 人关注过本帖
标题:编写一个过程可以移动panel的問題,加急呀
只看楼主 加入收藏
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
收藏
 问题点数:0 回复次数:5 
编写一个过程可以移动panel的問題,加急呀

大家再帮帮忙呀,
这个是我产生新panel的过程,
procedure TMainForm.Button1Click(Sender: TObject);
var i,u,x0:integer;
a:array of tpanel

begin
setlength(a,u);
x0:=50;
u:=strtoint(edit1.Text);
for i:=1 to u do
begin
a[i]:=tpanel.Create(self);
a[i].Parent:=self;
a[i].Enabled:=true;
a[i].Visible:=true;
a[i].Left:=x0;
a[i].Top :=100;
a[i].Width:=50;
x0:=x0+150+10;
end;
end;
这个是我自定义的移动panel的过程:
procedure TMainForm.ButtonMove(Sender: TObject;P:TPanel;Shift: TShiftState; X,Y: Integer);
begin
if (x>=0)and(x<=3) then
begin
if (y>=0)and(y<=3) then P.Cursor:=crSizeNWSE;
if (y>3)and(y<P.Height-3) then P.Cursor:=crSizeWE;
if (y>=P.Height-3)and(y<=P.Height) then P.Cursor:=crSizeNESW;
end
else if (x>3)and(x<P.Width-3) then
begin
if (y>=0)and(y<=3) then P.Cursor:=crSizeNS;
if (y>3)and(y<P.Height-3) then P.Cursor:=crArrow;
if (y>=P.Height-3)and(y<=P.Width) then P.Cursor:=crSizeNS;
end
else if (x>=P.Width-3)and(x<=P.Width) then
begin
if (y>=0)and(y<=3) then P.Cursor:=crSizeNESW;
if (y>3)and(y<P.Height-3) then P.Cursor:=crSizeWE;
if (y>=P.Height-3)and(y<=P.Width) then P.Cursor:=crSizeNWSE;
end;
end;
两个过程都可以实现功能的,
我想问的是该在什么地方调用这个过程才可以实现新产生的panel的移动呢?

[此贴子已经被作者于2007-3-20 14:04:02编辑过]

搜索更多相关主题的帖子: panel 加急 编写 begin end 
2007-03-08 16:57
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
收藏
得分:0 

这个问题我解决了一些,自己写一个类似的过程
加入P:TPanel;就可以用P来代替PANEL1了,
procedure TfrmRecordinput.PanelMouseMove(Sender: TObject;P:TPanel;
Shift: TShiftState; X, Y: Integer);
但是会出现:[Error] Main.pas(76): Statement expected but 'PROCEDURE' found
[Error] Main.pas(18): Unsatisfied forward or external declaration: 'TMainForm.ButtonMove'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Main.pas'
的错误,是什么原因呢?

希望大家帮帮忙,回答下,谢谢了


2007-03-12 13:25
xu2000
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:51
帖 子:3890
专家分:56
注 册:2006-4-8
收藏
得分:0 
没有向前声明,你是怎么定义的?

我会拿出我全部的钱财,以保你衣食无忧。我会献出我所有的智慧,以助你一帆风顺。我会想到所有的笑语,以令你展眉开颜。我会挤出最长的时间,以使你终生幸福。        [本人原创的结婚宣言]
2007-03-12 22:54
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
收藏
得分:0 
错误解决了,不过我是重新建立一个application写的就没有问题了,
可能是我删错了吧。
楼上的你说的是向前声明是什么意思?告诉我下的,谢谢你了

2007-03-13 15:38
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
收藏
得分:0 
不过还想问的是自己写一个类似的过程
加入P:TPanel;就可以用P来代替PANEL1了,
procedure TfrmRecordinput.PanelMouseMove(Sender: TObject;P:TPanel;
Shift: TShiftState; X, Y: Integer);

我写了一个产生panel的程序,要让新产生的panel调用这个过程,
应该在什么地方写的呢?
麻烦大家帮忙的,谢谢先

2007-03-13 15:44
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
收藏
得分:0 

大家再帮帮忙呀,
这个是我产生新panel的过程,
procedure TMainForm.Button1Click(Sender: TObject);
var i,u,x0:integer;
a:array of tpanel

begin
setlength(a,u);
x0:=50;
u:=strtoint(edit1.Text);
for i:=1 to u do
begin
a[i]:=tpanel.Create(self);
a[i].Parent:=self;
a[i].Enabled:=true;
a[i].Visible:=true;
a[i].Left:=x0;
a[i].Top :=100;
a[i].Width:=50;
x0:=x0+150+10;
end;
end;
这个是我自定义的移动panel的过程:
procedure TMainForm.ButtonMove(Sender: TObject;P:TPanel;Shift: TShiftState; X,Y: Integer);
begin
if (x>=0)and(x<=3) then
begin
if (y>=0)and(y<=3) then P.Cursor:=crSizeNWSE;
if (y>3)and(y<P.Height-3) then P.Cursor:=crSizeWE;
if (y>=P.Height-3)and(y<=P.Height) then P.Cursor:=crSizeNESW;
end
else if (x>3)and(x<P.Width-3) then
begin
if (y>=0)and(y<=3) then P.Cursor:=crSizeNS;
if (y>3)and(y<P.Height-3) then P.Cursor:=crArrow;
if (y>=P.Height-3)and(y<=P.Width) then P.Cursor:=crSizeNS;
end
else if (x>=P.Width-3)and(x<=P.Width) then
begin
if (y>=0)and(y<=3) then P.Cursor:=crSizeNESW;
if (y>3)and(y<P.Height-3) then P.Cursor:=crSizeWE;
if (y>=P.Height-3)and(y<=P.Width) then P.Cursor:=crSizeNWSE;
end;
end;
两个过程都可以实现功能的,
我想问的是该在什么地方调用这个过程才可以实现新产生的panel的移动呢?


2007-03-20 09:10
快速回复:编写一个过程可以移动panel的問題,加急呀
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015417 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved