Parameter for Timeout

Parameter for Timeout

Postby Jimmy » Mon Sep 18, 2023 3:48 am

hi,

und Xbase++ i have 4th Parameter for Timeout
Code: Select all  Expand view
  DO WHILE !lExit = .T.
      nEvent := AppEvent( @mp1, @mp2, @oXbp, nTimeOut )
      DO CASE
          CASE nEvent == xbe_None
            // Timeout
            DoTimeOut()
            RETURN

         CASE nEvent == xbeP_Keyboard .AND. mp1 == xbeK_ESC
            EXIT
      OTHERWISE
         oXbp:handleEvent( nEvent, mp1, mp2 )
      ENDCASE
   ENDDO

this Way a Windows / Dialog can be "close" when "Timeout" is reach

how to use that Concept under Fivewin :idea:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby karinha » Mon Sep 18, 2023 1:17 pm

hello, look \samples\GAME.PRG

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7766
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Parameter for Timeout

Postby Jimmy » Mon Sep 18, 2023 3:58 pm

hi,

thx for Answer

to use a TIMER is not a Solution

4th Parameter of AppEvent ( = ACTIVATE ) does react on "NO Event" within "Timeout"
i can check
Code: Select all  Expand view
         CASE nEvent == xbe_None
            // Timeout
            DoCloseWindowAndDBF()

and "close" Window/Dialog and DBF

"NO Event" mean that there is no "Input" or "Mouse-Move" in Event-Queue of App
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby karinha » Mon Sep 18, 2023 4:53 pm

DoCloseWindowAndDBF() ???

I don't understand? You show a piece of program. There's no way to guess what you want to do! Show an EXAMPLE in practice.

¿No entiendo? Muestras una parte del programa. ¡No hay forma de adivinar lo que quieres hacer! Muestre un EJEMPLO en la práctica.

Gracias, thanks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7766
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Parameter for Timeout

Postby Jimmy » Mon Sep 18, 2023 8:06 pm

hi,
karinha wrote:Show an EXAMPLE in practice.

will Xbase++ CODE help you to understand :?:
Code: Select all  Expand view
PROCEDURE DoCloseWindowAndDBF()
   IF USED()
      nRecordWork := RECNO()   // remember last work
      CLOSE
   ENDIF
   lExit := .T.                // Field wide STATIC
RETURN


---

AppEvent() is like ACTIVATE and 4th Parameter is for TIMEOUT
AppEvent() get Events when Keyboard "input" or Mouse move or other Action

if used 4th Parameter of AppEvent it include "Timeout"
when "no Event" arrive and after "timeout" is over, it send Event xbe_None

now i can react on xbe_None and call "DoCloseWindowAndDBF()"

---

my Question is : how can i "simulate" 4th Parameter of AppEvent() under Fivewin :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby karinha » Mon Sep 18, 2023 8:26 pm

Code: Select all  Expand view

PROCEDURE DoCloseWindowAndDBF()

   IF USED()

      nRecordWork := RECNO()   // remember last work

      GOTO( nRecordWork )
 
      CLOSE( cAlias ) // Name ALIAS()

      // oDlg:End() // static
      // oWnd:End() // etc

   ENDIF

   lExit := .T.                // Field wide STATIC

RETURN NIL
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7766
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Parameter for Timeout

Postby Jimmy » Wed Sep 20, 2023 10:49 am

hi,

Thx for Answer.

i do not have Problem to write CODE for DoCloseWindowAndDBF()

my "Problem" is to get a "Timeout" which will "activate" call of DoCloseWindowAndDBF() when "Timeout"

---

HMG use DOEVENTS which "seem" me equivalent to Fivewin SysRefresh()

it use TranslateMessage( &Msg ) and DispatchMessage( &Msg ) to get Event from Queue
Code: Select all  Expand view
HB_FUNC ( DOEVENTS )
{
   MSG Msg;
   HWND hDlgModeless = NULL;
   while( PeekMessage ( &Msg, NULL, 0, 0, PM_REMOVE ) )
   {  
      hDlgModeless = GetActiveWindow();   // this is not better way of take Handle of Modeless Dialog Box

      if ( hDlgModeless == NULL || !IsDialogMessage ( hDlgModeless, &Msg ) )   // ADD June 2015
      {
         TranslateMessage ( &Msg );
         DispatchMessage  ( &Msg );
      }
   }
}
 

if there is "NO Event" and "Timeout" is over than it should send "itself" a Event like xbe_None
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby karinha » Wed Sep 20, 2023 1:16 pm

Holá,

Jimmy, make a COMPLETE EXAMPLE with all the FUNCTIONS, your way of programming is very complex, and I think you mix another LIB with FIVEWIN. It's very difficult to understand you.

Jimmy, haz un EJEMPLO COMPLETO con todas las FUNCIONES, tu forma de programar es muy compleja, y creo que mezclas otra LIB con FIVEWIN. Es muy difícil entenderte.

Gracias, thanks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7766
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Parameter for Timeout

Postby Jimmy » Wed Sep 20, 2023 2:54 pm

hi,

sorry, you still does not understand my Question what Upload Sample show.
that CODE only work with Xbase++ ... i have NO harbour Sample (yet)

---

