[RESOLVED] A Problem with MDI Parent and Close ( X ) Button..
I have a MDI Parent form...
Now .. for the close button ( X ) on top right i have the code
vb Code:
Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim vbResponse As VbMsgBoxResult
vbResponse = MsgBox("Are You Sure You want to exit the Program?", vbYesNo, " Exit Application")
Select Case vbResponse
Case vbYes
Unload Me
Case vbNo
Cancel = -1
End Select
End Sub
as suggested by some1..
and I have a EXIT coded in the menu.. the code is
vb Code:
Private Sub mnuexit_Click()
msg = MsgBox("Are You Sure You want to exit the Program?", vbYesNo, " Exit Application")
If msg = vbYes Then
Unload Me
Else
Exit Sub
End If
End Sub
Now the problem is.. that when i click on the close button.. its works fine..
But when I click on the the EXIT MENU.. then it 1st runs its msgbox.. then runs the CLOSE BUTTON code??? I dont know why.. so the msgbox pop ups twice on the EXIT MENU
Please help here.. I dont want the box to come twice asking again to exit or not..
Re: A Problem with MDI Parent and Close ( X ) Button..
Never done this, but I think you should make a code for the queryunload sub like
if unloadmode = something then
show messagebox etc.
end if
for 'something' you might want to range from 0 to 2
Re: A Problem with MDI Parent and Close ( X ) Button..
The only code you need in the "mnuexit_Click" event is:
Unload Me
This is because that statement will automatically fire the "MDIForm_QueryUnload" event.
Furthermore, you do not need the "Unload Me" statement in the "MDIForm_QueryUnload" event. You can get rid of the whole Select Case statement, and code this If statement:
If vbResponse = vbNo Then
Cancel = 1
End If
Re: A Problem with MDI Parent and Close ( X ) Button..
yeah i put the whole code in
unloadmode = 0 .. it works..
repped and resolved..
Re: [RESOLVED] A Problem with MDI Parent and Close ( X ) Button..
used.. BruceG idea.. works and looks much better :)