标题:TForm1.CreateLabels()从哪里来的啊
只看楼主
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
 问题点数:0 回复次数:6 
TForm1.CreateLabels()从哪里来的啊

看别人程序时候发现里面有很多诸如:
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编辑过]

搜索更多相关主题的帖子: interface procedure Windows Design 
2007-02-13 15:36
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
得分:0 
你看的程序是delphi编的吗?

小猫说:给我10元钱
2007-02-13 19:30
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
得分:0 
恩,是的。
我把一部分程序贴出来了,大家帮我看看哈
谢谢

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


2007-02-13 20:33
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
得分:0 
procedure UpdateAll();
procedure CreateLabels();
procedure UpdateOne(i: Integer; j: Integer);

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

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


小猫说:给我10元钱
2007-02-13 21:45
xu2000
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:51
帖 子:3890
专家分:56
注 册:2006-4-8
得分:0 
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了。

我会拿出我全部的钱财,以保你衣食无忧。我会献出我所有的智慧,以助你一帆风顺。我会想到所有的笑语,以令你展眉开颜。我会挤出最长的时间,以使你终生幸福。        [本人原创的结婚宣言]
2007-02-13 23:02
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
得分:0 
恩,理解了.谢谢大家的帮忙

2007-02-18 18:13
aaron52088
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-1-24
得分:0 

就是说
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;
是上面自定义的过程要实现的操作吗?


2007-02-18 18:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-120836-1-1.html




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

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