viziopoint
asked on
How do I programatically create Indy components
Hi experts, I am trying to create a service and creating the indy components (tcpserver, udpserver) from code rather than dropping a component on a form. I'm looking for some code sample that shows how to do this.
Thanks.
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The GeExpert tip is indeed a very really useful tip! - Thanks!
I'm getting some odd results though like:
Bindings := <>;
It tried to replace the <> with nil - compiles but does not work (crashes) so I just commented them out and it seems to work.
I also had problems with assigning event handlers since I don't have a form. I was able to fix this with a little trick that I think is fine:
type
TEventHandlers = class // create a dummy class
procedure UDPServerUDPRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);
end;
...
var
EvHandlers : TEventHandlers;
....
IdUDPSever1.OnUDPRead := EvHandlers.UDPServerUDPRea d
to the component created with the GeExpert code and it seems to work.
I'll continue to test and report back.
Thanks again for the help.
I'm getting some odd results though like:
Bindings := <>;
It tried to replace the <> with nil - compiles but does not work (crashes) so I just commented them out and it seems to work.
I also had problems with assigning event handlers since I don't have a form. I was able to fix this with a little trick that I think is fine:
type
TEventHandlers = class // create a dummy class
procedure UDPServerUDPRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);
end;
...
var
EvHandlers : TEventHandlers;
....
IdUDPSever1.OnUDPRead := EvHandlers.UDPServerUDPRea
to the component created with the GeExpert code and it seems to work.
I'll continue to test and report back.
Thanks again for the help.
you don't have a form and you want to use an event handler ?
the way you do it with the dummy class is actually the solution!
why you may ask ... well because how the event handler is defined
a event handler is a method, and a method is a procedure of a object
TNotifyEvent = procedure (Sender: TObject) of object;
the *of object* at the end means it must be defined inside a class.
you will have to create a instance of EvHandlers at runtime too...
the way you do it with the dummy class is actually the solution!
why you may ask ... well because how the event handler is defined
a event handler is a method, and a method is a procedure of a object
TNotifyEvent = procedure (Sender: TObject) of object;
the *of object* at the end means it must be defined inside a class.
you will have to create a instance of EvHandlers at runtime too...
Actually you should have the indy component in the event handler dummy class.
ASKER
Just wanted to confirm that following the tips above, everything worked fine. Thanks Again!
Thanks Geert_Gruwez =D