易截截图软件、单文件、免安装、纯绿色、仅160KB

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'


相关文档:

Delphi与XML文档

同步程序案例
procedure TGetOrderThread.PostDB(webnr:WideString);
var
  Err: String;
  SetWebnr:WideString;
  xmlDoc: IXMLDocument;
  root: IXMLNode;
  rowc: IXMLNode;//记录数
  rows: IXMLNodeList;//主记录列表
  row: IXMLNode;
  drows: IXMLNodeList;// ......

怎样用DELPHI接收摄像头的图象

community.csdn.net/Expert/topic/3423/3423580.xml?temp=.7675897
主  题:  怎样用DELPHI接收摄像头的图象 
作  者:  benbenpear (笨笨) 
等  级:   
信 誉 值:  100 
所属社区:  Delphi GAME,图形处理/多媒体 
问题点数:  0  ......

delphi TStringList的用法

TStrings是一个抽象类,在实际开发中,是除了基本类型外,应用得最多的。
常规的用法大家都知道,现在来讨论它的一些高级的用法。
先把要讨论的几个属性列出来:
1、CommaText
2、Delimiter & DelimitedText
3、Names & Values & ValuefromIndex
先看第一个:CommaText。怎么用呢?用代码说话:
const
......

delphi + java 的分布式应用思考

delphi  + java 的分布式应用思考
用delphi做界面层  java业务逻辑层 这样看上去很美吧?
具体的实现
java 做业务逻辑层 应该有多种选择 企业级的有EJB3, 轻量级的有spring
目前在学习ejb3,感觉用来做业务逻辑层真的很不错。spring还没有了解
界面层用delphi,RAD应该是delphi的优势。
关键的问题的如果把 ......

Delphi字符串加密解密函数


Delphi字符串加密解密函数
功能:字符串加密和解密
首先定义一个常量数组
const
      XorKey:array[0..7] of Byte=($B2,$09,$AA,$55,$93,$6D,$84,$47); //字符串加密用
在程序里加入以下两个函数,
function Enc(Str:String):String;//字符加密函數 這是用的一個&# ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号