Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Networks";
Current archive: 2002.04.01;
Download: [xml.tar.bz2];

Down

TClientSocket and OnConnect Override Find similar branches


eblade   (2002-01-16 22:18) [0]

In general, the problem is this. I need to make a 1 class with a field, a successor from TClientSocket and hang
On the OnConnect, OnDisconnect event of this field, call the 1 class procedures (owner class). Like this
can be done? I would be very grateful for the answer.



Digitman   (2002-01-17 10:55) [1]

interface

Class 1 = class (TClientSocket)
procedure MyConnectProc (Sender: TCustomWinSocket);
procedure MyDisConnectProc (Sender: TCustomWinSocket);

public
constructor Create (AOwner: TComponent);
end;
.

implementation

constructor Tclass1.Create (AOwner: TComponent);
begin
inherited Create (AOwner);
OnConnect: = MyConnectProc;
OnDisconnect: = MyDisconnectProc;
end;



eblade   (2002-01-17 19:55) [2]

thank you, but a little bit wrong
I asked how to hang but OnConnect fields call the owner's procedure ... I will explain

Class 1 = class (TComponent)
private
CS: TClientSocket;
public
procedure OnConnect (i: integer);
end;
.

How onconnect CS to hang up call OnConnect Tclass 1 ci, for example = 1?



Digitman   (2002-01-18 09:20) [3]

I don’t know at what point you are creating an instance of TClientSocket, so I placed its creation in the constructor of your class
Class 1 = class (TComponent) private CS: TClientSocket; ... procedure ConnectEventHandler (Sender: TObject; Socket: TCustomWinSocket); procedure OnConnect (i: integer); ... public constructor Create (AOwner: TComponent); destructor Destroy; override; end; ... implementation constructor Tclass1.Create (AOwner: TComponent); begin inherited Create (AOwner); CS: = TClientSocket.Create (nil); CS.OnConnect: = ConnectEventHandler; end; destructor Tklass1.Destroy; begin CS.Free; inherited; end; procedure TX1.ConnectEventHandler (Sender: TObject; Socket: TCustomWinSocket); begin OnConnect (1); end;



eblade   (2002-01-18 13:54) [4]

Senks, this is what you need

one more question
What should I do if I have a CS - I will have a list of heirs from TC ClientSocket with a unique id added, which I will need to pass to the 1.ConnectEventHandler class?



Digitman   (2002-01-18 14:36) [5]

Class 1 = class (TComponent) private CS: TList; ... procedure ConnectEventHandler (Sender: TObject; Socket: TCustomWinSocket); procedure OnConnect (i: integer); ... public constructor Create (AOwner: TComponent); destructor Destroy; override; end; ... implementation constructor Tclass1.Create (AOwner: TComponent); var i: Integer; newsocket: TClientSocket; begin inherited Create (AOwner); CS: = TList.Create; for i: = 0 to ..... do begin newsocket: = TClientSocket.Create (nil); newsocket.OnConnect: = ConnectEventHandler; CS.Add (newsocket); end; end; destructor Tklass1.Destroy; var i: Integer; begin for i: = 0 to CS.Count - 1 do TObject (CS.Items [i]). Free; CS.Free; inherited; end; procedure TX1.ConnectEventHandler (Sender: TObject; Socket: TCustomWinSocket); begin OnConnect (CS.IndexOf (Socket)); end;



eblade   (2002-01-18 22:31) [6]

thank you so much again



Pages: 1 whole branch

Forum: "Networks";
Current archive: 2002.04.01;
Download: [xml.tar.bz2];

Top









Memory: 0.57 MB
Time: 0.019 c
We answer immediately.
d_oleg
2002-03-21 09:30
2002.04.01
Bitmap Dll


We answer immediately.
unikum
2002-01-31 19:41
2002.04.01
Subdirectories


We answer immediately.
Ariokh
2002-02-17 22:00
2002.04.01
Just a question


We answer immediately.
Sergey Saf
2002-03-21 12:07
2002.04.01
Play file


We answer immediately.
Semfly
2002-01-18 21:05
2002.04.01
File transfer via socket.





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish