过程也是类吗?(50分)

  • 主题发起人 主题发起人 小刀客
  • 开始时间 开始时间

小刀客

Unregistered / Unconfirmed
GUEST, unregistred user!
type
TNeedDiskEvent = procedure(Sender: TObject
DiskID, NumOfDisks: Word
var Continue: Boolean) of object;
TProgressEvent = procedure(Sender: TObject
PercentDone: Word) of object;

TFileSplitter = class(TComponent)
private
FOnNeedDisk: TNeedDiskEvent;
FOnProgress: TProgressEvent;
我弄不清TNeedDiskEvent是个过程,怎么也当类用?这是正确的吗
 
看看delphi中的这段帮助

procedure FuncProc(P: TIntegerFunction)

{ FuncProc is a procedure whose only parameter is a parameterless integer-valued
function }

The variables above are all procedure pointers 梩hat is, pointers to the
address of a procedure or function. If you want to reference a method of an
instance object (see Classes and objects), you need to add the words of object
to the procedural type name. For example type

TMethod = procedure of object;
TNotifyEvent = procedure(Sender: TObject) of object;

These types represent method pointers. A method pointer is really a pair of
pointers
the first stores the address of a method, and the second stores a
reference to the object the method belongs to. Given the declarations

type

TNotifyEvent = procedure(Sender: TObject) of object;
TMainForm = class(TForm)
procedure ButtonClick(Sender: TObject);
...
end;
var
MainForm: TMainForm;
OnClick: TNotifyEvent

we could make the following assignment.

OnClick := MainForm.ButtonClick;
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
625
import
I
后退
顶部