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
Code: Select all
#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