|
-
Feb 21st, 2007, 09:21 AM
#1
Thread Starter
Hyperactive Member
ListBox I need the help
Hi All
I have something like this
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, lParam As Any) As Long
Const LB_ITEMFROMPOINT = &H1A9
Private Sub Form_Load()
List1.AddItem "Marina"
List1.AddItem "Phill"
List1.AddItem "Karla"
List1.AddItem "Mark"
List1.AddItem "Antonio"
List1.AddItem "Theo"
List1.ListIndex = 0
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Dim P&, LX&, LY&, Param&
LX = List1.Parent.ScaleX(X, List1.Parent.ScaleMode, vbPixels)
LY = List1.Parent.ScaleY(Y, List1.Parent.ScaleMode, vbPixels)
Param = CLng(LX) + &H10000 * CLng(LY)
P = SendMessage(List1.hwnd, LB_ITEMFROMPOINT, 0, ByVal Param)
If P < List1.ListCount Then List1.ListIndex = P
End Sub
how to switch off procedure (Private Sub List1_MouseMove) after clicking on a chosen an item. I not want after chosen and clicking on a some item to highlight it already other of item in this list.
Thanks in advance
I know, I know, my English is bad, sorry .....
-
Feb 21st, 2007, 09:37 AM
#2
Re: ListBox I need the help
Try something like
VB Code:
Option Explicit
Private blnHasSelected As Boolean
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, lParam As Any) As Long
Const LB_ITEMFROMPOINT = &H1A9
Private Sub Form_Load()
List1.AddItem "Marina"
List1.AddItem "Phill"
List1.AddItem "Karla"
List1.AddItem "Mark"
List1.AddItem "Antonio"
List1.AddItem "Theo"
List1.ListIndex = 0
End Sub
Private Sub List1_Click()
blnHasSelected = True
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
Dim P&, LX&, LY&, Param&
If blnHasSelected = True The Exit Sub
LX = List1.Parent.ScaleX(X, List1.Parent.ScaleMode, vbPixels)
LY = List1.Parent.ScaleY(Y, List1.Parent.ScaleMode, vbPixels)
Param = CLng(LX) + &H10000 * CLng(LY)
P = SendMessage(List1.hwnd, LB_ITEMFROMPOINT, 0, ByVal Param)
If P < List1.ListCount Then List1.ListIndex = P
End Sub
-
Feb 21st, 2007, 02:35 PM
#3
Thread Starter
Hyperactive Member
Re: ListBox I need the help
Hi Hack.
Thanks for quick reply
I made a bit in other way, because in this code that you gave me this does not want to work like I want.
I make it (blnHasSelected = True) in event Mouse_Up because this Click event it happens already in Load event. However I made again the work for this procedure in event Mouse_Move for Form. I seem me that I made it okay. It fine work for me.
have a look, only in this a bit the code:
VB Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
blnHasSelected = False
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
If blnHasSelected = False Then '<<< it I changed here on a False
Dim P&, LX&, LY&, Param&
LX = List1.Parent.ScaleX(X, List1.Parent.ScaleMode, vbPixels)
LY = List1.Parent.ScaleY(Y, List1.Parent.ScaleMode, vbPixels)
Param = CLng(LX) + &H10000 * CLng(LY)
P = SendMessage(List1.hwnd, LB_ITEMFROMPOINT, 0, ByVal Param)
If P < List1.ListCount Then List1.ListIndex = P
End If
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
blnHasSelected = True
End Sub
Again very thanks, Hack
I know, I know, my English is bad, sorry .....
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
|