Results 1 to 10 of 10

Thread: Form Termination Trapping

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    4

    Cool

    I'd like to make my program run until the user exits with my exit command, and not the termination button. Is there anyway to trap that?

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    There is one of two ways to do this:
    First:
    Code:
    'Everytime they click the 'x' it cancels itself
    Private Sub Form_Unload(Cancel As Integer)
        Cancel = 1
    End Sub
    Second:

    Set the ControlBox property of the form to False so that no 'x' is shown.

    Hope this helps

    Shaun

    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    No! Don't do that You won't be able to ever close your prog!!!

    Use
    Code:
    Public DontCancelMe As Boolean
    Private Sub Form_QueryUnload(cancel as integer)
    If DontCancelMe = False Then
    'Exit via the X button, don't close
    Cancel = 1
    End If
    'Else it's via your button, so close it!
    End Sub
    
    Private Sub ExitMe_Click
    DontCancelMe = True
    Unload Me
    End Sub
    This'll work!

    [Edited by Jop on 09-08-2000 at 01:48 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi Jop,
    He did say that he has his own Exit command so that they would still be able to exit his App

    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I think he meant his own way to exit (in a menu with extra confirmation).
    And in your case (Form_Unload) you're not able to unload the prog in any way (yeah end maybe, but not in a proper way)
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Not arguing with you

    What's wrong with End anyway?
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hey, one thing, no hard feelings man! I'm serious, I'm not trying to be 'better' than you, end just does what it says, it just ends the prog without Unloading it from the memory, so it's not a good idea to just quit it leaving the resources unavailable for other progs. That's what the Unload is for, making sure the used resources are made free.

    get it? (I ain't mad at ya )
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    4
    Are you two married? Just seemed there was a little arguing going on there. Thanks for the help though.

  9. #9
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    No arguing!
    Jop is right, I've always used End and didn't know any better.
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  10. #10
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    No we were not arguing!! () not in my humble opinion

    No... I was not mad, I was just trying to prove that I was right

    No but serious, no hard feelings right? (this is startin' to be a Chit-Chat topic, hey they should make a "Hey I hate you" and a "I'm sorry" forum )

    Hey, look at all the smileys, that means we are happy!

    [Edited by Jop on 09-08-2000 at 02:21 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width