Results 1 to 7 of 7

Thread: Waaah Why isn't VB doing what I want VB to do?!?!

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    try...

    Dim strMsg As VbMsgBoxResult
    strMsg = MsgBox("Really quit?", vbYesNo)
    If strMsg = vbNo Then
    Cancel = True
    Else
    Unload Me
    End If
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  2. #2
    Guest
    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

  3. #3
    Junior Member
    Join Date
    Apr 2000
    Posts
    27

    Question

    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?!

    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
    Help would be greatly appreciated. Thnx in advance.

  4. #4
    Junior Member
    Join Date
    Apr 2000
    Posts
    27

    Arrow naaaaaaaah!!

    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!
    Life's hard, but the front of a train is harder

  5. #5

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    MsgBox returns an Integer and not a string and that may be your problem, but this should work in any case:
    Code:
    If vbNo = MsgBox("Really quit?", vbYesNo) Then
        Cancel = True 
    Else 
        Unload Me 
    End If
    You also need to make sure that you have the code in a routine like the QueryUnload event that has a Cancel value.

  7. #7
    Junior Member
    Join Date
    Apr 2000
    Posts
    27

    Post Weeeeeirrrdd...

    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. . .
    Life's hard, but the front of a train is harder

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width