Windows Screen-Saver or Energy.Saving have a "Timeout" like i want to have in my harbour App
Xbase++ CAN use 4th Parameter for "Timeout" but HMG or Fivewin / harbour have NO Equivalent as i know

as i remember right i had a "Screen-Saver" in my Cl*pper App but i can´t find that SOURCE any more

---

New Question : how to build Screen-Saver for Fivewin :idea:
i do not mean "Animation", i mean how to detect "Timeout" of App so Screen-Saver will be "activate" :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby hebert_j_vargas » Wed Sep 20, 2023 3:52 pm

Hi Jimmy, I think you're looking for this function in harbour hb_idle_add( bBlock )

Code: Select all  Expand view

PROCEDURE Main()

   CLS

   ? "DEFAULT IDLEREPEAT =", Set( _SET_IDLEREPEAT )
   ?
   ? "Idle Block should be displayed multiple times until key or 10 seconds elapsed!"
   ? "Press any key to begin..."
   ?
   Inkey( 0 )

   hb_idleAdd( {|| QOut( "Idle Block" ) } )
   Inkey( 2 )

   Set( _SET_IDLEREPEAT, .F. )

   hb_idleAdd( {|| QOut( "Idle Block2" ) } )

   CLS
   ? "Idle Block & Block-2 should display ONCE! while waitning for key or 10 seconds elapsed!"
   ?
   Inkey( 2 )

   ?
   ? "Again - Idle Block & Block-2 should display ONCE! while waitning for key or 10 seconds elapsed!"
   ?
   Inkey( 2 )
   ?

   RETURN

 
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)
FiveWin Version: FWHX 15.01
BCC 5.8.2
User avatar
hebert_j_vargas
 
Posts: 99
Joined: Thu Aug 02, 2012 3:21 pm

Re: Parameter for Timeout

Postby karinha » Wed Sep 20, 2023 4:16 pm

Jimmy, see if it helps:

Code: Select all  Expand view

// C:\FWH..\SAMPLES\SCREENSA.PRG

// How to create a screensaver that will be executed when a GET is not used for some time

#include "FiveWin.ch"

static nTime := 0

function Main()

   local oDlg, oSay, oGet, cTest := Space( 10 )

   DEFINE DIALOG oDlg TITLE "Test"

   @ 0.5, 8 SAY oSay PROMPT "Elapsed time: " + AllTrim( Str( nTime ) ) + " secs."
   
   @ 3, 7 GET oGet VAR cTest PASSWORD
   
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT BuildTimer( oDlg, oSay, oGet )

return nil

function BuildTimer( oDlg, oSay, oGet )

   local oTmr
   
   DEFINE TIMER oTmr OF oDlg ;
      ACTION ( nTime++, oSay:Refresh(), If( nTime > 14, ScreenSaver(),)) INTERVAL 1000

   ACTIVATE TIMER oTmr
   
   oGet:bKeyDown = { | nKey | nTime := 0, nKey }
   
return nil  

function ScreenSaver()

   static oDlg

   nTime = 0

   if oDlg == nil

      ShowWindow( FindWindow( "Shell_TrayWnd", "" ), 0 ) // Taskbar
      ShowWindow( FindWindow( "Button", "Start" ), 0 ) // Vista round button

      DEFINE DIALOG oDlg STYLE WS_VISIBLE COLOR "W/B" SIZE GetSysMetrics( 0 ), GetSysMetrics( 1 )
   
      @ 10, 10 SAY "This is a screensaver" COLOR "W/B"
   
      oDlg:bKeyDown = { || oDlg:End() }
   
      ACTIVATE DIALOG oDlg ;
         ON CLICK oDlg:End()

      ShowWindow( FindWindow( "Shell_TrayWnd", "" ), 1 )
      ShowWindow( FindWindow( "Button", "Start" ), 1 )
         
      oDlg = nil
      nTime = 0

   endif    
   
return nil
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7766
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Parameter for Timeout

Postby Jimmy » Thu Sep 21, 2023 3:29 am

hi,
hebert_j_vargas wrote:I think you're looking for this function in harbour hb_idle_add( bBlock )

thx for Answer.

i have Problem with "Console" App ... it does not show anything on Screen ... :(
have try REQUEST HB_GT_WIN_DEFAULT but got "unknown Function" ...
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby Jimmy » Thu Sep 21, 2023 3:31 am

hi,
karinha wrote:see if it helps:

YES, your Sample work in right Direction. :D

instead of Screen-Save it should "close" WINDOWS / DIALOG and DBF if USED()
Thx for Idea, now i can work in that Direction
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Parameter for Timeout

Postby Marc Venken » Thu Sep 21, 2023 9:26 am

Karinha,

Very usefull piece of code.

If a program is left open bij a user (like so ofthen) the code will show the screensaver (with a message that a program need to be closed) It even works if you are working in a other program. Nice and thanks

if the screensaver stays active for xxx time, you could even force a close all and close dialog and terminate the program. Interesting idea
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1417
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Parameter for Timeout

Postby Jimmy » Thu Sep 21, 2023 11:15 am

hi Marc,

that is exact the Idea for "File-based" System and Network to reduce SMB Problem
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1725
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 43 guests

cron