IsForeground() ??

IsForeground() ??

Postby MarcoBoschi » Thu Sep 20, 2012 7:18 am

Does exist a function which tells me if the application is foreground()?
In this little program instead of TIME() the value of this function
"Foreground" OR "Background"

Many thanks
Marco

Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION MAIN()
LOCAL oMain
DEFINE WINDOW oMain

ACTIVATE WINDOW oMain ON INIT dialogo()

RETURN NIL

FUNCTION DIALOGO()
LOCAL oDlg
LOCAL oSay
LOCAL oTimer

DEFINE DIALOG oDlg

@ 1 , 1 SAY oSay PROMPT "PROVA" OF oDlg

DEFINE TIMER oTimer OF oDlg INTERVAL 1000 ACTION oSay:settext( TIME() )

ACTIVATE DIALOG oDlg ON INIT ( oTimer:hWndOwner := oDlg:hWnd , oTimer:Activate()  )

RELEASE TIMER oTimer

RETURN NIL
 
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: IsForeground() ??

Postby MarcoBoschi » Thu Sep 20, 2012 7:31 am

solved!

Code: Select all  Expand view
#include "fivewin.ch"

STATIC hWnd

FUNCTION MAIN()
LOCAL oMain


DEFINE WINDOW oMain

ACTIVATE WINDOW oMain ON INIT dialogo()

RETURN NIL

FUNCTION DIALOGO()
LOCAL oDlg
LOCAL oSay
LOCAL oTimer


DEFINE DIALOG oDlg

@ 1 , 1 SAY oSay PROMPT "PROVA" OF oDlg

DEFINE TIMER oTimer OF oDlg INTERVAL 1000 ACTION oSay:settext( IIF( isforeground() , "Foreground" , "Back" ) )

ACTIVATE DIALOG oDlg ON INIT ( oTimer:hWndOwner := oDlg:hWnd , oTimer:Activate()  ) ;
                     ON PAINT hWnd := GETFOREGROUNDWINDOW()

RELEASE TIMER oTimer

RETURN NIL

FUNCTION ISFOREGROUND()
LOCAL lRitorna := .T.
IF GETFOREGROUNDWINDOW() <> hWnd
   lRitorna := .F.
ENDIF
RETURN lRitorna



DLL32 FUNCTION GETFOREGROUNDWINDOW() AS LONG PASCAL FROM "GetForegroundWindow" LIB "user32.dll"
 
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: IsForeground() ??

Postby Eoeo » Thu Sep 20, 2012 8:25 am

nice!
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 112 guests