> constructor TWSockClient.Create(AOwner: TComponent); > begin > inherited Create(AOwner); > OnDataAvailable := DataReceived; > end;
When you derive from a component, you should _not_ use the OnSomeEvent properties. Instead, you have to override the procedure, usually named TriggerSomeEvent, that triggers the event in the parent class and still call the external event handler. > procedure TFrmTest.Test(Sender: TObject; const Obj: TObject); > begin > ShowMessage('ok'); > end; In an event handler that has his source from hardware, such as OnDataAvailable, you can't call the message pump directly (ProcessMessages) or indirectly (ShowMessage and many others). This is because when the message pump is called, the pending events are triggered and the event handler are re-entered, causing many troubles. If you want to display something, add a line to a TMemo, use OutputDebugString, write a line to a console or to a log file. But do _not_ call a modal form. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be ----- Original Message ----- From: "Snake Liquid" <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Tuesday, August 23, 2005 7:39 AM Subject: [twsocket] TWSocketClient inheritance problem > hello, > > i have defined a small class for ClientClass to use with TWSocketServer wich > have an event that it should call, but i remarked that when the server try to call TriggerClientCreate(Client); in the TriggerSessionAvailable method, it calls my event .. > > here is the class : > > unit Test; > interface > uses > Classes, WSocketS; > type > TMyEvent = procedure (Sender: TObject; const AnObject: TObject) of object; > TWSockClient = class(TWSocketClient) > protected > FMyEvent: TMyEvent; > procedure DataReceived(Sender: TObject; ErrCode: Word); > published > constructor Create(AOwner: TComponent); override; > property MyEvent: TMyEvent read FMyEvent write FMyEvent; > end; > implementation > constructor TWSockClient.Create(AOwner: TComponent); > begin > inherited Create(AOwner); > OnDataAvailable := DataReceived; > end; > procedure TWSockClient.DataReceived(Sender: TObject; ErrCode: Word); > begin > //Some job to do > Text; > if Assigned(FMyEvent) then > FMyEvent(Sender, nil); > end; > end. > > > > > > > and here is a small test > > procedure TFrmTest.Test(Sender: TObject; const Obj: TObject); > begin > ShowMessage('ok'); > end; > > procedure TFrmTest.ServClientConnect(Sender: TObject; Client: TWSocketClient; > Error: Word); > begin > TWSockClient(Sender).MyEvent := Test; > end; > > > > > just implement this in a form and try to connect the first time to the > server, everything will be done correctly, but in the next connection, the server will call Test when he calls TriggerClientCreate > > any idea please, if you need me to prepare all the units in an example, just > told me. > > > --------------------------------- > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger > Téléchargez le ici ! > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be