[Gambas-user] Closing signals

timothy timothy.marshal-nichols at ...247...
Thu Feb 8 10:14:12 CET 2007


> -----Original Message-----
> From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
> bounces at lists.sourceforge.net] On Behalf Of Leonardo Miliani
> Sent: Wednesday, 07 February 2007 10:45 PM
> To: mailing list for gambas users
> Subject: [Gambas-user] Closing signals
> 
> Hello everybody.
> I would like to know if there's a way to intercept what is trying to
> close a Gambas application.
> I remember that in VB there was a way to read the closing signal to
know
> if the application had been closed from the user by clicking on the
"X"
> icon or if the system was shutting down and was sending all the
> applications the terminating signal.
> 
> I would like to write a check in my applications to close them in a
safe
> way if they intercept a terminating signal from the system, i.e.
during
> shutdowns or reboots, to avoyd data loosing.
> Thanks.
> 
> --
> Ciao.
> Leo.
> 


Hi,

Not sure if this is what you are getting at. But STOP EVENT will stop a
form closing if it is used in a Form's Close event. So if all you need
is to handle the user clicking the X on a window then this will do the
job.

Suppose we have a variable to tell us if changes to our have not been
saved:

PRIVATE dataChanged AS Boolean

We then set this if the user changes something. And also clear it if the
user saves. Then we can put this in our Form close event.

PRIVATE dataChanged AS Boolean

PUBLIC SUB Form_Close()
  DIM result AS Integer
  dataChanged = TRUE
  IF dataChanged THEN 
    result = Message.Question("Are you sure?", "Quit without saving",
         "Save then quit", "Cancel")
    IF result = 2 THEN
      ' If save is selected then save before quitting
      PRINT "Do save here"
    ELSE IF result = 3 THEN 
      ' If cancel is pressed then cancel close form event
      STOP EVENT 
    END IF
  END IF  
END


Thanks

8-{)} Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>







More information about the User mailing list