Results 1 to 7 of 7

Thread: PopUpMenu won't go away

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    FeedMeTown, Ohio
    Posts
    176

    Question

    I'm using the mouse-down event of a form for a few different purposes. My code is written so that if the user selects the right mouse button, a PopUpMenu appears. The problem is, it won't go away until several clicks of the left mouse button. . Any help out there. Thanks in advance. P.S. This is an MDI application.

  2. #2
    Guest
    Take a look at this thread which answers your queston. Not sure if it will work the same for an MDI form though.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'code is compliments of ameba at ExpertsExchange
    
    'make a popup menu just like the one's in windows
    'appear at the right click of your mouse as long
    'as your right click is on the form
    
    Option Explicit 
    
    Private Sub Form_Load() 
       mnuPop.Visible = False 
    End Sub 
    '
    
    'allow users the ability of win keyboard menu key
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
        If KeyCode = 93 Then 
            'fire up the popup menu 
            PopupMenu mnuPop, 2, 60, 60 
        End If 
    End Sub 
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 
        If Button = vbRightButton Then 
            'fire up the popup menu 
            PopupMenu mnuPop, 2, X, Y 
        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

  4. #4
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    Use this:


    Code:
    'Declaration
    Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
    
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
               set this form as current window, otherwise popup
               'menu will stay on the screen even after you click
               'outside it
    
               Call SetForegroundWindow(Me.hwnd)
    
               PopupMenu frmMain.mnuconfigure
    
    End Sub
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  5. #5
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Who ressurected this old thread?

  6. #6
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    I took me a long time to find out how to acomplish it so I thought I'd post it anyway, incase anyone searches for a way to remove the menu.

    Plus, I didnt even look at the date
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I've had similar problems, and I solved it with this (even though it sounds somewhat unconventional)

    Make the last menu item of your popup menu and item called
    Cancel Menu

    Put nothing in its click event.

    Bring the menu up, and click on Cancel Menu.

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