Dim strMsg As VbMsgBoxResult
strMsg = MsgBox("Really quit?", vbYesNo)
If strMsg = vbNo Then
Cancel = True
Else
Unload Me
End If
Printable View
Dim strMsg As VbMsgBoxResult
strMsg = MsgBox("Really quit?", vbYesNo)
If strMsg = vbNo Then
Cancel = True
Else
Unload Me
End If
I'm not sure what code you are using. But does the program know you are clicking the right mouse button?
Code:Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLICK = &H203
Public Const WM_RBUTTONUP = &H205
Public Const WM_MOUSEMOVE = &H200
Private Sub Form_MouseMove(button As Integer, Shift As Integer, X As Single, Y As Single)
Static lngMsg As Long
Static blnFlag As Boolean
Dim result As Long
lngMsg = X / Screen.TwipsPerPixelX
If blnFlag = False Then
blnFlag = True
Select Case lngMsg
'right-click
Case WM_RBUTTONUP
result = SetForegroundWindow(Me.hwnd)
If vbNo = MsgBox("Do you really want to shutdown the program?" & vbCrLf & "Click Yes to quit.", vbYesNo + vbExclamation + vbDefaultButton2 + vbMsgBoxSetForeground) Then
Cancel = True
Exit Sub
Else
Cancel = False
Call DeleteSystrayIcon(picSystray)
Unload Me
End
End If
Case WM_LBUTTONUP
result = SetForegroundWindow(Me.hwnd)
PopupMenu Me.mnumenu
End Select
blnFlag = False
End If
End Sub
Well I have an form.. with systray icon..
and when the user clicks on the close command on the menu
of the systray icon, I want the user to get a message box,
to confirm if he wants to quit the program... I have the
following code for that.. the only thing is.. that vb DO
recognize what the user clicks... only doesn't respond to
it.. IT ENDS ANYWAYZ?!
Help would be greatly appreciated. Thnx in advance.Code:If vbNo = MsgBox("Do you really want to shutdown the program?" & vbCrLf & "Click Yes to quit.", vbYesNo + vbExclamation + vbDefaultButton2 + vbMsgBoxSetForeground) Then
Cancel = True
Exit Sub
Else
Cancel = False
Call DeleteSystrayIcon(picSystray)
Unload Me
End
End If
you're not getting the point, both of you! :)
VB DOES intercept correct if the user clicks on no or
yes... when the user clicks on yes... cancel is set to
false.. and the program quits.. but the problem is...
when the user clicks on no, and cancel is set to true..
VB STILL ENDS THE PROGRAM!!!
It just won't listen to me! ;)
someones not getting it..
If you paste the code I gave you into a command button and you press yes you exit <<<>>> if you press no you remain in the app.
it works...tried, tested, and true...
Private Sub Command1_Click()
Dim strMsg As VbMsgBoxResult
strMsg = MsgBox("Really quit?", vbYesNo)
If strMsg = vbNo Then
Cancel = True
Else
Unload Me
End If
End Sub
MsgBox returns an Integer and not a string and that may be your problem, but this should work in any case:
You also need to make sure that you have the code in a routine like the QueryUnload event that has a Cancel value.Code:If vbNo = MsgBox("Really quit?", vbYesNo) Then
Cancel = True
Else
Unload Me
End If
Hmmz your messages let me tried my own routine i have in another program..
and it works... really weird.. so it's something in my own program that still unloads the program..
mabey it has to do with all the subclassing ;)
haha so this post is here for nothing ;P oh well
Thnx newayz because of you all i've realized the error is
somewhere in my program.. so it's not that routine.. Thnx. . . :)