Timer on a Dialog

Post Reply
User avatar
vilian
Posts: 984
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Timer on a Dialog

Post by vilian »

Hi Guys,
I'm trying create a Timer on a dialog by this way:

Code: Select all | Expand

DEFINE DIALOG oDlg RESOURCE "TESTE01" OF oWnd

       REDEFINE BITMAP oBmp ID 101 OF oDlg FILE (cQrc) ADJUST UPDATE
       REDEFINE METER oMtr VAR nPerc TOTAL 100 ID 102 OF oDlg UPDATE
               
       REDEFINE BUTTONBMP ID 105 OF oDlg ACTION ( oDlg:End() ) CANCEL UPDATE

       DEFINE TIMER oTmr OF oDlg INTERVAL 5000 ACTION Consultar(oDlg,oTmr,oMtr,@nPerc,cIDPix) 

 ACTIVATE DIALOG oDlg CENTERED ;
               ON INIT oTmr:Activate()
However, the function Consultar() is never being executed. Do you know Why ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
paquitohm
Posts: 284
Joined: Fri Jan 14, 2022 8:37 am

Re: Timer on a Dialog

Post by paquitohm »

So perhaps,

DEFINE TIMER oTmr OF WndMain() INTERVAL 5000 ACTION Consultar(oDlg,oTmr,oMtr,@nPerc,cIDPix)
User avatar
Enrico Maria Giordano
Posts: 8728
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Timer on a Dialog

Post by Enrico Maria Giordano »

Or:

Code: Select all | Expand

ON INIT ( oTmr:hWndOwner := oDlg:hWnd, oTmr:Activate() )
User avatar
Marc Venken
Posts: 1481
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Timer on a Dialog

Post by Marc Venken »

I have this in my code... (grabed it somewhere here)

Code: Select all | Expand


     oDlg:bInit := <||
      DEFINE TIMER oTimer OF oDlg INTERVAL 100 ;
         ACTION If( nStartSec == nil,,( nSecsLapsed := SecsLapsed( nStartSec ),oSay:Refresh() ) )
      ACTIVATE TIMER oTimer
      return nil
      >

     ACTIVATE DIALOG oDlg CENTERED;
     VALID ( oTimer:End(), .t. )

 
Marc Venken
Using: FWH 23.08 with Harbour
User avatar
vilian
Posts: 984
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Timer on a Dialog

Post by vilian »

Thank you Enrico,
It worked perfectly ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Post Reply