社区
Delphi
帖子详情
偶不明白:delphi的type中声明了:tform1:=class(form);button1:=tbutton;等,为什么却在最后又声明:var form1:=tform1,为什么不声明在t
chris2019
2002-04-13 11:27:07
tell me
...全文
385
18
打赏
收藏
偶不明白:delphi的type中声明了:tform1:=class(form);button1:=tbutton;等,为什么却在最后又声明:var form1:=tform1,为什么不声明在t
tell me
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
18 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
tf1008
2010-06-02
打赏
举报
回复
学习学习
kinggo
2002-04-13
打赏
举报
回复
为什么用
type
tform1=class(form)
button1=tbutton
而不用:
tform1=class(form)
tbutton1=class(button)
button1=tbutton
这样定义也可以
不过没有这个必要
dancemaple
2002-04-13
打赏
举报
回复
button1是一个对象(类实例),而tbutton是一个类
还是那句话:看看OOP的书吧
kinggo
2002-04-13
打赏
举报
回复
tform1:=class(form);button1:=tbutton这只不是定一个类
var form1:=tform1是定义一个类的变量也就是对象
chris2019
2002-04-13
打赏
举报
回复
为什么用
type
tform1=class(form)
button1=tbutton
而不用:
tform1=class(form)
tbutton1=class(button)
button1=tbutton
fermium
2002-04-13
打赏
举报
回复
同意楼上,另外var form1:Tform1 是戴毅一个实例,这些都是OOP的基础知识哈
erickleung
2002-04-13
打赏
举报
回复
可能你是惯用basic或c等编程, 随写随编.
Delphi沿用Pascal的体制, 任何物件都先要在定义区内定义,
然後在 implementation 执行区中使用.
正因为有这个规定, Pascal的好处便是较易跟进, 和其编译器
超级快.
liutaoboy
2002-04-13
打赏
举报
回复
TForm1是从Form中派生出来的一个类,而Form1是TForm1类型的变量,
这是两个概念,在Type中只是声明类,并没有把它实例化,建议你看一看
有关OOP或Java方面的书
dancemaple
2002-04-13
打赏
举报
回复
type是类型声明,var是变量(包括对象)定义
outer2000
2002-04-13
打赏
举报
回复
当然需要声明,前面派生了一个新的TFORM1;而FORM1又是。。
ihihonline
2002-04-13
打赏
举报
回复
tform1:=class(form);
var form1:=tform1
建议你看一看c++;
类-〉对象-〉事例;
BossHawk
2002-04-13
打赏
举报
回复
to liaokuo(辽阔)
写错了吧?这里没有实例化吗?
liaokuo
2002-04-13
打赏
举报
回复
不声明
var
form1 :tform;
也可以用,即使不构造事例,依然可以运行
application.create(Tform,Tform)
BossHawk
2002-04-13
打赏
举报
回复
可以这样 type Button1 = class(TButton) end;
这表示Button1是一个新的类(不是实例变量),接下来可以
var mybutton1: Button1;
为什么用
type
tform1=class(form)
button1=tbutton
而不用:
tform1=class(form)
tbutton1=class(button) //这里错了Form是一个类,Button不是,TButton是
button1=tbutton //也错了,用TButton1才是
为什么要TForm1而不TButton1呢?
因为你新建一个窗体时,不会(或很少)就一个空窗体吧?你得在里面放上其他东东(控件啦:)),这就是一个继承过程;但是,你会对一个TButton进一步加工吗?基本不会!(有时候是可以的!见后面的说明),所以你不必要用type tbutton1=class(Tbutton); var mybutton1: tbutton1;
特别说明:
tbutton有一个属性tag,大伙可以自由使用,那么你是不是觉得有时候不够用呢?比如你需要一个String型的属性而Hint又已经使用了?呵呵,可以这样:
type
TAdvButton = class(TButton)
private
yourstr: String;
end;
var
MyAdvButtonArr: array of TAdvButton;
然后就可以用了,区别是你要用代码创建新的TAdvButton,不能在设计时生成。
假如你想在设计时就生成,那么把这个TAdvButton作成控件安装上去就行。
怎么作呢?用Delphi的控件生成向导吧,太简单了,不过说起来烦,自己琢磨琢磨!
blazingfire
2002-04-13
打赏
举报
回复
To:chris2019(牛虻---最后的匈奴) :
Button1=TButton 这种用法没有,那么怎么用?
chris2019
2002-04-13
打赏
举报
回复
偶是说:
Button1=TButton
//这种用法好象没有
为什么不这样用呢?
blazingfire
2002-04-13
打赏
举报
回复
To:chris2019(牛虻---最后的匈奴)
---------------------
---------------------
TForm1=Class(TForm);
//这句话指是TForm1是从TForm继乘过来的一个子类
Button1=TButton
//这种用法好象没有
TButton1=Class(TButton)
//这句话也是指TButton1是从TButton中继乘过来的一个子类
var
Form1:TForm1;
//这是指定义了一个TForm1类的对象变量。
chris2019
2002-04-13
打赏
举报
回复
为什么用
type
tform1=class(form)
button1=tbutton
而不用:
tform1=class(form)
tbutton1=class(button)
button1=tbutton
delphi
计算器
Form
1: T
Form
1; implementation {$R *.dfm} procedure T
Form
1.
Button
1Click(Sender: TObject);
var
temp:string; begin if er then exit; if pnt then scr.Caption:=scr.Caption+(sender as T
button
)....
Delphi
获取
Form
数据
在
Delphi
编程环境
中
,
Form
是用户界面的基本组成部分,它包含了各种控件,如按钮、文本框、标签等。获取
Form
中
的数据是实现程序逻辑和用户交互的关键步骤。本实例将详细探讨如何在
Delphi
中
获取
Form
上的不同类型的控件...
delphi
摄像程序
unit Unit1; interface uses Windows, Messages, SysUtils,
Var
iants,
Class
es, Graphics, Controls,
Form
s, Dialogs, StdCtrls, ExtCtrls;
type
T
Form
1 =
class
(T
Form
) ...
Form
1: T
Form
1;
DELPHI
动态创建删除FRAME---示例源码
Button
1: T
Button
; procedure
Button
1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; implementation uses unit2; {$R *.dfm} procedure TFrame1....
delphi
使用exec调用
Form
1: T
Form
1; sd : SECURITY_DESCRIPTOR; implementation {$R *.dfm} procedure T
Form
1.
Button
1Click(Sender: TObject); begin begin InitializeSecurityDescriptor(@sd,SECURITY_DESCRIPTOR_REVISION); ...
Delphi
5,930
社区成员
262,940
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章