Results 1 to 4 of 4

Thread: Click-Menu

  1. #1

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hi,
    I want to know if it's possible (probably!) when a user clicks on a form (anywhere) to will display a menu, just like the menu's when you right-click, for example in this page).

    Anyone suggestions? There must be a way to do that!

    Thanks!

    Jop

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    Create A menu using Menu Editor and make it invisible (Visible = False). Then use this code:
    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        '//works only if user clicks the right button
        If Button = vbRightButton Then
            Me.PopupMenu mnuPopUp
        End If
    End Sub
    HTH

    [Edited by QWERTY on 03-31-2000 at 06:35 PM]

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Sure, use the PopupMenu function. Here is an example from MSDN.
    Code:
    PopupMenu Method Example
    This example displays a pop-up menu at the cursor location when the user clicks the right mouse button over a form. To try this example, create a form that includes a Menu control named mnuFile (mnuFile must have at least one submenu). Copy the code into the Declarations section of the form, and press F5.
    
    Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
       If Button = 2 Then
          PopupMenu mnuFile
       End If
    End Sub
    BTW, I don't know why but MS Help is often poorly written as in the example where the "magic number" 2 is used rather than the built-in constants for the mouse buttons which are:
    vbLeftButton 1 Left mouse button
    vbRightButton 2 Right mouse button
    vbMiddleButton 4 Middle mouse button

  4. #4

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986

    Thanks guys!

    Thanks guys, you've helped me alot!

    Jop

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