注册 登录
编程论坛 Delphi论坛

TForm1.CreateLabels()从哪里来的啊

aaron52088 发布于 2007-02-13 15:36, 751 次点击

看别人程序时候发现里面有很多诸如:
procedure TDesignForm.CreateLabels();
procedure TDesignForm.UpdateOne(i: Integer; j: Integer);
这样的过程应在什么地方双击写的呢?
而在FORM的事件中只有onActivate和onCreate有内容啊

大家帮我看看哈,谢谢先
程序我贴一部分出来看看的:
unit Design;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Tools; //TOOLS是自己定义的,没有贴出来

type
TDesignForm = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure UpdateOne(i: Integer; j: Integer);
procedure UpdateAll();
procedure CreateLabels();
procedure LabelMouseEnter(Sender: TObject);
procedure LabelMouseLeave(Sender: TObject);
procedure LabelClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
DesignForm: TDesignForm;
m_compArry: TLabelArray;
m_seq: Integer;

implementation

uses Main, ResizeGarage; //使用到其他的单元,自定义的
{$R *.dfm}

procedure TDesignForm.FormCreate(Sender: TObject);
begin
CreateLabels;
m_seq := Tools.Tool.m_seq;
end;

procedure TDesignForm.FormActivate(Sender: TObject);
begin
if m_seq <> Tools.Tool.m_seq then
begin
CreateLabels;
m_seq := Tools.Tool.m_seq;
end;

UpdateALL;
end;

procedure TDesignForm.UpdateOne(i: Integer; j: Integer);
begin
m_compArry[i,j].Color := Tools.Tool.GetColor(i, j);
end;

procedure TDesignForm.UpdateAll();
var
i,j: Integer;
begin
for i := Low(m_compArry) to High(m_compArry) do
for j := Low(m_compArry[i]) to High(m_compArry[i]) do
m_compArry[i,j].Color := Tools.Tool.GetColor(i, j);
end;

procedure TDesignForm.CreateLabels();
var
i,j: Integer;
begin
for i := Low(m_compArry) to High(m_compArry) do
for j := Low(m_compArry[i]) to High(m_compArry[i]) do
m_compArry[i,j].Free;
m_compArry := nil;
Tools.Tool.CreateLabelArray(m_compArry, self.Panel1);
for i := Low(m_compArry) to High(m_compArry) do
for j := Low(m_compArry[i]) to High(m_compArry[i]) do
begin
m_compArry[i,j].OnMouseEnter := self.LabelMouseEnter;
m_compArry[i,j].OnMouseLeave := self.LabelMouseLeave;
m_compArry[i,j].OnClick := self.LabelClick;
end;
end;

procedure TDesignForm.LabelMouseEnter(Sender: TObject);
var
name: String;
i,j: Integer;
begin
name := TLabel(Sender).Name;
i := Tools.Tool.GetIFromStr(name);
j := Tools.Tool.GetJFromStr(name);

if Tools.Tool.IsRoad(i,j) then
TLabel(Sender).Caption := '通道'
else
TLabel(Sender).Caption := '车位';
end;

procedure TDesignForm.LabelMouseLeave(Sender: TObject);
begin
TLabel(Sender).Caption := '';
end;

procedure TDesignForm.LabelClick(Sender: TObject);
var
name: String;
i,j: Integer;
begin
name := TLabel(Sender).Name;
i := Tools.Tool.GetIFromStr(name);
j := Tools.Tool.GetJFromStr(name);
Tools.Tool.ChangeType(i, j);

if Tools.Tool.IsRoad(i,j) then
TLabel(Sender).Caption := '通道'
else
TLabel(Sender).Caption := '车位';

UpdateOne(i, j);
end;

procedure TDesignForm.Button1Click(Sender: TObject);
begin
ResizeGarage.ResizeForm.Edit1.Text := IntToStr(Tools.Tool.m_rows);
ResizeGarage.ResizeForm.Edit2.Text := IntToStr(Tools.Tool.m_columns);
ResizeGarage.ResizeForm.Show;
Self.Hide;
end;

procedure TDesignForm.Button2Click(Sender: TObject);
begin
Main.MainForm.Show;
Self.Hide;
end;

end.

[此贴子已经被作者于2007-2-13 20:38:33编辑过]

6 回复
#2
sgliuxiu2007-02-13 19:30
你看的程序是delphi编的吗?
#3
aaron520882007-02-13 20:33
恩,是的。
我把一部分程序贴出来了,大家帮我看看哈
谢谢

[此贴子已经被作者于2007-2-13 20:39:41编辑过]

#4
sgliuxiu2007-02-13 21:45
procedure UpdateAll();
procedure CreateLabels();
procedure UpdateOne(i: Integer; j: Integer);

这几个是自定义的,知道吗?

[此贴子已经被作者于2007-2-13 21:46:14编辑过]

#5
xu20002007-02-13 23:02
TDesignForm = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure UpdateOne(i: Integer; j: Integer);
procedure UpdateAll();
procedure CreateLabels();
procedure LabelMouseEnter(Sender: TObject);
procedure LabelMouseLeave(Sender: TObject); //从这里来的。 TDesignForm = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure UpdateOne(i: Integer; j: Integer);
procedure UpdateAll();
procedure CreateLabels();
procedure LabelMouseEnter(Sender: TObject);
procedure LabelMouseLeave(Sender: TObject); //从这里来的。
procedure LabelClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);

这是两个自定义的过程,你把他放在了TDesignForm这个类的定义中,所以他一个对象方法。所以在实现的时候前面要加上TDesignForm。
如果你放在类定义的外面,就不用加TDesignForm了。
#6
aaron520882007-02-18 18:13
恩,理解了.谢谢大家的帮忙
#7
aaron520882007-02-18 18:19

就是说
procedure TDesignForm.LabelMouseEnter(Sender: TObject);
var
name: String;
i,j: Integer;
begin
name := TLabel(Sender).Name;
i := Tools.Tool.GetIFromStr(name);
j := Tools.Tool.GetJFromStr(name);

if Tools.Tool.IsRoad(i,j) then
TLabel(Sender).Caption := '通道'
else
TLabel(Sender).Caption := '车位';
end;
是上面自定义的过程要实现的操作吗?

1