Jump to content
Fivewin Brasil

DIALOG MSG com Button Temporizando


Theotokos

Recommended Posts

			MsgRun( cMensagem,"LEIA Antes ",;
					  {|o| EsperarMsgRun(o) }  )
					  

Function EsperarMsgRun(o)
	
	LOCAL nSegIni := Secs(Time())
	LOCAL nSegFim := 0
	
	While .T.
		nSegFim := Secs(Time())-nSegIni
		o:cTitle := "LEIA Antes" + ;
						" - AGUARDE...     " + StrZero( nSegFim, 2) + '" / 20"'
		o:Refresh()
		
		If nSegFim >= 20
			Exit
		EndIf
	EndDo
	
Return

FAço assim atualmente, quero substituir a MsgRun por uma DIALOG com Botão, e que o tempo fosse aparecendo no botão e depois que terminasse libera o botão...

Link to comment
Share on other sites

Veja se ajuda. Você pode ir mostrando o tempo de espera no Botão com o Refresh(), eu acho...

[code]
// tinativo.prg - By William Adami
// exemplo do uso da classe Tinativo
// Apos um tempo de inatividade do mouse
// e do teclado chama uma funcao qualquer.

#include "fivewin.ch"

STATIC oWnd

//************

FUNCTION Main()

   LOCAL nTempo_espera, cNome_funcao, lTimercontinua

   // Tempo a ser esperado ate chamar a funcao
   // -> 1 hora tem 3600 segundos.
   nTempo_espera := 10  // segundos. 

   // nome da funcao a ser chamada quando
   // chegar no tempo de espera
   cNome_funcao := "LOGOFF()"   
   // se apos executar a funcao , continua
   // monitorando a inatividade do mouse e teclado.
   lTimercontinua := .F.

   define window oWnd title "Teste de teclado e mouse"

   activate window oWnd ;
      ON INIT tinativo():new( nTempo_espera, cNome_funcao, lTimerContinua )

RETURN NIL

FUNCTION LOGOFF()

   // msgalert( "AQUI ENTRA SUA FUNCAO DE LOGOFF !", "AVISO" )

   IF MsgYesNo( OemToAnsi( "ATEN€ÇO USUµRIO:                       " )+CRLF+ ;
                OemToAnsi( "PROTEJA OS BANCOS DE DADOS DO PROGRAMA." )+CRLF+ ;
                OemToAnsi( "SE NÇO ESTIVER USANDO O WINORCAM.EXE,  " )+CRLF+ ;
                OemToAnsi( "DESLIGUE-O PARA NÇO CORRER RISCOS.     " )+CRLF+ ;
                OemToAnsi( "POSSO DESLIGAR O PROGRAMA? <S> ou <N>??" ),      ;
                OemToAnsi( "AVISO PARA DESLIGAR O WINORCAM.EXE...  " ) )

      //--Fecha o Programa Definitivamente
      LIBERA_TUDO()  // ESTA EM WINORCAM.PRG

      // QUIT

   ENDIF

RETURN NIL

//   tinativo.prg

#include "fivewin.ch"

CLASS TINATIVO

   DATA nTimeInpAntes
   DATA nTimeInpDepois
   DATA cTimeAtu
   DATA nTempo
   DATA oTimerTime
   DATA cFunc
   DATA lContinuar

   METHOD NEW( nTime, cFuncao, lContinua )  CONSTRUCTOR

   METHOD ver_tempo()

ENDCLASS

METHOD new( ntime, cFuncao, lContinua ) CLASS TINATIVO

   ::cfunc := cfuncao
   ::ntempo := ntime
   ::lContinuar := lContinua
   ::oTimerTime := TTimer():New( 1000, { || ::VER_TEMPO() } )
   ::oTimerTime:Activate()
   ::cTimeAtu := time()
   ::nTimeInpAntes := getInputState()    // 0 = erro

RETURN self

