Page 1 of 1

MsgInfo() with Timer

Posted: Tue Feb 01, 2011 12:57 pm
by Anderson.OL
Good morning everyone ..

Has anyone modified the function MsgInfo () so that if the user is not near the pc, after 5 seconds it closes and the system continues its processing?

Re: MsgInfo() with Timer

Posted: Tue Feb 01, 2011 3:24 pm
by ukoenig
Hello,
I think instead of using Msginfo :

MsgWait( "Please, just wait a little!", "This is a test", 15 ) // 15 Seconds

MsgInfo() is used, to force a user, to take notice of something happend.

Best Regards
Uwe :lol:

Re: MsgInfo() with Timer

Posted: Tue Feb 01, 2011 4:51 pm
by Anderson.OL
I created the following functions

Code: Select all

****************************************************************************
static procedure MsgTimer(cMessageCaption, nSeconds)
****************************************************************************
*
* Fechar um MsgDialog automaticamente
* Parametros: cMessageCaption, nSegundos
* Retorno: Nenhum
*
* Autor: Anderson
* 1/2/2011 - 12:03:46
*
****************************************************************************

public oTmr := NIL

   Define Timer    oTmr             ;
          Interval 1000             ;
          ;//Action   (if (nHandle > 0 , nTempo++  , /* nada faz */ ),;
          ;//          DoIncTimer() )  ;
          Action   DoIncTimer(cMessageCaption, nSeconds);
          of       oWnd
          
   oTmr:Activate()

Return Nil

/*------------------------------------------------------------------------*/

****************************************************************************
static procedure DoIncTimer(cMessageCaption, nSeconds)
****************************************************************************
*
* Tarefa a ser executada antes de estourar o timer
* Parametros: cMessageCaption, nSeconds
* Retorno: Nenhum
*
* Autor: Anderson
* 1/2/2011 - 12:17:07
*
****************************************************************************

static nHandle := -1
static nTempo  := 0

   if nHandle <= 0
      nHandle := FindWindow(nil, cMessageCaption)
      SetWindowText(nHandle,cMessageCaption + ' (' + StrTrim(nSeconds - nTempo) + ')')
   end

   if nHandle > 0
   
      //-- Começa a contar a partir do momento que acha a janela ---------//
      
      nTempo++
      
      if nTempo == nSeconds
      
         //-- Se estorou o tempo fecha a janela e destroi o timer --------//
         SendMessage(nHandle, WM_CLOSE)
         oTmr:Deactivate()
         oTmr:End()
         Release oTmr
         
      else
      
         //-- Exibe a contagem do tempo ----------------------------------//
         
         SetWindowText(nHandle,cMessageCaption + ' (' + StrTrim(nSeconds - nTempo) + ')')
         
      end
      
   end

Return Nil

/*------------------------------------------------------------------------*/
And I use this way.

Code: Select all

MsgTimer('Informação',10)
MsgInfo('Mensagem','Informação')