Control flow lazarus / 13-General ---------------------------------------------------------------------- rquiterio · 2009-02-10 15:31 Hi, It’s my first app with Lazarus and I’m having  a rare situation with it. After returning from a function call, (it could be showmessage, for example) the control goes to the beginning of the calling function not to the line after the second function was called. In this piece of code I try to validate that a customer exists and that is currently active. But when the function Mostrar_Mensajes_Error is executed, after returning to the calling function (the Enter event of a textbox) the control goes to the beginning of the event, not to  the line after where the function was called.  That makes the event to be repeated. I’m using Lazarus 0.9.26 beta on Windows XP SP2 Thanks in advance,   screen.Cursor:=crhourglass;   //Busco el cliente   with data_qry do   begin      SQL.Clear;      Close;      SQL.Add('select nombres,apellidos,direccion,cedula,telefono_01,');      SQL.Add('telefono_02,estatus from clientes ');      SQL.Add('where negocio=:negocio and cliente=:codigo ');      Params.ParamByName('negocio').AsInteger:=StrtoInt(trim(frmmain.tx tnegocio.text));      Params.ParamByName('codigo').AsInteger:=StrtoInt(txtcodigo.text);      Open;      if RecordCount>0 then      begin         //Valido que el cliente este activo         if fieldbyname('estatus').asstring='I' then         begin            screen.Cursor:=crdefault;            Mostrar_Mensaje_Error('Error: ','El cliente no está activo.',2);            txtcodigo.SetFocus;            Exit;         end;         //Paso los datos del cliente a la pantalla         txtnombre.text      := trim(FieldByName('nombres').AsString) +' '+                                trim(FieldByName('apellidos').AsString);         txtdireccion.text   := FieldByName('direccion').AsString ;         txtcedula.text      := FieldByName('cedula').AsString ;         txttelefono_01.text := FieldByName('telefono_01').AsString ;         txttelefono_02.text := FieldByName('telefono_02').AsString ;         txtaccion.text      := 'A'      end      else      Begin         screen.Cursor:=crdefault;         Mostrar_Mensaje_Error('Error: ','El cliente no existe.',2);         txtcodigo.SetFocus;         Exit;      End;   end; ---------------------------------------------------------------------- cpalx · 2009-02-10 17:23 I have some similar code, and goes fine ---------------------------------------------------------------------- Martin_fr · 2009-02-10 20:31 The probable cause is in the following bit of your post "(the Enter event of a textbox)" and then:        Mostrar_Mensaje_Error('Error: ','El cliente no está activo.',2);         txtcodigo.SetFocus; If you are indeed in  txtcodigo.OnEnter  then setting focus to this control, can trigger the OnEnter again. There was a previous discussion on exactly this (either here on the forum or on the mailing list; Sorry don't remember the details). ---------------------------------------------------------------------- rquiterio · 2009-02-10 21:08 Thanks Martin_fr for your interest But the code is in the Enter event of another text box.  Following the tabOrder property. ---------------------------------------------------------------------- rquiterio · 2009-02-13 23:00 If I run it on Linux (ubuntu 8.10) it goes Ok.  The problem is with Windows