BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Socket Component

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Development
View previous topic :: View next topic  
Author Message
Hanlie
Guest





PostPosted: Fri Nov 28, 2003 6:40 am    Post subject: Socket Component Reply with 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
Jeff Giddens
Guest





PostPosted: Sat Nov 29, 2003 10:06 pm    Post subject: Re: Socket Component Reply with 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

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





PostPosted: Mon Dec 01, 2003 8:17 am    Post subject: Re: Socket Component Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ActiveX Controls Development All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.