Recent

Author Topic: I got error in my Procedure  (Read 1622 times)

onlyhasbi

  • New member
  • *
  • Posts: 9
I got error in my Procedure
« on: February 23, 2015, 03:45:26 pm »
procedure Tform1.EnterToTeks(Sender:Tobject);
Begin
  if Tedit(Sender).Text=Tedit(sender).Hint then
     Tedit(Sender).Clear;
end;

procedure Tform1.ExitToTeks(Sender:Tobject);
Begin
  if Tedit(Sender).Text=EmptyStr then
     Tedit(Sender).Text:=Tedit(Sender).Hint;
end;


procedure TForm1.FormCreate(Sender: TObject);
var
 i:integer;
begin
 for i:=0 to (ComponentCount-1) do
     begin
      if Components is TEdit then
         Begin
           TEdit(Components).OnEnter:=EnterToTeks; //Here
           TEdit(Components).OnExit:=ExitToTeks;
         end;
     end;
end;

When i Try to compile this code, I got error in //Here ? anyone can solve and explain, why that's occur ?

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: I got error in my Procedure
« Reply #1 on: February 23, 2015, 03:49:07 pm »
Code: [Select]
Components [i] ...
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: I got error in my Procedure
« Reply #2 on: February 23, 2015, 04:00:32 pm »
and if you're using {$mode objfpc} you'll need to add an "@":
Code: [Select]
   TEdit(Components[i]).OnEnter:=@EnterToTeks;

 

TinyPortal © 2005-2018