|
-
Dec 12th, 2000, 10:26 AM
#1
Thread Starter
Addicted Member
Code:
Option Explicit
Private Declare Function sendMessageByString& Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String)
Private Sub Command1_Click()
Dim lngEntryNum As Long
Dim strTxtToFind As String
lngEntryNum = sendMessageByString(List1.hwnd, &H18C, 0, "abc")
End Sub
Private Sub Form_Load()
List1.AddItem "abc"
List1.AddItem "abcd"
List1.AddItem "abcd d"
List1.AddItem "abdd e"
List1.AddItem "abd"
List1.AddItem "abdec"
End Sub
when I use this code, he selects the second line, instead of the first. Why???
-
Dec 12th, 2000, 12:14 PM
#2
Frenzied Member
Ouch that hurts my eyes 
Code:
lngEntryNum = sendMessageByString(List1.hwnd, &H18C, 0, "abc")
neeevvvvvvver use that kindof hex values 
use constants instead.
like this:
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
I think it's selecting the first item because you did:
Code:
lngEntryNum = sendMessageByString(List1.hwnd, &H18C, 0, "abc")
and that should be:
Code:
lngEntryNum = sendMessageByString(List1.hwnd, LB_FINDSTRING, -1, "abc")
so with all code that would make:
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Private Sub Command1_Click()
Dim lngEntryNum As Long
Dim strTxtToFind As String
lngEntryNum = sendMessage(List1.hwnd, LB_FINDSTRING, -1, "abc")
End Sub
Private Sub Form_Load()
List1.AddItem "abc"
List1.AddItem "abcd"
List1.AddItem "abcd d"
List1.AddItem "abdd e"
List1.AddItem "abd"
List1.AddItem "abdec"
End Sub
Did that fixed the prob?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Dec 12th, 2000, 02:44 PM
#3
Fanatic Member
&H18C is the value for the message LB_SELECTSTRING
-
Dec 13th, 2000, 02:59 AM
#4
Thread Starter
Addicted Member
yes, it is working. Thanks a lot Jop & Mad Compie.
-
Dec 13th, 2000, 09:06 AM
#5
Frenzied Member
Originally posted by Mad Compie
&H18C is the value for the message LB_SELECTSTRING
OOPS wasn't paying attention 
sorry, but fine it's working
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
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
|