Try this:
Code:Private Type POINTAPI x As Long y As Long End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long Private Const LB_ITEMFROMPOINT = &H1A9 Private Sub Form_Load() Dim iIndex As Integer For iIndex = 0 To 99 List1.AddItem "Item" & iIndex Next End Sub Private Sub List1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim tPOINT As POINTAPI Dim iIndex As Long If Button = vbRightButton Then Call GetCursorPos(tPOINT) Call ScreenToClient(List1.hWnd, tPOINT) iIndex = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0&, ByVal ((tPOINT.x And &HFF) Or (&H10000 * (tPOINT.y And &HFF)))) If iIndex > -1 Then iIndex = iIndex And &HFF If List1.Selected(iIndex) And Shift <> -1 Then PopupMenu mnuPopup Else List1.Selected(iIndex) = True End If End If End If End Sub Private Sub List1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Call List1_MouseDown(Button, -1, x, y) End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]




Reply With Quote