Results 1 to 9 of 9

Thread: How do I create an index like the one used by windows help system

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Talking

    Hi there guys, i need some help for a project i am working on. I need to create a feature that will enable the user to start typing a word and in a list box show matching results. The feature i would like it to be based around is the windows help system "The Index Search".....

    I have a screen dump of the layout if you would like it...

    send me some mail please.....

    Rohan

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Question

    Where are grabbing the information from ?
    Is it from a Database or is it static?
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    I am not sure, what do you think

    if you look at a windows help system you can see how that works. I am not sure but i can send you a picture

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Smile

    If you grab the words from a database, you can set an onchange event of the text box that the user is entering then each time it does, change the row source of the list box to lstbox.rowsource = "SELECT * FROM tbltest WHERE name LIKE '" & txtsearch & "*'"

    Hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Talking Awesome answer

    Thanks Ian, awesome idea.....

    Rohan

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Exclamation

    You can use a simple SendMessage API to achiev exactly what you want. Let's assume that you have a ListBox and a TextBox where you type in your search text:
    Code:
    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
    Private Const LB_FINDSTRING = &H18F
    
    
    Private Sub Text1_Change()
        List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal (Text1.Text))
    End Sub
    When you type into the Textbox, it will search the Listbox for the string you typed in. If it finds it, then it will select that list item.

  7. #7
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    I bow down to the great Guru Serge, I forgot about that API

    All credit

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  8. #8
    Lively Member
    Join Date
    Jan 2000
    Location
    usa
    Posts
    100

    Question

    Will this also work for a listview ?

  9. #9
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    For ListView you can use ListView's FindItem method:
    Code:
    Private Sub Command1_Click()
        Dim itmX As ListItem
        
        Set itmX = ListView1.FindItem("MyWord", , , lvwPartial)
        If Not itmX Is Nothing Then
            ListView1.SetFocus
            itmX.Selected = True
            itmX.EnsureVisible
        End If
    End Sub

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