Page 1 of 1

Timer on a Dialog

Posted: Thu Nov 21, 2024 8:44 pm
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 ?

Re: Timer on a Dialog

Posted: Thu Nov 21, 2024 9:37 pm
by paquitohm
So perhaps,

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

Re: Timer on a Dialog

Posted: Thu Nov 21, 2024 10:13 pm
by Enrico Maria Giordano
Or:

Code: Select all | Expand

ON INIT ( oTmr:hWndOwner := oDlg:hWnd, oTmr:Activate() )

Re: Timer on a Dialog

Posted: Fri Nov 22, 2024 8:22 am
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. )

 

Re: Timer on a Dialog

Posted: Fri Nov 22, 2024 10:58 am
by vilian
Thank you Enrico,
It worked perfectly ;)