METHOD VER_TEMPO CLASS TINATIVO

   LOCAL AUX

   ::nTimeInpDepois := getInputState()

   IF ( ::nTimeInpDepois - ::nTimeInpAntes ) > 0

      ::nTimeInpAntes := getInputState()

      ::cTimeAtu := time()

   ENDIF


   IF ( CONVTIME( time() ) - CONVTIME( ::cTimeAtu ) ) > ::ntempo

      ::oTimerTime:DeActivate()

      aux := ::cfunc
   
      // aqui executa a funcao

      &aux

      if ::lContinuar

         ::oTimerTime:Activate()
         ::cTimeAtu := time()

      ENDIF


   ENDIF

RETURN NIL

FUNCTION CONVTIME( ZZ )

   LOCAL Z

   Z := ( VAL( LEFT(ZZ,2 ) ) * 360 ) + ( VAL( SUBSTR(ZZ,4,2 ) ) * 60 ) + ;
          VAL( RIGHT( ZZ,2 ) )

RETURN Z

//*----------------------------------------------------------------------
#pragma BEGINDUMP
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETINPUTSTATE )
{
LASTINPUTINFO lpi;
lpi.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&lpi))
{
hb_retni(0);
}
hb_retni(lpi.dwTime);
}
#pragma ENDDUMP
 
// FIN / END
[/code]

Regards, saludos.

Link to comment
Share on other sites

Entendi o funcionamento do novo forum?

Veja se ajuda. Você pode ir mostrando o tempo de espera no Botão com o Refresh(), eu acho...

// tinativo.prg - By William Adami
// exemplo do uso da classe Tinativo
// Apos um tempo de inatividade do mouse
// e do teclado chama uma funcao qualquer.

#include "fivewin.ch"

STATIC oWnd

//************

FUNCTION Main()

   LOCAL nTempo_espera, cNome_funcao, lTimercontinua

   // Tempo a ser esperado ate chamar a funcao
   // -> 1 hora tem 3600 segundos.
   nTempo_espera := 10  // segundos. 

   // nome da funcao a ser chamada quando
   // chegar no tempo de espera
   cNome_funcao := "LOGOFF()"   
   // se apos executar a funcao , continua
   // monitorando a inatividade do mouse e teclado.
   lTimercontinua := .F.

   define window oWnd title "Teste de teclado e mouse"

   activate window oWnd ;
      ON INIT tinativo():new( nTempo_espera, cNome_funcao, lTimerContinua )

RETURN NIL

FUNCTION LOGOFF()

   // msgalert( "AQUI ENTRA SUA FUNCAO DE LOGOFF !", "AVISO" )

   IF MsgYesNo( OemToAnsi( "ATEN€ÇO USUµRIO:                       " )+CRLF+ ;
                OemToAnsi( "PROTEJA OS BANCOS DE DADOS DO PROGRAMA." )+CRLF+ ;
                OemToAnsi( "SE NÇO ESTIVER USANDO O WINORCAM.EXE,  " )+CRLF+ ;
                OemToAnsi( "DESLIGUE-O PARA NÇO CORRER RISCOS.     " )+CRLF+ ;
                OemToAnsi( "POSSO DESLIGAR O PROGRAMA? <S> ou <N>??" ),      ;
                OemToAnsi( "AVISO PARA DESLIGAR O WINORCAM.EXE...  " ) )

      //--Fecha o Programa Definitivamente
      LIBERA_TUDO()  // ESTA EM WINORCAM.PRG

      // QUIT

   ENDIF

RETURN NIL

//   tinativo.prg

#include "fivewin.ch"

CLASS TINATIVO

   DATA nTimeInpAntes
   DATA nTimeInpDepois
   DATA cTimeAtu
   DATA nTempo
   DATA oTimerTime
   DATA cFunc
   DATA lContinuar

   METHOD NEW( nTime, cFuncao, lContinua )  CONSTRUCTOR

   METHOD ver_tempo()

ENDCLASS

