Tem como usar Hb_IdleAdd com hwgui?

Projeto HwGui - Biblioteca visual para Harbour/xHarbour

Moderador: Moderadores

Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

Tem como usar Hb_IdleAdd com hwgui?

Mensagem por asimoes »

Pessoal, tem como usar Hb_IdleAdd com hwgui?

Estou vendo aqui sem sucesso
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

Tem como usar Hb_IdleAdd com hwgui?

Mensagem por asimoes »

Já vi que não dá então tive que criar
Só pra exemplificar

Código: Selecionar todos

  WITH OBJECT oMonitorSDP := ClMonitorSDP():New()
      oDlg_Wait := :MonitorSDP()
      :Liga_Timer( oDlg_Wait, .T., 1000 * 10, { || hwg_MsgInfo() }, "oTimer" ) 
   END

Código: Selecionar todos

#include "hwgui.ch"
#include "hbclass.ch"

#define HB_SYMBOL_UNUSED( symbol )  ( symbol := ( symbol ) )
   
THREAD STATIC ThisForm
  
CREATE CLASS ClMonitorSDP

   PROTECTED :
   
   EXPORTED :   
   
   METHOD MonitorSDP()
   METHOD Liga_Timer( oJanela, lLiga, nTime, bBlock, oTimer ) 

ENDCLASS

METHOD MonitorSDP( nTimeOut ) 
LOCAL oDlg_Wait 
   
   Hb_Default(@nTimeOut, 3600)

   INIT DIALOG oDlg_Wait ;
               TITLE       "" ;
               AT          0, 0 ;
               SIZE        0, 0 ;
               FONT        HFont():Add( 'Tahoma', 0, -13, 400 )
   
   ThisForm := oDlg_Wait
   
   ::Liga_Timer( oDlg_Wait, .T., 1000 * 30, { || hwg_MsgInfo() }, "oTimer" ) 
   
   ACTIVATE DIALOG oDlg_Wait NOMODAL SHOW SW_HIDE  
   
RETURN oDlg_Wait

METHOD Liga_Timer( oJanela, lLiga, nTime, bBlock, oTimer ) 

   IF lLiga
      SET TIMER &oTimer. of oJanela VALUE nTime ACTION bBlock
   ELSE
      oJanela:&oTimer.:End()   
   ENDIF
   
RETURN Nil

►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

Tem como usar Hb_IdleAdd com hwgui?

Mensagem por asimoes »

Simplificando:

bBlock é onde eu vou passar a rotina, no meu caso é uma rotina recursiva que atualiza uma tabela até não existir mais registros
Tem que ter cuidado ao finalizar a rotina, porque tem uma janela em execução em SHOW SW_HIDE, não modal

Código: Selecionar todos

#include "hwgui.ch"
#include "hbclass.ch"

#define HB_SYMBOL_UNUSED( symbol )  ( symbol := ( symbol ) )
   
CREATE CLASS ClMonitorSDP

   PROTECTED :
   
   EXPORTED :   
   
   METHOD MonitorSDP()
   METHOD Liga_Timer( oJanela, lLiga, nTime, bBlock, oTimer ) 

ENDCLASS

METHOD MonitorSDP() 
LOCAL oDlg_Wait 
   
   INIT DIALOG oDlg_Wait ;
               TITLE       "" ;
               AT          0, 0 ;
               SIZE        0, 0 ;
               FONT        HFont():Add( 'Tahoma', 0, -13, 400 )
   
   ACTIVATE DIALOG oDlg_Wait NOMODAL SHOW SW_HIDE  
   
RETURN oDlg_Wait

METHOD Liga_Timer( oJanela, lLiga, nTime, bBlock, oTimer ) 

   IF lLiga
      SET TIMER &oTimer. of oJanela VALUE nTime ACTION bBlock
   ELSE
      oJanela:&oTimer.:End()   
   ENDIF
   
RETURN Nil
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

Tem como usar Hb_IdleAdd com hwgui?

Mensagem por asimoes »

Mais uma modificação:

Código: Selecionar todos

   WITH OBJECT oMonitorSDP := ClMonitorSDP():New()
      oDlg_MonitorSDP := :MonitorSDP()
      :oTimer := "oTimerMonitor"
      :nTimer := 10 * 1000
      :bBlock := {|| Demo() }
      :Start()
   END

Código: Selecionar todos

*----------------------------------------------------------------
* Autor: Alexandre Simões
* Data : 05/02/2021
* Lib  : HwGui 2.17 (fork)
* ---------------------------------------------------------------
* Thread para executar uma rotina durante a execução da aplicação
* A execução é feita em janela Hide não modal
* ---------------------------------------------------------------

#include "hwgui.ch"
#include "hbclass.ch"

#define HB_SYMBOL_UNUSED( symbol )  ( symbol := ( symbol ) )
   
CREATE CLASS ClMonitorSDP

   PROTECTED :
   
   EXPORTED :   
   
   VAR oJanela AS OBJECT    INIT Nil
   VAR bBlock  AS CODEBLOCK INIT Nil
   VAR oTimer  AS STRING    INIT "oTimerSDP"
   VAR nTimer  AS INTEGER   INIT 10 * 1000 
   
   METHOD MonitorSDP()
   METHOD Liga_Timer( oJanela, lLiga )
   METHOD Start()
   METHOD Stop() 
   METHOD Close()

ENDCLASS

METHOD MonitorSDP() 
LOCAL oDlg_Wait 
   
   INIT DIALOG oDlg_Wait ;
               TITLE "" ;
               AT    0, 0 ;
               SIZE  0, 0
   
   ::oJanela := oDlg_Wait
   
   ACTIVATE DIALOG oDlg_Wait NOMODAL SHOW SW_HIDE  
   
RETURN ::oJanela

METHOD Start()
   
   ::Liga_Timer( ::oJanela, .T. )
   
RETURN Nil

METHOD Stop()

    ::Liga_Timer( ::oJanela, .F. )

RETURN Nil

METHOD Close()

   IF Hb_IsObject( ::oJanela )
      ::oJanela:Close()
   ENDIF
   
RETURN Nil

METHOD Liga_Timer( oJanela, lLiga ) 
LOCAL oTimer := ::oTimer

   IF lLiga
      SET TIMER &oTimer. of ::oJanela VALUE ::nTimer ACTION ::bBlock
   ELSE
      oJanela:&oTimer.:End()  
   ENDIF
   
RETURN Nil
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Responder