 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Hanlie Guest
|
Posted: Fri Nov 28, 2003 6:40 am Post subject: Socket Component |
|
|
Hello all,
I need to write a delphi automation object that wraps the tcustomwinsocket
component.
Anyone ideas / links to sample code?
Thanks
Hanlie
South Africa
|
|
| Back to top |
|
 |
Jeff Giddens Guest
|
Posted: Sat Nov 29, 2003 10:06 pm Post subject: Re: Socket Component |
|
|
Hello Hanlie,
There are a few different ways to go about this. I would start with an
automation class that contains and instance of TCustomWinSocket. Then
create a type library with all of the methods and an event sink for all of
your events. After that, I would map the implementation of the type library
interfaces to the instance of the TCustomWinSocket component.
Something like this:
Note: Some of the socket methods/events may not exist. I am just showing
how to use any component as an example.
TAutoSocket = class(TAutoObject, IConnectionPointContainer, IAutoSocket)
private
FConnectionPoints: TConnectionPoints;
FConnectionPoint: TConnectionPoint;
FEvents: IAutoSocketEvents;
FSocket: TCustomWinSocket;
procedure DoSocketConnect(Sender: TObject);
protected
property ConnectionPoints: TConnectionPoints read FConnectionPoints
implements IConnectionPointContainer;
procedure EventSinkChanged(const EventSink: IUnknown); override;
public
procedure Initialize; override;
destructor Destroy; override;
procedure Connect;
procedure Disconnect;
end;
implementation
procedure TAutoSocket.Initialize;
begin
inherited Initialize;
{... delphi auto generated code...}
FSocket := TCusomWinSocket.Create;
FSocket.OnConnect := DoSocketConnect;
end;
destructor TAutoSocket.Destroy;
begin
FSocket.Free;
inherited Destroy;
end;
procedure TAutoSocket.Connect;
begin
FSocket.Connect;
end;
procedure TAutoSocket.Disconnect;
begin
FSocket.Disconnect;
end;
procedure TAutoSocket.DoSocketConnected(Sender: TObject);
begin
FEvents.OnSocketConnected;
end;
This should get you started. Also check out Binh Ly's COM site at:
http://www.techvanguards.com/com/ There are some excellent examples and
tutorials on his site.
- Jeff
"Hanlie" <hanste (AT) mweb (DOT) co.za> wrote
| Quote: | Hello all,
I need to write a delphi automation object that wraps the tcustomwinsocket
component.
Anyone ideas / links to sample code?
Thanks
Hanlie
South Africa
|
|
|
| Back to top |
|
 |
Hanlie Guest
|
Posted: Mon Dec 01, 2003 8:17 am Post subject: Re: Socket Component |
|
|
Thank You, I will give it a try
"Jeff Giddens" <jeff (AT) nospam (DOT) com> wrote
| Quote: | Hello Hanlie,
There are a few different ways to go about this. I would start with an
automation class that contains and instance of TCustomWinSocket. Then
create a type library with all of the methods and an event sink for all of
your events. After that, I would map the implementation of the type
library
interfaces to the instance of the TCustomWinSocket component.
Something like this:
Note: Some of the socket methods/events may not exist. I am just showing
how to use any component as an example.
TAutoSocket = class(TAutoObject, IConnectionPointContainer, IAutoSocket)
private
FConnectionPoints: TConnectionPoints;
FConnectionPoint: TConnectionPoint;
FEvents: IAutoSocketEvents;
FSocket: TCustomWinSocket;
procedure DoSocketConnect(Sender: TObject);
protected
property ConnectionPoints: TConnectionPoints read FConnectionPoints
implements IConnectionPointContainer;
procedure EventSinkChanged(const EventSink: IUnknown); override;
public
procedure Initialize; override;
destructor Destroy; override;
procedure Connect;
procedure Disconnect;
end;
implementation
procedure TAutoSocket.Initialize;
begin
inherited Initialize;
{... delphi auto generated code...}
FSocket := TCusomWinSocket.Create;
FSocket.OnConnect := DoSocketConnect;
end;
destructor TAutoSocket.Destroy;
begin
FSocket.Free;
inherited Destroy;
end;
procedure TAutoSocket.Connect;
begin
FSocket.Connect;
end;
procedure TAutoSocket.Disconnect;
begin
FSocket.Disconnect;
end;
procedure TAutoSocket.DoSocketConnected(Sender: TObject);
begin
FEvents.OnSocketConnected;
end;
This should get you started. Also check out Binh Ly's COM site at:
http://www.techvanguards.com/com/ There are some excellent examples and
tutorials on his site.
- Jeff
"Hanlie" <hanste (AT) mweb (DOT) co.za> wrote in message
news:3fc6ee4f (AT) newsgroups (DOT) borland.com...
Hello all,
I need to write a delphi automation object that wraps the
tcustomwinsocket
component.
Anyone ideas / links to sample code?
Thanks
Hanlie
South Africa
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|