Problem with Event Handling in Indy
Hi,
I'm trying to "Encapsulate" ftp and http file transfer and have the
same set of basic functions for both... Eg: Connect, Disconnect, Get,
Etc...
All basic functions are working but none of the Event Handlers works.
I don't understand why events are never arising.
====================
unit netUnit;
TNet = class(TComponent)
http: TIdHTTP;
ftp : TIdFTP;
IdAntiFreeze1: TIdAntiFreeze;
procedure ftpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
(...)
public
(...)
function Connect : boolean;
function Disconnect : boolean;
function Get(const NetName,LocalName : string) : boolean;
end;
implementation
procedure TNet.ftpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
MessageDlg('ftp Working',mtInformation,[mbOk],0);
end;
=====================
=====================
uses netUnit
var net : TNet;
begin
net := TNet.Create(ftp-host,username,password);
net.connect;
net.get('path/filename','filename');
net.Disconnect;
net.free;
end.
In the simplified example above, my program will properly
connect,
get the file
Disconnect
Free the object.
But ftp.OnWork (as any other Event) arised. Actually TComponent events
are not arising either.