• Welcome to Valhalla Legends Archive.
 

Form_Unload Cancel Prop

Started by CrAz3D, August 31, 2003, 01:21 PM

Previous topic - Next topic

CrAz3D

vb6
I am trying to get the form to not close when I click the 'close' button.  I have accomplished this by using Cancel=1

The only problem I am having is that the form I don't want to close is a MDIChild, & it will not close when I try to close the main MDI form.  Any ideas?

rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Skywing

Maybe you could set a flag in Form_Unload or whatever for your main window, and check that flag in Form_Unload for your MDIClient to determine whether or not it should allow itself to be closed?

CrAz3D

#2
okey dokey, thank ya, I'lls ee what that does.
---
Well, I tried this:
If UnloadCancel = False Then
   Cancel = 1
End If
It didn't seem to work.  Any other ideas?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Grok

Use Query_Unload instead.  It provides the mechanism you need to decide the reason why the form is closing.  If the reason is the system menu (user clicked) then set Cancel = True.  For all other reasons, set Cancel = False.

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   Select Case UnloadMode
   Case vbFormControlMenu  '0 The user chose the Close command from the Control menu on the form.
       Cancel = True
   Case vbFormCode         '1 The Unload statement is invoked from code.
   Case vbAppWindows       '2 The current Microsoft Windows operating environment session is ending.
   Case vbAppTaskManager   '3 The Microsoft Windows Task Manager is closing the application.
   Case vbFormMDIForm      '4 An MDI child form is closing because the MDI form is closing.
   Case vbFormOwner        '5 A form is closing because its owner is closing
   End Select
End Sub

CrAz3D

#4
Thank ya kindly

EXTREMELY KINDLY!  ;D
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...