BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Laptop Screen Down! - Did you press CTRL+ALT+DEL?"
, by pro-x
Checks the state of YOUR laptop screen!
Also checks if the CTRL-ALT-DEL box (you know the one with "Log out") is visible!
Gimmie creds if you want. =P
Code
;"closing the screen" in the following code means that the screen energy saving is turned on, which often happens when you close the screen on a laptop. ; By comparing the total amount of free video memory with the start value, you can determine ; if the screen was "closed" or, if using 3D, CTRL + ALT + DEL was pressed. ; In BOTH cases, the graphics has to be reinitialized or you won't be able to display any graphics, ; or worse, and error will occur. ; When using 3D to detect CTRL + ALT + DEL, a Loop (While/Wend) must be used to "trap" the ; program until the dialog is no longer visible. This is because the error occurs when the dialog ; appears, and not when it disappears, as it does when you "close" the screen. (Or... Opens it.) ; ;------------------------------------------------------------------------------------------------------- ; ;3D is Needed For "[CTRL + ALT + DEL]-Detection" ;NOTE: [CTRL + ALT + DEL]-Detection works with "TotalVidMem()" too! ;The Example: Graphics3D 320,240,32,2 AppTitle "Sense" Mem=AvailVidMem() While Not KeyHit(1) If KeyHit(57) Then LID=False:CAD=False If AvailVidMem()<>Mem Then CAD=False LID=False While AvailVidMem()=0 CAD=True Wend LID=Not CAD Graphics3D 320,240,32,2 End If Cls Locate 1,1 If LID=True Then Print "Ahaa! You Put The Lid Down!" If CAD=True Then Print "Woah! You Pressed CTRL+ALT+DEL!" If LID=False And CAD=False Then Print "I Can Sense Your Movements! >=)" Delay 1 Wend End ;Try "closing the screen" when you are running your own blitz-app (only tested with Blitz3D) and you will notice that nothing will be ;visible on the screen and if you drag the window outside the screen, you will get some "sticky pixels" on the window. ;To be able to draw again, use the following function to detect changes and then run the "Graphics" command again and reload ALL ;Graphics! (maybe free the old ones up first?) ;;How To Use: ; ;Graphics3D 800,600,32,2 ;SetBuffer BackBuffer() ;StartMemory=DetectVideoFail() ;;MAIN LOOP ;While Not KeyHit(1) ; r=DetectVideoFail(StartMemory) ; If r>0 Then ; Graphics3D GraphicsWidth(),GraphicsHeight(),GraphicsDepth() ; SetBuffer GraphicsBuffer() ; LoadGraphics() ;Load your graphics in here... Don't forget cameras etc. ; End If ;Wend ;End Function DetectVideoFail(m=0) f=0 If m=0 Then Return AvailVidMem() Else If m<>AvailVidMem() Then f=1 While AvailVidMem()=0 f=2 Wend End If Return f End If End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations