Hi All, I am having problems with this timer. The first thing is it does not close the form, even if I change the interval time. The second thing is I have a label on the form and the message is not being assigned to the labels caption as in MessageForm.Label1.Caption:=Msg; I modified the program to include I modified my code as per requests of users to below
procedure TMainForm.ShowNotification(Msg:String; time:Cardinal); var MessageForm:TMessageChildForm; begin MessageForm:=TMessageChildForm.Create(nil); MessageForm.Label1.Caption:=Msg; MessageForm.Caption:='Project Setup'; MessageForm.Timer1.Interval:=time; MessageForm.Show; end; procedure TMessageChildForm.Timer1Timer(Sender: TObject); begin Timer1.Enabled:=False; Close; end; procedure TMessageChildForm.FormShow(Sender: TObject); begin Timer1.Enabled:=True; end; Anything wrong with the above. Thanks Lefti ---------------------------------------- > Date: Fri, 14 Dec 2007 17:25:37 -0500 > From: [EMAIL PROTECTED] > To: [email protected] > Subject: Re: [lazarus] showmessage or similar that closes without a prompt > > el stamatakos wrote: >> Hi All, >> I created a form. I placed a TTimer on this form and a label. The code is >> like this >> >> procedure TMainForm.ShowNotification(Msg:String; time:Cardinal); >> var >> MessageForm:TMessageChildForm; >> begin >> MessageForm:=TMessageChildForm.Create(Self); >> MessageForm.Show; >> MessageForm.Visible:=True; >> MessageForm.Label1.Caption:=Msg; >> MessageForm.Timer1.Interval:=time; >> MessageForm.Close; >> end; >> >> and the call is >> ShowNotification('Creating directories',5000); >> >> I assume this is 5 seconds but when I run the app it goes faster then that >> like not even 1 sec. Anything worng with the code above >> > > You are Closing the form yourself. "MessageForm.Close;" > > > You need to set the OnTimer Event of Timer1 and in that procedure is > where you call MessageForm.Close; > > Also disable the timer when it runs and reenable it when you call > ShowNotification > > > Happy Coding, > > Andrew > > _________________________________________________________________ > To unsubscribe: mail [EMAIL PROTECTED] with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
