OpenScreen() Alt-Tab/Windows Key Demo
Posted: Wed Sep 15, 2010 12:08 am
Nothing fancy and works with the debugger on! Also closes from the taskbar.
Code: Select all
;******************************************************************************************************
;* ALT-TAB IsScreenActive() demo
;* By djes (djes@free.fr) 03/24/2009
;* Modified by AndyMK 14/09/2010
;* PB 4.51
;******************************************************************************************************
#STARS_NB = 100
Structure pos
x.l
y.l
speed.l
EndStructure
Dim stars.pos(#STARS_NB)
Desktop = ExamineDesktops()
Global Width = DesktopWidth(0)
Global Height = DesktopHeight(0)
Procedure create_sprites()
CreateSprite(0, 64, 64)
StartDrawing(SpriteOutput(0))
Circle(32, 32, 31, RGB($FF, $FF, $FF))
StopDrawing()
EndProcedure
Procedure init_display()
OpenScreen(Width, Height, 32, "", #PB_Screen_SmartSynchronization)
ClearScreen(0)
EndProcedure
Procedure check_lostfocus()
If IsScreenActive() = 0
FreeSprite(0)
OpenWindow (0,1,1,1,1, "Alt-Tab Demo" , #PB_Window_Minimize|#PB_Window_BorderLess )
CloseScreen()
Repeat
Event=WaitWindowEvent ()
If Event = #WM_CLOSE
ExitProg = 1
Break
EndIf
Until Event = #WM_PAINT
If ExitProg = 0
CloseWindow (0)
init_display()
create_sprites()
Else
End
EndIf
EndIf
EndProcedure
InitSprite()
init_display()
create_sprites()
For i=0 To #STARS_NB-1
stars(i)\x = Random(Width-1)
stars(i)\y = Random(767)
stars(i)\speed = Random(16) + 1
Next i
Repeat
FlipBuffers()
ClearScreen(0)
check_lostfocus()
For i = 0 To #STARS_NB-1
stars(i)\x + stars(i)\speed
If stars(i)\x > Width-1
stars(i)\x - Width - 64
EndIf
Next i
For i = 0 To #STARS_NB-1
DisplayTranslucentSprite(0, stars(i)\x, stars(i)\y, stars(i)\speed<<4)
Next i
Until GetAsyncKeyState_(#VK_ESCAPE)
CloseScreen()
End