Code: Select all
Global DeactivateApp
Enumeration #PB_Event_FirstCustomValue
#PB_Event_ActivateAppWindow
#PB_Event_DeactivateAppWindow
EndEnumeration
Procedure PB_Event_ActivateAppWindow()
If DeactivateApp = #True :DeactivateApp = #False
While WindowEvent() = #PB_Event_ActivateWindow :Wend
PostEvent(#PB_Event_ActivateAppWindow, EventWindow(), -1)
EndIf
EndProcedure
Procedure PB_Event_DeactivateAppWindow()
If GetActiveWindow() =-1 :DeactivateApp = #True
While WindowEvent() = #PB_Event_DeactivateWindow :Wend
PostEvent(#PB_Event_DeactivateAppWindow, EventWindow(), -1)
EndIf
EndProcedure
BindEvent(#PB_Event_ActivateWindow, @PB_Event_ActivateAppWindow())
BindEvent(#PB_Event_DeactivateWindow, @PB_Event_DeactivateAppWindow())
; -------------
OpenWindow(0,200,200,100,50,"test 1")
TextGadget(0,10,10,80,20,"")
OpenWindow(1,400,200,100,50,"test 2")
TextGadget(1,10,10,80,20,"")
Define Counter
Define ActivateAppWindow
Repeat
Event = WindowEvent()
Window = EventWindow()
Select Event
Case #PB_Event_ActivateAppWindow
Debug "#PB_Event_ActivateApp "
ActivateAppWindow = #True
Case #PB_Event_ActivateWindow
Debug "#PB_Event_Activate "
Case #PB_Event_DeactivateAppWindow
Debug "#PB_Event_DeactivateApp "
ActivateAppWindow = #False
Case #PB_Event_DeactivateWindow
Debug "#PB_Event_Deactivate "
Default
Delay(10)
If ActivateAppWindow = #True
Counter+1
SetGadgetText(0,Str(Counter))
EndIf
EndSelect
Until Event=#PB_Event_CloseWindow