METHOD new( ntime, cFuncao, lContinua ) CLASS TINATIVO

   ::cfunc := cfuncao
   ::ntempo := ntime
   ::lContinuar := lContinua
   ::oTimerTime := TTimer():New( 1000, { || ::VER_TEMPO() } )
   ::oTimerTime:Activate()
   ::cTimeAtu := time()
   ::nTimeInpAntes := getInputState()    // 0 = erro

RETURN self

METHOD VER_TEMPO CLASS TINATIVO

   LOCAL AUX

   ::nTimeInpDepois := getInputState()

   IF ( ::nTimeInpDepois - ::nTimeInpAntes ) > 0

      ::nTimeInpAntes := getInputState()

      ::cTimeAtu := time()

   ENDIF


   IF ( CONVTIME( time() ) - CONVTIME( ::cTimeAtu ) ) > ::ntempo

      ::oTimerTime:DeActivate()

      aux := ::cfunc
   
      // aqui executa a funcao

      &aux

      if ::lContinuar

         ::oTimerTime:Activate()
         ::cTimeAtu := time()

      ENDIF


   ENDIF

RETURN NIL

FUNCTION CONVTIME( ZZ )

   LOCAL Z

   Z := ( VAL( LEFT(ZZ,2 ) ) * 360 ) + ( VAL( SUBSTR(ZZ,4,2 ) ) * 60 ) + ;
          VAL( RIGHT( ZZ,2 ) )

RETURN Z

//*----------------------------------------------------------------------
#pragma BEGINDUMP
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETINPUTSTATE )
{
LASTINPUTINFO lpi;
lpi.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&lpi))
{
hb_retni(0);
}
hb_retni(lpi.dwTime);
}
#pragma ENDDUMP
 
// FIN / END

Regards, saludos.

 

Link to comment
Share on other sites

A sua função corrigida, exibe contagem regressiva.

Haviam usos inadequados.

MsgRun( 'teste',"LEIA Antes - Aguarde ...", {|o| EsperarMsgRun(o) }  )

Function EsperarMsgRun(o)
   LOCAL nSec
   local cTitle
   
   nSec:=20
   cTitle:=o:cTitle
   DO While nSec >= 0
      o:cTitle := cTitle + ' ' + StrZero( nSec--, 2)
      WaitSeconds(1)
      SysRefresh()
   EndDo
   
   Return NIL

[],
Eric

Site | Facebook | YouTube

16 horas atrás, Theotokos disse:
			MsgRun( cMensagem,"LEIA Antes ",;
					  {|o| EsperarMsgRun(o) }  )
					  

Function EsperarMsgRun(o)
	
	LOCAL nSegIni := Secs(Time())
	LOCAL nSegFim := 0
	
	While .T.
		nSegFim := Secs(Time())-nSegIni
		o:cTitle := "LEIA Antes" + ;
						" - AGUARDE...     " + StrZero( nSegFim, 2) + '" / 20"'
		o:Refresh()
		
		If nSegFim >= 20
			Exit
		EndIf
	EndDo
	
Return

FAço assim atualmente, quero substituir a MsgRun por uma DIALOG com Botão, e que o tempo fosse aparecendo no botão e depois que terminasse libera o botão...

Link to comment
Share on other sites

6 horas atrás, kapiaba disse:
Entendi o funcionamento do novo forum?

Veja se ajuda. Você pode ir mostrando o tempo de espera no Botão com o Refresh(), eu acho...

// tinativo.prg - By William Adami
// exemplo do uso da classe Tinativo
// Apos um tempo de inatividade do mouse
// e do teclado chama uma funcao qualquer.

#include "fivewin.ch"

STATIC oWnd

//************

