Page 1 of 1

Close Activated Dialog by oWnd:oTimer

PostPosted: Sat Feb 01, 2020 3:05 am
by dutch
Dear All,

I need to close all activated dialog by autooff() *alike screen saver*. I can use this below function for automatic log off (popup login screen) the program.
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=21595&start=0&hilit=getInputState

I need to return to main windows (close all sub dialog), If user does not use for specific time.

How to do this?

Thanks in advance,

Re: Close Activated Dialog by oWnd:oTimer

PostPosted: Mon Feb 10, 2020 3:02 pm
by ukoenig
Dutch

I need to return to main windows (close all sub dialog), If user does not use for specific time.


You can use a logical var for each dialog ( lOpen := .T. or .F. )
Maybe a solution You are looking for

I have still a question to
How can I set the vars lOpen{1], lOpen{2] or lOpen{3] to .F. in case one of the dialog-systembuttons exit is used to perform a defined action :?:

This sample works : the timer is closing all open dialogs from inside a window

Image

Code: Select all  Expand view

#include "fivewin.ch"

#define SC_CLOSE   0xF060

STATIC oWnd, oTimer, lOpen[3]

FUNCTION MAIN()
local oDlg[3], oBtn[4]

I := 1
FOR I := 1 TO 3
    lOpen[3] := .F.
NEXT

DEFINE WINDOW oWnd TITLE "Dialog AUTOCLOSE" ;
FROM 0, 0 TO 24, 64 PIXEL  
oWnd:SetColor( 0, 16762509 )

@ 20, 30 BTNBMP oBtn[1] 2007 ;
SIZE 120, 30 PROMPT "Open Dialog 1" OF oWnd NOBORDER ;
ACTION OPENDLG1(oDlg)

@ 20, 200 BTNBMP oBtn[2] 2007 ;
SIZE 120, 30 PROMPT "Open Dialog 2" OF oWnd NOBORDER ;
ACTION OPENDLG2(oDlg)

@ 20, 370 BTNBMP oBtn[3] 2007 ;
SIZE 120, 30 PROMPT "Open Dialog 3" OF oWnd NOBORDER ;
ACTION OPENDLG3(oDlg)

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT TIMER(oDlg)

RETURN NIL

//-------------------

FUNCTION OPENDLG1(oDlg)
LOCAL oDlgBtn

DEFINE DIALOG oDlg[1]  ;
FROM 150, 100 TO 450, 400 OF oWnd PIXEL
oDlg[1]:SetColor( 0, 13355927 )

@ 120, 30 BTNBMP oDlgBtn 2007 ;
SIZE 50, 20 PROMPT "Close" OF oDlg[1] NOBORDER ;
ACTION ( lOpen[1] := .F., oDlg[1]:End() )

ACTIVATE DIALOG oDlg[1] NOWAIT ;
ON INIT ( lOpen[1] := .T., NoCloseDlg( oDlg[1]:hWnd ) ) // disable system-exit

RETURN NIL

//-------------------

FUNCTION OPENDLG2(oDlg)
LOCAL oDlgBtn

DEFINE DIALOG oDlg[2] ;
FROM 150, 500 TO 450, 700 OF oWnd PIXEL
oDlg[2]:SetColor( 0, 11513815 )

@ 120, 30 BTNBMP oDlgBtn 2007 ;
SIZE 50, 20 PROMPT "Close" OF oDlg[2] NOBORDER ;
ACTION ( lOpen[2] := .F., oDlg[2]:End() )

ACTIVATE DIALOG oDlg[2] NOWAIT ;
ON INIT  lOpen[2] := .T.

RETURN NIL

//-------------------

FUNCTION OPENDLG3(oDlg)
LOCAL oDlgBtn

DEFINE DIALOG oDlg[3] ;
FROM 150, 800 TO 450, 1100 OF oWnd PIXEL  
oDlg[3]:SetColor( 0, 9028804 )

@ 120, 30 BTNBMP oDlgBtn 2007 ;
SIZE 50, 20 PROMPT "Close" OF oDlg[3] NOBORDER ;
ACTION ( lOpen[3] := .F., oDlg[3]:End() )

ACTIVATE DIALOG oDlg[3] NOWAIT ;
ON INIT lOpen[3] := .T.

RETURN NIL

//-----------------------

FUNCTION TIMER(oDlg)

IF oTimer == nil
      DEFINE TIMER oTimer INTERVAL 7000 ACTION CLOSEDLG(oDlg)
      ACTIVATE TIMER oTimer
ELSE
      Alert( "There is already a working timer..." )
ENDIF

RETURN NIL

//-------------------

FUNCTION CLOSEDLG(oDlg)
I := 1

FOR I := 1 TO 3
    IF lOpen[I] = .T.
        lOpen[I] := .F.
        oDlg[I]:End()
    ENDIF
NEXT

oWnd:Refresh()

RETURN NIL

//------------------- Disable the EXIT-button

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

HB_FUNC ( NOCLOSEDLG ) // ( hWnd )

{
   HMENU hMenu = GetSystemMenu( ( HWND ) hb_parnl( 1 ), FALSE ) ;
   EnableMenuItem( hMenu, SC_CLOSE, MF_GRAYED ) ;
}

#pragma ENDDUMP
 


regards
Uwe :?:

Re: Close Activated Dialog by oWnd:oTimer

PostPosted: Tue Feb 11, 2020 4:37 am
by dutch
Dear Uwe,

I got the solution as your recommendation, it works fine now. The lOpen will be .F. in the Main procedure (Home) after return from sub-dialog.

Thanks for an idea.
Dutch

Re: Close Activated Dialog by oWnd:oTimer

PostPosted: Thu Feb 13, 2020 1:15 am
by nageswaragunupudi
Code: Select all  Expand view
AEval( GetAllWin(), { |o| If( o == nil .or. o:hWnd == GetWndApp(), nil, o:End() ) } )
 

Re: Close Activated Dialog by oWnd:oTimer

PostPosted: Thu Feb 13, 2020 2:27 am
by dutch
Dear Mr.Rao,

I will test and feedback to you.
nageswaragunupudi wrote:
Code: Select all  Expand view
AEval( GetAllWin(), { |o| If( o == nil .or. o:hWnd == GetWndApp(), nil, o:End() ) } )
 

Thanks you so much.