LNET and KOL lazarus / 13-General ---------------------------------------------------------------------- Dibo · 2009-12-19 23:56 Hi, I'm trying to mix KOL library with LNet socket. But I have a problem. In a standard Lazarus project, connecting events is as follows: ObjectVar.OnEvent: = @ProcedureName, but the project KOL assigned without the "@". I do not know what is the reason for this, but OnConnect event can't trigger: Code: [Select]{ KOL MCK } // Do not remove this line! {$DEFINE KOL_MCK} {$ifdef FPC} {$mode delphi} {$endif} unit Unit1; interface uses Windows, Messages, KOL {place your units here->} , lNet {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics; {$ELSE} ; {$ENDIF} type   { TForm1 }   {$I MCKfakeClasses.inc}   {$IFDEF KOLCLASSES} TForm1 = class; PForm1 = TForm1; {$ELSE OBJECTS} PForm1 = ^TForm1; {$ENDIF CLASSES/OBJECTS}   TForm1 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})     Button1: TKOLButton;     Form: PControl;     KOLForm1: TKOLForm;     KOLProject: TKOLProject;     Memo1: TKOLMemo;     Panel1: TKOLPanel;     procedure Button1Click(Sender: PObj);     procedure KOLForm1Destroy(Sender: PObj);     procedure KOLForm1FormCreate(Sender: PObj);   private     { private declarations }     FTCPSocket: TLTcp;     procedure FTCPSocketOnConnect(aSocket: TLSocket);   public     { public declarations }   end; var   Form1 {$IFDEF KOL_MCK} : PForm1 {$ELSE} : TForm1 {$ENDIF} ; {$IFDEF KOL_MCK} procedure NewForm1( var Result: PForm1; AParent: PControl ); {$ENDIF} implementation {$IFDEF KOL_MCK} {$I unit1_1.inc} {$ENDIF} { TForm1 } procedure TForm1.KOLForm1FormCreate(Sender: PObj); begin   FTCPSocket := TLTcp.Create(nil);   FTCPSocket.OnConnect := FTCPSocketOnConnect; end; procedure TForm1.FTCPSocketOnConnect(aSocket: TLSocket); begin   Memo1.Add('Connected'); end; procedure TForm1.KOLForm1Destroy(Sender: PObj); begin   FTCPSocket.Free; end; procedure TForm1.Button1Click(Sender: PObj); begin   FTCPSocket.Connect('somehost.com', 5222); end; initialization {$IFNDEF KOL_MCK} {$I unit1.lrs} {$ENDIF} end. ---------------------------------------------------------------------- Hitman · 2009-12-20 00:28 {$mode delphi} is the reason why you don't use @ within KOL. In delphi you assign function pointers "implicit". objfpc doesn't allow that. Also: the visual lNet components use the main loop of the LCL. I guess that isn't substituted within KOL so the necessary CallAction is never called. ---------------------------------------------------------------------- Dibo · 2009-12-20 17:18 Hmm, so there is no solution for this problem? ---------------------------------------------------------------------- marcov · 2009-12-20 19:00 It would be more logical to ask this on a KOL forum than a Lazarus forum. ---------------------------------------------------------------------- Dibo · 2009-12-21 11:01 I posted too, but KOL forum looks deserted ---------------------------------------------------------------------- yuriy_sydorov · 2009-12-22 20:22 You should ask lNet developer how to use lNet in non-LCL programs ( call CallAction() somewhere in the message loop? ). The problem is not in the presence or absence of @. ---------------------------------------------------------------------- Dibo · 2009-12-22 22:28 You're right! I use TLTcp instead of visual TLTCPComponent (which inherited from TLTcp) to reduce the size of the exe file, but using TLTcp I must queue messages by my self calling CallAction in loop. In found examples in LNet console demos . I just connected to TCP server, so I think everything else is OK. Thanks. Edit: Hitman, now I understand what you mean