|
-
Mar 16th, 2007, 01:21 PM
#1
Thread Starter
Addicted Member
[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..
-
Mar 16th, 2007, 01:27 PM
#2
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
Delete it. They just clutter threads anyway.
-
Mar 16th, 2007, 01:38 PM
#3
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
"It's cold gin time again ..."
Check out my website here.
-
Mar 16th, 2007, 01:40 PM
#4
Thread Starter
Addicted Member
Re: A Problem with MDI Parent and Close ( X ) Button..
yeah i put the whole code in
unloadmode = 0 .. it works..
repped and resolved..
-
Mar 16th, 2007, 01:45 PM
#5
Thread Starter
Addicted Member
Re: [RESOLVED] A Problem with MDI Parent and Close ( X ) Button..
used.. BruceG idea.. works and looks much better
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
|