Results 1 to 17 of 17

Thread: Select all in listview

Hybrid View

  1. #1
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Select all in listview

    VB Code:
    1. Const LVM_FIRST As Long = &H1000
    2. Const LVIF_STATE As Long = &H8
    3. Const LVIS_SELECTED As Long = &H2
    4. Const LVIS_FOCUSED As Long = &H1
    5. Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 8)
    6.  
    7.  
    8. Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    9.      ByVal hwnd As Long, _
    10.      ByVal wMsg As Long, _
    11.      ByVal wParam As Long, _
    12.      ByRef lParam As Any) As Long
    13.      
    14. Private Sub Command1_Click()
    15. With myLVitem
    16.       .mask = LVIF_STATE
    17.       .state = &HF
    18.       .stateMask = LVIS_SELECTED Or LVIS_FOCUSED
    19.       End With
    20.      
    21.         dmWriteProcessData lvItemPointer, VarPtr(myLVitem), Len(myLVitem)
    22.         apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 1, lvItemPointer)
    23. End Sub

    You didn't add the LVM_FIRST declaration that I posted above. The above should work and highlight the first item. For the 2nd item you should use (I'm guessing) :

    VB Code:
    1. apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 2, lvItemPointer)

    For the 3rd item :

    VB Code:
    1. apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 3, lvItemPointer)

    And so on...


    Has someone helped you? Then you can Rate their helpful post.

  2. #2
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Select all in listview

    Now this errorshowin in pic attached:




    pointing at :


    Code:
    Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
         ByVal hwnd As Long, _
         ByVal wMsg As Long, _
         ByVal wParam As Long, _
         ByRef lParam As Any) As Long
    HAve u tried this code ? did it work for u?
    I think this code will not work for external listview since at no point code is looking for a window that holds the listvidew!!

    AS u see i provied the classname and listview info beleow so i be happy if u have a look at it.Thanks




    This is the informaton i got from my external listview using api spy:


    Window Handle == 0x00310520.
    Class Name : SysListView32.
    RECT.left == 799.
    RECT.top == 195.
    RECT.right == 995.
    RECT.bottom == 462.


    and


    VB Code:
    1. '************************************************************************************
    2. '*****                        FindWindow Source [Code]                          *****
    3. '*****        By Sean Gallardy    E-Mail [email protected]                  *****
    4. '************************************************************************************
    5.  
    6.  
    7. 'API Calls
    8. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    9. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    10.  
    11.  
    12. Function GetMyWindow() as long
    13.  
    14.  
    15. 'Variables
    16. Dim lParent as long
    17. Dim lChild(1 to 5) as long
    18.  
    19.  
    20. 'Get Parent Window
    21. lParent = FindWindow("My Window Class", "window caption")
    22. 'Get Child Window(s)
    23. lChild(1) = FindWindowEx(lParent, 0, "WTL_SplitterWindow", "")
    24. lChild(2) = FindWindowEx(lChild(1), 0, "WTL_SplitterWindow", "")
    25. lChild(3) = FindWindowEx(lChild(2), 0, "WTL_SplitterWindow", "")
    26. lChild(4) = FindWindowEx(lChild(3), 0, "ATL:0053D8D0", "")
    27. lChild(5) = FindWindowEx(lChild(4), 0, "SysListView32", "")
    28.  
    29.  
    30. GetMyWindow = lChild(5)
    31.  
    32.  
    33. End Function
    Attached Images Attached Images  

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