Mouse Up Event with Right-Click PopUp Menu
Posted on 2004-08-29
I want to be able to register a Right-Click Mouse Press by the user when they click within a ListBox. I want to code this in the Mouse Up event as other Windows programs do, however there seems to be a problem .... When i initiate the click (MouseDown) it is indeed within the ListBox, however when I move the mouse outside the ListBox, the MouseUp event gets called and so it brings up my Context-Sensitive Menu.
I also tried ranging within the MouseUp event like so
LIST BOX MOUSE UP EVENT:
Private Sub TableData_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbRightButton) Then
If (X >= TableData.Left And X <= TableData.Left + TableData.Width And Y >= TableData.Top) Then
Call PopupMenu(frmWorkspace.mnuTableEntity, vbPopupMenuRightAlign)
but this does NOT work as I planned. The X and Y parameter dont seem to work with the LEFT, TOP WIDTH and HEIGHT.
What is the proper way to code Right-Click PopUpMenu events for ListBox so the registered last click is exactly within the ListBox??