Results 1 to 5 of 5

Thread: sendmessage: not on correct line???

  1. #1

    Thread Starter
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179

    Unhappy

    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???

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  3. #3
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    &H18C is the value for the message LB_SELECTSTRING

  4. #4

    Thread Starter
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    yes, it is working. Thanks a lot Jop & Mad Compie.

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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
  •  



Click Here to Expand Forum to Full Width