Results 1 to 5 of 5

Thread: Do not close PopUp Menu on selection of certain items

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    13

    Do not close PopUp Menu on selection of certain items

    The title says it all. Is it possible to leave a PopUpMenu open after a selection or check of certain items?

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    2,167

    Re: Do not close PopUp Menu on selection of certain items

    Not a direct answer to your question, but you could fake it by caching the x,y coordinates of where the popup appears, and then use a timer with a tiny interval to re-display the popup menu at the same x,y coordinates. Very simple example:

    Code:
    Dim xC As Single
    Dim yC As Single
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
      If Button = 2 Then
        xC = x
        yC = y
        PopupMenu mnuPop, , x, y
      End If
    End Sub
    
    Private Sub mnuPopTest_Click()
      mnuPopTest.Checked = Not mnuPopTest
      tmrRepop.Enabled = True
    End Sub
    
    Private Sub tmrRepop_Timer()
      tmrRepop.Enabled = False
      PopupMenu mnuPop, , xC, yC
    End Sub
    Where tmrRepop has an Interval of 10ms. You have to create mnuPop and the sub-item mnuPopTest to test this simple example.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    23,809

    Re: Do not close PopUp Menu on selection of certain items

    If it doesn't need to overlap outside the parent window just use a UserControl. Otherwise use a child Form.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    13

    Re: Do not close PopUp Menu on selection of certain items

    Quote Originally Posted by OptionBase1 View Post
    Not a direct answer to your question, but you could fake it by caching the x,y coordinates of where the popup appears, and then use a timer with a tiny interval to re-display the popup menu at the same x,y coordinates. Very simple example:

    Code:
    Dim xC As Single
    Dim yC As Single
    
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
      If Button = 2 Then
        xC = x
        yC = y
        PopupMenu mnuPop, , x, y
      End If
    End Sub
    
    Private Sub mnuPopTest_Click()
      mnuPopTest.Checked = Not mnuPopTest
      tmrRepop.Enabled = True
    End Sub
    
    Private Sub tmrRepop_Timer()
      tmrRepop.Enabled = False
      PopupMenu mnuPop, , xC, yC
    End Sub
    Where tmrRepop has an Interval of 10ms. You have to create mnuPop and the sub-item mnuPopTest to test this simple example.
    Thanks OptionBase1 for reply, But this makes a flicker, especially when there are many menu items.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2017
    Posts
    13

    Re: Do not close PopUp Menu on selection of certain items

    Quote Originally Posted by dilettante View Post
    If it doesn't need to overlap outside the parent window just use a UserControl. Otherwise use a child Form.
    Thanks dilettante for your answer. What is your suggestion when I want to use the menu for the system tray icon? Can you explain with an example?

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