Theotokos Posted December 14, 2023 Report Share Posted December 14, 2023 Olá pessoal, boa tarde!!! Alguem ja fez uma dialog para apresentar uma mensagem e que tenha um Botão de OK (exemplo) e que ele só é liberado após certo tempo (a programar)? Quote Link to comment Share on other sites More sharing options...
Theotokos Posted December 14, 2023 Author Report Share Posted December 14, 2023 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... Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 15, 2023 Report Share Posted December 15, 2023 Rapaz... Não entendi muito bem, e essa mensagem: " depois que terminasse libera o botão..." não me caiu muito bem... kkkkkkkkkkkkkkkk Eu num rô naum!!! kkkkkkkkkkkkkk Vou estudar melhor... Abs. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 15, 2023 Report Share Posted December 15, 2023 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. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 15, 2023 Report Share Posted December 15, 2023 Forum novo. Testando o código fonte. Jesuis acende a luz. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted December 15, 2023 Report Share Posted December 15, 2023 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. Quote Link to comment Share on other sites More sharing options...
Eric.Developer Posted December 15, 2023 Report Share Posted December 15, 2023 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... Quote Link to comment Share on other sites More sharing options...
Theotokos Posted December 15, 2023 Author Report Share Posted December 15, 2023 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!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.