Search code examples
delphidelphi-2010

TTimer.OnTimer does not fire


I made 2 forms in one project, form2 incorporated into the parent form I use form2 more details such as the use of frames, I use this code in the parent application formcreate ..

for example:

form2 := tform2.Create(self);
form2.Parent := panel1;
form2.Visible := true;

form 2 made ​​it into form1(parent application)

the problem is when i enter this code in the timer component when in the run (F9) nothing has changed at all

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  form2.Label1.Caption:= ipclient.LocalIP;
end;

component used in the parent application is: = Timer1

components are used in form2: = label1 to record the local ip

so basically how to make form2 provide full access to all of the parent application in order to be set in the parent application can run all?


Solution

  • I have just set up a demo project to do exactly what you have done and it has worked first time. Is the Timer1.Enabled property set to True, and is the Interval value low enough to actually be firing?

    Also, where is the code behind the ipClient.LocalIP method?

    I wrote my own method for getting the IP Address using Winsock, and when I ran the program, the Form2.Label1.Caption changed to my IP address after 2 seconds (Timer1.Interval = 2000).