|
-
Mar 17th, 2005, 06:45 PM
#1
Thread Starter
Giants World Champs!!!!
Canceling Form Unload ***Resolved***
Would I use the following code to prevent a form from unloading when the user click the red 'X' in the upper right hand corner of the form:
VB Code:
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
Me.Hide
End Sub
Will this do the trick or should I use the Query_Unload Event?
Thanks
Last edited by Mark Gambo; Mar 17th, 2005 at 07:16 PM.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Mar 17th, 2005, 06:52 PM
#2
Fanatic Member
Re: Canceling Form Unload
Both will play the game...
QueryUnload is executed first
and Unload is executed after it ...
-
Mar 17th, 2005, 07:05 PM
#3
Re: Canceling Form Unload
Well in your case you should use the QueryUnload event since you only want to hide the form if someone clicks the X button. But if someone is shuting down Windows or you want to end the application through code you want to unload the form so your application ends properly. You can only test why your form is being unloaded in the QueryUnload event.
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
'the X has been clicked or the user has pressed Alt+F4
Cancel = True
Me.Hide
End If
End Sub
-
Mar 17th, 2005, 07:15 PM
#4
Thread Starter
Giants World Champs!!!!
Re: Canceling Form Unload
Joacim,
Thanks again!!!!
Mark
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|