Delphi拾遗(8) 类事件
类的事件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyEvent = procedure of object; //不带参数的过程
TMyEventExt = procedure(AName: string) of object; //带参数的过程
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyBase = class
private
FName : string;
FAge : Integer;
FOnEvent: TMyEvent; //定义 TMyEvent 类型事件
FOnEventExt: TMyEventExt;
procedure SetAge(const AValue: Integer);
public
//创建类时进行相应的一些初始化工作
constructor Create;
procedure SetEvent1;
procedure SetEvent2;
procedure SetEventExt1(ATmp: string);
//Name属性 不可更改
property Name: string read FName write FName;
//Age属性 可以更改
property Age: Integer read FAge write SetAge;
//关联事件 发布 TMyEvent 类型事件
property OnEvent: TMyEvent read FOnEvent write FOnEvent;
property OnEventExt: TMyEventExt read FOnEventExt write FOnEventExt;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMyBase }
constructor TMyBase.Create;
begin
FName := 'hehf';
FAge := 99; //不赋值时默认为0
FOnEvent := SetEvent1;
FOnEventExt := SetEventExt1; //这时不能带参数
end;
procedure TMyBase.SetAge(const AValue: Integer);
begin
if (AValue > 0) and (AValue < 130) then
FAge := AValue
else
FAge := -1;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
TmpMy: TMyBase;
begin
TmpMy := TMyBase.Create;
ShowMessage(IntToStr(TmpMy.Age)); // 99
TmpMy.Age := 100;
ShowMessage(IntToStr(TmpMy.Age)); // 100
TmpMy.OnEvent; //触发关联事件
TmpMy.Free;
end;
procedure TMyBase.SetEvent1;
begin
ShowMessage('Event 1'
相关文档:
方法一:
直接弹出UDL对话框:
use
ADOConed;
EditConnectionString(ADOQuery1);
方法二:
⑴、右键---新建---文本文档,重命名为 connSet.udl 。
⑵、双击打开 connSet.udl 按提示操作配置数据库,选择本地或远程数据库,配置好后退出。
⑶、使用Delphi 控件TADOConnection连接代码:
在Form ......
community.csdn.net/Expert/topic/3423/3423580.xml?temp=.7675897
主 题: 怎样用DELPHI接收摄像头的图象
作 者: benbenpear (笨笨)
等 级:
信 誉 值: 100
所属社区: Delphi GAME,图形处理/多媒体
问题点数: 0 ......
一、概述及示例代码
Delphi中包括许多已经封装好的类及控件,其中的非可视化控件库以功能方式划分可处理诸多应用需求。若使用C++实现系统时对某些功能简单调用delphi中现成的库时即可。因此将delphi中的库以DLL形式封装好之后如何将方法导出可供C++调用是本文记录的重点。C++调用的方式有多种,在这里只讨论一种静 ......
TStrings是一个抽象类,在实际开发中,是除了基本类型外,应用得最多的。
常规的用法大家都知道,现在来讨论它的一些高级的用法。
先把要讨论的几个属性列出来:
1、CommaText
2、Delimiter & DelimitedText
3、Names & Values & ValuefromIndex
先看第一个:CommaText。怎么用呢?用代码说话:
const
......
结合Delphi
客户端桌面开发的优势和Java的稳健强壮特性,采用Delphi
Client + Java Server的系统架构应该是很有市场的,经过一段时间的实际项目实践,实现架构是这么实现的,供讨论:
1.后台应用服务层可采用基于Spring+Hibernate的轻量级J2EE实现,并使用Apache XML-RPC
提供客户端调用接口;
2.前台采用 Delphi
......