Results 1 to 4 of 4

Thread: External ListView

  1. #1

    Thread Starter
    Hyperactive Member MikeBAM's Avatar
    Join Date
    Sep 2000
    Location
    Metro Detroit
    Posts
    284

    External ListView

    How can I Count The Number Of Items In A ListView Out Side Of My Program? What's The API Call For It?
    Also How Can I Click A ListView Item Or Double Click A Item.
    ~* )v( ! /< E *~

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    You have to find the window handle of the listview first using findwindowEx - do a search on the forum for that code, theres loads of threads with it in.....

    and to find the number of items in a listview....

    Code:
    Option Explicit
    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
    Private Const LVM_FIRST = &H1000                     '// ListView messages
    Private Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
    Private Sub cmdGetListItems_Click()
    Dim lNumItems&
    lNumItems = SendMessage(lvw1.hwnd, LVM_GETITEMCOUNT, 0, 0&)
    MsgBox lNumItems & " Item(s) in listview"
    End Sub
    
    Private Sub Form_Load()
    Dim i%
    For i = 1 To 20
      lvw1.ListItems.Add , , "HELLO" & i
    Next i
    End Sub
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    to click an item you'll need to send a notification message in the form of a WM_NOTIFY, with an NM_CLICK or NM_DBLCLK message within the NMLISTVIEW Struct which is the lparam of the WM_NOTIFY message.....

    I don't have any listview examples of this to hand though sorry....
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4

    Thread Starter
    Hyperactive Member MikeBAM's Avatar
    Join Date
    Sep 2000
    Location
    Metro Detroit
    Posts
    284
    Well I figured out the count the # of items, thanks. Now on to the click event.
    Yeah i know how to find the window and all that.
    Not totally sure what you were saying but i'll have to look up those constants and mess around with it.
    ~* )v( ! /< E *~

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