Results 1 to 11 of 11

Thread: Popup menu problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    I have a popup menu in my app. It works, but not the way like other popup menus in Explorer or other windows apps.

    Basically when the popup menu is open I can't right-click somewhere else on the form and re-display that menu at mouse point. I have to either left-click one of the menu options or left-click somewhere else to make the menu dissapear and then when the menu is off I can right-click again to make it re-apear.

    Example:
    Let's say, you're on windows desktop. No matter how many times you right-click, a NEW menu pops up at current mouse position. You don't have to close it, you just right-click again somewhere else and the current menu closes and the new one appears. I want the same thing in my app.

    Thanks for your help.
    Thanks

    Tomexx.

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    you can set a right mouse button setting to click. I'm confushing myself, but this will let the right mouse button do what you want! this is a flag in the popupmenu function
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Anyone else?
    Thanks

    Tomexx.

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    I think this is always so in a VB program. Maybe if you create the menus with the API the problem is solved. I'm sure V(ery) Basic will give you his menu example that uses the API if you ask him.

  5. #5
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Unfortunately, my app doesn't do that yet. But, as always, I will respond to consumer demands and subclass mouse events.

    Rest assured I will die trying. Well, metaphorically. Maybe not even that.
    Courgettes.

  6. #6
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    no, vb is set for leftbuttondefault. I've giving this tip to someone else, it works for him. in the PopupMenu Function, set the flags to vbRightButtonDefault (or something like that, use MSDN)
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  7. #7
    Guest
    It's actually vbPopupMenuRightButton gwdash, but the idea of what you were talking about works. Here's an example:

    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then PopupMenu mnupopup, vbPopupMenuRightButton
    End Sub

  8. #8
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Does anybody know how VB does that? Because Windows doesn't send any mouse messages while a menu is up, so how can it tell when a button has been clicked?

    If somebody has any ideas, please say, because I'd like to add this functionality to my project.

    Thank you,

    El Maestro
    Courgettes.

  9. #9
    Guest
    V(ery) Basic, you could do something like this:

    Code:
    Dim clicked As Integer
    
    Private Sub Form_Load()
    clicked = 0
    End Sub
    
    Private Sub Command1_Click()
    clicked = 1
    End Sub
    
    Private Sub Command2_Click()
    If clicked = 1 Then MsgBox "Command1 has been clicked!", vbCritical
    End Sub

  10. #10
    _______ 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

  11. #11
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    So that means that if I show the menu when the mouse button is released, then it'll receive mouse messages.

    For a change that makes sense!

    Thanks, but why did he say 'Joe'?

    Gee. It's getting a little late now so I'd better go. Thanks,
    Courgettes.

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