
c ya,
nco2k
Code: Select all
Repeat
WinEvent.l = WindowEvent()
Select WinEvent
Case 0
Delay(1)
Case #PB_Event_ActivateWindow
SetPriorityClass_(GetCurrentProcess_(), #HIGH_PRIORITY_CLASS)
;Case #PB_Event_InactivateWindow
;SetPriorityClass_(GetCurrentProcess_(), #NORMAL_PRIORITY_CLASS)
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver : End
well thats all i need.This only checks if your APP'S WINDOWS are activated
call me economical or greedy, but i am trying to avoid (or at least reduce) using commands, which repeat themselves the whole time in a loop.So, what you need to do is
check (in your main loop) if GetForegroundWindow_() is or isn't the same
as WindowID()
Code: Select all
If OpenWindow(0, 0, 0, 480, 320, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "")
Repeat
WinEvent.l = WindowEvent()
Select WinEvent
Case 0
Delay(1)
Case #WM_ACTIVATE
Debug "Window has become Active or Inactive"
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
End
Code: Select all
;{ WaitWindow Loop
Repeat
ev=WaitWindowEvent()
If ev >=49355 And ev <=49359
EndTimer(2)
EndTimer(3)
EndTimer(1)
playing=#False
If GetActiveWindow_() = WindowID(0)
StartTimer(2,1000,@StartDemo())
EndIf
EndIf
If ev=#PB_Event_ActivateWindow
EndTimer(2)
EndTimer(3)
EndTimer(1)
Delay(50) ; Give the thread time to complete before attempting draw
StartDrawing(WindowOutput())
DrawImage(UseImage(#window),0,0)
DrawImage(UseImage(#playarea),67,77)
If soundson = #False
DrawImage(UseImage(#buttonsoundoff),462,471)
EndIf
StopDrawing()
If CountList(PieceGroup())
showpiece(1)
EndIf
UpdateScore()
ShowPreview()
StartTimer(2,1000,@startdemo())
EndIf
Code: Select all
mymsg = registerwindowmessage_("wm_activatething")
procedure windowproc(hwnd, message, wparam,lparam)
if message = #wm_activate
postmessage_(#hwnd_broadcast, mymsg, wparam, lparam)
endif
endprocedure