Page 1 of 2
Parameter for Timeout
Posted: Mon Sep 18, 2023 3:48 am
by Jimmy
hi,
und Xbase++ i have 4th Parameter for Timeout
Code: Select all | Expand
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
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 1:17 pm
by karinha
hello, look \samples\GAME.PRG
Regards, saludos.
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 3:58 pm
by Jimmy
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
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
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 4:53 pm
by karinha
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.
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 8:06 pm
by Jimmy
hi,
karinha wrote:Show an EXAMPLE in practice.
will Xbase++ CODE help you to understand
Code: Select all | Expand
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
Re: Parameter for Timeout
Posted: Mon Sep 18, 2023 8:26 pm
by karinha
Code: Select all | Expand
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.
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 10:49 am
by Jimmy
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
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
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 1:16 pm
by karinha
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.
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 2:54 pm
by Jimmy
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
i do not mean "Animation", i mean how to detect "Timeout" of App so Screen-Saver will be "activate"
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 3:52 pm
by hebert_j_vargas
Hi Jimmy, I think you're looking for this function in harbour hb_idle_add( bBlock )
Code: Select all | Expand
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
Re: Parameter for Timeout
Posted: Wed Sep 20, 2023 4:16 pm
by karinha
Jimmy, see if it helps:
Code: Select all | Expand
// 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.
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 3:29 am
by Jimmy
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" ...
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 3:31 am
by Jimmy
hi,
karinha wrote:see if it helps:
YES, your Sample work in right Direction.
instead of Screen-Save it should "close" WINDOWS / DIALOG and DBF if USED()
Thx for Idea, now i can work in that Direction
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 9:26 am
by Marc Venken
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
Re: Parameter for Timeout
Posted: Thu Sep 21, 2023 11:15 am
by Jimmy
hi Marc,
that is exact the Idea for "File-based" System and Network to reduce SMB Problem