FUNCTION Main()

   LOCAL nTempo_espera, cNome_funcao, lTimercontinua

   // Tempo a ser esperado ate chamar a funcao
   // -> 1 hora tem 3600 segundos.
   nTempo_espera := 10  // segundos. 

   // nome da funcao a ser chamada quando
   // chegar no tempo de espera
   cNome_funcao := "LOGOFF()"   
   // se apos executar a funcao , continua
   // monitorando a inatividade do mouse e teclado.
   lTimercontinua := .F.

   define window oWnd title "Teste de teclado e mouse"

   activate window oWnd ;
      ON INIT tinativo():new( nTempo_espera, cNome_funcao, lTimerContinua )

RETURN NIL

FUNCTION LOGOFF()

   // msgalert( "AQUI ENTRA SUA FUNCAO DE LOGOFF !", "AVISO" )

   IF MsgYesNo( OemToAnsi( "ATEN€ÇO USUµRIO:                       " )+CRLF+ ;
                OemToAnsi( "PROTEJA OS BANCOS DE DADOS DO PROGRAMA." )+CRLF+ ;
                OemToAnsi( "SE NÇO ESTIVER USANDO O WINORCAM.EXE,  " )+CRLF+ ;
                OemToAnsi( "DESLIGUE-O PARA NÇO CORRER RISCOS.     " )+CRLF+ ;
                OemToAnsi( "POSSO DESLIGAR O PROGRAMA? <S> ou <N>??" ),      ;
                OemToAnsi( "AVISO PARA DESLIGAR O WINORCAM.EXE...  " ) )

      //--Fecha o Programa Definitivamente
      LIBERA_TUDO()  // ESTA EM WINORCAM.PRG

      // QUIT

   ENDIF

RETURN NIL

//   tinativo.prg

#include "fivewin.ch"

CLASS TINATIVO

   DATA nTimeInpAntes
   DATA nTimeInpDepois
   DATA cTimeAtu
   DATA nTempo
   DATA oTimerTime
   DATA cFunc
   DATA lContinuar

   METHOD NEW( nTime, cFuncao, lContinua )  CONSTRUCTOR

   METHOD ver_tempo()

ENDCLASS

METHOD new( ntime, cFuncao, lContinua ) CLASS TINATIVO

   ::cfunc := cfuncao
   ::ntempo := ntime
   ::lContinuar := lContinua
   ::oTimerTime := TTimer():New( 1000, { || ::VER_TEMPO() } )
   ::oTimerTime:Activate()
   ::cTimeAtu := time()
   ::nTimeInpAntes := getInputState()    // 0 = erro

RETURN self

METHOD VER_TEMPO CLASS TINATIVO

   LOCAL AUX

   ::nTimeInpDepois := getInputState()

   IF ( ::nTimeInpDepois - ::nTimeInpAntes ) > 0

      ::nTimeInpAntes := getInputState()

      ::cTimeAtu := time()

   ENDIF


   IF ( CONVTIME( time() ) - CONVTIME( ::cTimeAtu ) ) > ::ntempo

      ::oTimerTime:DeActivate()

      aux := ::cfunc
   
      // aqui executa a funcao

      &aux

      if ::lContinuar

         ::oTimerTime:Activate()
         ::cTimeAtu := time()

      ENDIF


   ENDIF

RETURN NIL

FUNCTION CONVTIME( ZZ )

   LOCAL Z

   Z := ( VAL( LEFT(ZZ,2 ) ) * 360 ) + ( VAL( SUBSTR(ZZ,4,2 ) ) * 60 ) + ;
          VAL( RIGHT( ZZ,2 ) )

RETURN Z

//*----------------------------------------------------------------------
#pragma BEGINDUMP
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
#include "windows.h"
#include "hbapi.h"
HB_FUNC( GETINPUTSTATE )
{
LASTINPUTINFO lpi;
lpi.cbSize = sizeof(LASTINPUTINFO);
if (!GetLastInputInfo(&lpi))
{
hb_retni(0);
}
hb_retni(lpi.dwTime);
}
#pragma ENDDUMP
 
// FIN / END

Regards, saludos.

 

Blz!!! Vou Testar hoje a noite.... Obgdao!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...