|
-
Dec 3rd, 1999, 03:43 AM
#1
Thread Starter
Junior Member
Hello,
I am in search for a correct coding procedure for a pop up menu for a list box.
The coding I am searching for will select an item from the listbox when your right click it. Also, when you right click the list for the menu to pop up, and then right click the list again, it will pop the menu up from the point you clicked at.
-
Dec 3rd, 1999, 03:48 AM
#2
Hyperactive Member
Make an invisible menu, call it lstMenu and use this code:
Code:
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then Me.PopupMenu lstMenu
End Sub
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
-
Dec 3rd, 1999, 03:52 AM
#3
Thread Starter
Junior Member
that did not help me any better than where I was, that is nothing more than a generic command to pop a menu up on a list box
what I am in search for is this. A pop up menu that will select the line you right clicked. second, when you right click once, then click once more with the menu already poped up...it will pop up
-
Dec 3rd, 1999, 04:07 AM
#4
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]
-
Dec 3rd, 1999, 04:24 AM
#5
Thread Starter
Junior Member
thank you mr young, but still the click feature for the popupmenu still will not corroperate...
-
Dec 3rd, 1999, 04:27 AM
#6
I don't understand what it is you are trynig to achieve then?
The code I posted will select a List Item if Right Clicked, if you then Right Click the item again, a Popup menu will appear. (Provided you have actually created the PopupMenu called mnuPopup
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|