Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PopUp Menu doesn't appear

Status
Not open for further replies.

mmfried

Programmer
Sep 17, 2003
33
IL
I activate a player of .wav sound files, from a PopUp menu. During the replay The PopUp menu doesn't appear (doesn't Pop Up),if the replay was activated from the PopUp menu. It does appear if its activated by other ways (i.e. regular menu), any Idea how to solve this?
 
'In Form1:

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

Select Case Button
Case vbRightButton
PopupMenu mnuPop, vbPopupMenuRightButton
End Select
End Sub

Private Sub mnuForm2direct_Click()
Form2.Show vbModal
End Sub


'And in Form2

Private mMenuForm2 As Boolean

Private Sub mnuForm2indirect_Click()
mMenuForm2 = True
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

Select Case Button
Case vbRightButton
mMenuForm2 = False
PopupMenu mnuPop, vbPopupMenuRightButton
If mMenuForm2 Then
Form2.Show vbModal
End If
End Select
End Sub

peterguhl@yahoo.de
 
You can't have a popup menu appear when there's another popup menu already active in the call stack. Hit Ctrl-L when debugging to see your call stack, and if there's a popup event already in there, you can't call another popup.

To get around this, you do as Poltergeist showed: you store what option the user chose while in the menu select event in a module-level variable. When control returns to the mouse-up event, you then call a function that performs what they selected based on that variable. I've used an enumeration in the past to store the user's selection.

This seems a little clunky, but is actually a good thing, as this function can be shared between a popup menu, regular menu, and a toolbar.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Thanks For the info.
I knew how to use vb PopUp menu as a hidden Menu Item before, and as you advised me, but that didn't solve the problem, I used "HMENU CreatePopupMenu(VOID)" in the end to create a Pop Up menu and "TrackPopupMenu" to display it that solved the problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top