FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Parameter for Timeout
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Parameter for Timeout
Posted: Mon Sep 18, 2023 03:48 AM
hi,

und Xbase++ i have 4th Parameter for Timeout
Code (fw): Select all Collapse
   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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 01:17 PM

hello, look \samples\GAME.PRG

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 03: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 (fw): Select all Collapse
          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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 04: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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 08:06 PM
hi,
karinha wrote:Show an EXAMPLE in practice.
will Xbase++ CODE help you to understand :?:
Code (fw): Select all Collapse
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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 08:26 PM
Code (fw): Select all Collapse
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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: 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 (fw): Select all Collapse
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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 01: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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 02: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
Posts: 99
Joined: Thu Aug 02, 2012 03:21 PM
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 03:52 PM
Hi Jimmy, I think you're looking for this function in harbour hb_idle_add( bBlock )
Code (fw): Select all Collapse
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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 04:16 PM
Jimmy, see if it helps:
Code (fw): Select all Collapse
// 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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 03: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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 03: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
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 09: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.08 with Harbour
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Parameter for Timeout
Posted: 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