Results 1 to 11 of 11

Thread: [RESOLVED] Right Click Menus

  1. #1

    Thread Starter
    Lively Member yomamathecableguy's Avatar
    Join Date
    Jun 2008
    Posts
    67

    [RESOLVED] Right Click Menus

    hey all. this has probably been answered already, but i couldn't find it. how can i add a right click menu to an object in my form? i.e. if the user right clicks a go button, it gives a menu saying "open in new window" "open in this window" etc.
    Last edited by yomamathecableguy; Jul 30th, 2008 at 04:56 PM.

  2. #2
    Addicted Member Veritas2.0's Avatar
    Join Date
    May 2008
    Posts
    181

    Re: Right Click Menus

    Use the mouse_down and up event. Both of them allow you test which mousebutton has been pressed. So set either the mouse_down or mouse_up on the button to check if the right button was pressed and then pop up the menu.
    Simple little bugs 13 : Me 1

    Law of Bugs - That one bug you missed will be found almost immediately, by your customer.

    I wonder if anyone has ever asked for a User Surly interface?

  3. #3

    Thread Starter
    Lively Member yomamathecableguy's Avatar
    Join Date
    Jun 2008
    Posts
    67

    Re: Right Click Menus

    could you provide an example code? i'm also not sure how to pop up the menu. i want it to look like the normal right click menus.

  4. #4
    Hyperactive Member danecook21's Avatar
    Join Date
    Feb 2008
    Location
    NC, USA
    Posts
    501

    Re: Right Click Menus

    You would use the PopupMenu method. Yeah I know real hard right. Basically build your menu normally as you would build one in the menu editor, set it to Visible = False, then use Me.Popupmenu to pop it up (you will need to use the X and Y params to position it.

  5. #5
    Addicted Member Veritas2.0's Avatar
    Join Date
    May 2008
    Posts
    181

    Re: Right Click Menus

    This is taken directly from help and assumes you have a menu already set up on your form.

    Code:
    Private Sub Form_MouseUp (Button As Integer, Shift As _
       Integer, X As Single, Y As Single)
       If Button = 2 Then   ' Check if right mouse button 
                            ' was clicked.
          PopupMenu mnuFile   ' Display the File menu as a 
                            ' pop-up menu.
       End If
    End Sub
    Simple little bugs 13 : Me 1

    Law of Bugs - That one bug you missed will be found almost immediately, by your customer.

    I wonder if anyone has ever asked for a User Surly interface?

  6. #6

    Thread Starter
    Lively Member yomamathecableguy's Avatar
    Join Date
    Jun 2008
    Posts
    67

    Re: Right Click Menus

    ah i see. thank you so much! also, i know they're noob questions :P, but 1) how do i find the X and Y position of the mouse, and 2) how do i determine which mouse button was pressed?

  7. #7

    Thread Starter
    Lively Member yomamathecableguy's Avatar
    Join Date
    Jun 2008
    Posts
    67

    Re: Right Click Menus

    now i know how to see which mouse button was pressed ^_^

  8. #8
    Addicted Member Veritas2.0's Avatar
    Join Date
    May 2008
    Posts
    181

    Re: Right Click Menus

    There passed as integer values when the mouse_up event occurs.
    Simple little bugs 13 : Me 1

    Law of Bugs - That one bug you missed will be found almost immediately, by your customer.

    I wonder if anyone has ever asked for a User Surly interface?

  9. #9

    Thread Starter
    Lively Member yomamathecableguy's Avatar
    Join Date
    Jun 2008
    Posts
    67

    Re: Right Click Menus

    how would i access these?

  10. #10

    Thread Starter
    Lively Member yomamathecableguy's Avatar
    Join Date
    Jun 2008
    Posts
    67

    Re: Right Click Menus

    OHHHHH nevermind. thank you everyone!! i got it now. big kudos to veritas and danecook

  11. #11
    Addicted Member Veritas2.0's Avatar
    Join Date
    May 2008
    Posts
    181

    Re: Right Click Menus

    Their basic methods available to most controls. Easiest way would be to go to view code then select the control from the left drop down menu and then find "Mouse Up" from the right drop down menu.

    If you would be so kind as to mark this as resolved?
    Simple little bugs 13 : Me 1

    Law of Bugs - That one bug you missed will be found almost immediately, by your customer.

    I wonder if anyone has ever asked for a User Surly interface?

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