Results 1 to 17 of 17

Thread: Select all in listview

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    205

    Select all in listview

    I have searched the whole forum and found nothing on this, all I could find was how to select an item in an external listview using wm_keydown.

    I need to select all the items in an external listview.

    Anybody know how to do this?


    Thanks in advance.

  2. #2
    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



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

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

    Talking Re: Select all in listview

    Quote Originally Posted by manavo11
    Man i do not see any working example to select external listview item in that

    thread. Could u show me an working example to select item from external listview?Thanks

  4. #4
    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

    What's wrong with the code in the first post? Do you need help? Did you declare everything?


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

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

    Re: Select all in listview

    Quote Originally Posted by manavo11
    What's wrong with the code in the first post? Do you need help? Did you declare everything?
    thank u for u reply. Well i realy need help declaring needed things. i be happy if u tell me what controles and things i need to make that code run. This is the informaton i got from my external listview:


    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


    Thanks
    Attached Images Attached Images  
    Last edited by tony007; Jun 21st, 2006 at 07:03 AM.

  6. #6
    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 LVIF_STATE As Long = &H8
    2. Const LVIS_SELECTED As Long = &H2
    3. Const LVIS_FOCUSED As Long = &H1
    4. Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43)
    5.  
    6. Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    7.      ByVal hwnd As Long, _
    8.      ByVal wMsg As Long, _
    9.      ByVal wParam As Long, _
    10.      ByRef lParam As Any) As Long


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

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

    Re: Select all in listview

    Quote Originally Posted by manavo11
    VB Code:
    1. Const LVIF_STATE As Long = &H8
    2. Const LVIS_SELECTED As Long = &H2
    3. Const LVIS_FOCUSED As Long = &H1
    4. Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43)
    5.  
    6. Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    7.      ByVal hwnd As Long, _
    8.      ByVal wMsg As Long, _
    9.      ByVal wParam As Long, _
    10.      ByRef lParam As Any) As Long

    Thank u for u reply . could u tell me how to make the on command event. Where to put them ?I only want select and highlight for example the 2 listview item .The current listview does not allow select all. i tried this and got this error :


    compile error:

    Constant expression required


    and pointing at LVM_FIRST


    complete code:
    VB Code:
    1. Const LVIF_STATE As Long = &H8
    2. Const LVIS_SELECTED As Long = &H2
    3. Const LVIS_FOCUSED As Long = &H1
    4. Const LVM_SETITEMSTATE As Long = ([B]LVM_FIRST [/B] + 43)
    5.  
    6. Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    7.      ByVal hwnd As Long, _
    8.      ByVal wMsg As Long, _
    9.      ByVal wParam As Long, _
    10.      ByRef lParam As Any) As Long
    11.  
    12.  
    13. Private Sub Command1_Click()
    14. With myLVitem
    15.       .mask = LVIF_STATE
    16.       .state = &HF
    17.       .stateMask = LVIS_SELECTED Or LVIS_FOCUSED
    18.       End With
    19.      
    20.         dmWriteProcessData lvItemPointer, VarPtr(myLVitem), Len(myLVitem)
    21.         apiResult = SendMessage(lvWindow, LVM_SETITEMSTATE, 1, lvItemPointer)
    22. End Sub
    Last edited by tony007; Jun 20th, 2006 at 12:00 PM.

  8. #8
    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

    You will have to find the number of items in the listview and then select them one by one. If I'm not mistaken you have to change the 3rd parameter of the SendMessage call.


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

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

    Re: Select all in listview

    Quote Originally Posted by manavo11
    VB Code:
    1. Const LVM_FIRST As Long = &H1000

    You will have to find the number of items in the listview and then select them one by one. If I'm not mistaken you have to change the 3rd parameter of the SendMessage call.
    Many thanks for u reply. adding that line did not solve the error. error Pointing at same spot!

    How to get the number of items in external listview ? I just want to highlight say for example item number 4. could u tell me what should i put in 3rd parameter.Thanks

  10. #10
    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

    Add the extra line above the line that is causing the error.

    If you want to highlight the 4th item, you should put in the 3rd parameter the number 4. I think...


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

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

    Re: Select all in listview

    Quote Originally Posted by manavo11
    Add the extra line above the line that is causing the error.

    If you want to highlight the 4th item, you should put in the 3rd parameter the number 4. I think...
    could u tell me what u mean an extra line ? the program does not run at all so i do not get any thing highlited in external window!!

    It keep giving me compile error and pointing at this :


    Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43)

    May i know what is that number 43 for ? I have feeling that the code is not complet

    Do i need to know number of items in that external listview ? How?
    Last edited by tony007; Jun 20th, 2006 at 08:47 PM.

  12. #12
    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

    Can you post your code?


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

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

    Re: Select all in listview

    Quote Originally Posted by manavo11
    Can you post your code?
    Here is the complete latest code. I just followed what u suggested in previouse posts:



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

  14. #14
    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.

  15. #15
    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  

  16. #16
    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

    Declare it as Private :

    VB Code:
    1. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    2.      ByVal hwnd As Long, _
    3.      ByVal wMsg As Long, _
    4.      ByVal wParam As Long, _
    5.      ByRef lParam As Any) As Long


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

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

    Re: Select all in listview

    Quote Originally Posted by manavo11
    Declare it as Private :

    VB Code:
    1. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    2.      ByVal hwnd As Long, _
    3.      ByVal wMsg As Long, _
    4.      ByVal wParam As Long, _
    5.      ByRef lParam As Any) As Long

    I made that change and that error is out but another came when clicking the button:

    Code:
    Compile error: 
    
    Sub or functon not defined
    and point at :

    dmWriteProcessData

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