Close Event

Discussion in 'Questions (Windows Mobile)' started by Zenerdiode, Oct 4, 2009.

  1. Zenerdiode

    Zenerdiode Active Member Licensed User

    In the Form1_Close Sub, I'd like to be able to know if the event was fired by the AppClose keyword, the user clicking the red 'X' button or whether Windows is shutting down and has sent it a WMClose message. I'd then be able to process the close request accordingly.
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed User

    You need to set a global variable eg ShutDown and initially set it to False.
    Just before you use AppClose set ShutDown to True.
    Also do this if the WM has been detected.
    In the Close event check whether ShutDown is true or false and action accordingly.

    Regards,
    RandomCoder.
     
  3. mjcoon

    mjcoon Well-Known Member Licensed User

    How would you distinguish WMClose?

    And in my experiments I didn't think I got Form1_Close if the user was clicking on an "X" to hide (rather than "OK" to close).

    Mike.
     
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    You can catch WM_Messages using DZT's library found here http://www.basic4ppc.com/forum/additional-libraries/748-dzeventsmagic.html (WM_Close = 16)

    If setting the Form to minimize then you need to provide another way of closing the Form eg menu option or button.

    regards,
    RandomCoder
     
  5. mjcoon

    mjcoon Well-Known Member Licensed User

    Sure, have done that, and don't need to capture an event for something initiated by the program itself. But it could be useful to know if the program has been hidden. I'll look at that events library, thanks.

    Mike.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice