Close Activated Dialog by oWnd:oTimer

Post Reply
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Close Activated Dialog by oWnd:oTimer

Post 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/viewt ... InputState

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,
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Close Activated Dialog by oWnd:oTimer

Post 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

#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 :?:
Last edited by ukoenig on Tue Feb 11, 2020 2:59 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Close Activated Dialog by oWnd:oTimer

Post 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
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Close Activated Dialog by oWnd:oTimer

Post by nageswaragunupudi »

Code: Select all

AEval( GetAllWin(), { |o| If( o == nil .or. o:hWnd == GetWndApp(), nil, o:End() ) } )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Close Activated Dialog by oWnd:oTimer

Post by dutch »

Dear Mr.Rao,

I will test and feedback to you.
nageswaragunupudi wrote:

Code: Select all

AEval( GetAllWin(), { |o| If( o == nil .or. o:hWnd == GetWndApp(), nil, o:End() ) } )
 
Thanks you so much.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
Post Reply