GetScreenClose
State = GetScreenClose()
 
Parameters: NONE
Returns:

    State = The Close gadget State (0= not pressed, 1 = pressed)
 

      The GetScreenClose function checks if the close gadget (the (X) icon) on your window has been pressed. The function will return a TRUE (1) when the user clicks the close gadget.




FACTS:


      * Normally when the close gadget is clicked, the PlayBASIC run time will automatically exit by default. This is to ensure the user can easily break out of their programs, while working on them. So in order to read the close gadget, we have to disable this feature using the BreakKey command.

      * Reading the close gadget requires windows event monitoring, PlayBASIC preforms this monitoring during each 'SYNC'. So if you're program doesn't sync, it can be very hard to break out.





Mini Tutorial:


      This example

  
;Tell PB to limit the speed of this program
  SetFPS 60
  
; Disable ESC & Close inbuilt gadget events
  BreakKey off
  
; ============================================================
; >> Be careful though, make sure you can exit your program.
; As ESC or CLose gadget will no longer break the program
; ============================================================
  
; start a repeat/until loop
  Repeat
     
   ; Clear the screen
     Cls RGB(0,0,0)
     
   ; Display a messages
     Print "Click the Close Gadget"
     Print "Press Space to End"
     
     
   ; Checks for any recent close gadget events
     If GetScreenClose()=true
      ; The Person hit the Close gadget
        Print "Hey - Don't press that"
      ; Show the screen and wait 1/2 a second
        Sync
        Wait 500
     EndIf
     
   ; Display Screen and monitors window events
     Sync
     
   ; If neither the Esckey() or Spacekey() are pressed
   ; then jump back to the repeat
  Until EscKey() Or SpaceKey()
  
  
  



This example would output.

  
  no Text Output
  

 
Related Info: BreakKey | GetBreakKey :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com