Results 1 to 6 of 6

Thread: Problem getting hwnd of external listview

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Problem getting hwnd of external listview

    Hi all. There is an external application that has a listview in one of its window. My intention is to highlight and send double click to one of its row .

    So i tried to get the listview's hWnd value first but I don't know what class name it has. Most of other listviews got systemlistview32 name but not this one.I used PAT Jk's API spy 5.1 to get the code that help me find hWnd of the listview but unfortunetly when i used the PAT JK'S API Spy's code with the following code i got empty value for hwnd!

    So I be happy if you guys tell me how we can deal with such a listview and find it hwnd valu? Looking forward for replies.Thanks

    2 Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim hWnd As Long
    4. hWnd = getHwnd
    5.  
    6. End sub
    7.  
    8.  
    9. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    10. 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
    11.  
    12. Function getHwnd() As Long
    13. 'this part i used PAT or Jk's API spy 5.1
    14.  
    15. Dim atlc As Long, atlcf As Long, atla As Long
    16.  
    17. atlc = FindWindow("atl:008047c0", vbNullString)
    18. atlcf = FindWindowEx(atlc, 0&, "atl:00819cf0", vbNullString)
    19. atla = FindWindowEx(atlcf, 0&, "atl:00819a30", vbNullString)
    20.  
    21. getHwnd=atla
    22.  
    23. End Function
    Last edited by tony007; Apr 14th, 2009 at 05:32 PM.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Problem getting hwnd of external listview

    What do you get if you use Spy++?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Problem getting hwnd of external listview

    Quote Originally Posted by dee-u View Post
    What do you get if you use Spy++?
    Thanks for reply . I realy don't know how to use visual studio 6 spy++ but i tried it by clicking search ==> find window and dragged the finder tool over the listview and this is what i got :

    Handle:00040558
    caption:"Video Library"
    class:Button
    But use ing PAT JK'S API Spy's i got this part that i used in my code :
    2 Code:
    1. 'this part i used PAT or Jk's API spy 5.1
    2.  
    3. Dim atlc As Long, atlcf As Long, atla As Long
    4.  
    5. atlc = FindWindow("atl:008047c0", vbNullString)
    6. atlcf = FindWindowEx(atlc, 0&, "atl:00819cf0", vbNullString)
    7. atla = FindWindowEx(atlcf, 0&, "atl:00819a30", vbNullString)

    Note: see the pic of window that holds the listview
    Attached Images Attached Images  
    Last edited by tony007; Apr 14th, 2009 at 06:00 PM.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Problem getting hwnd of external listview

    Spy++ says it all, the control's class name is Button, you can try

    Code:
    atlc = FindWindow("Button", "Video Library")
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: Problem getting hwnd of external listview

    Quote Originally Posted by dee-u View Post
    Spy++ says it all, the control's class name is Button, you can try

    Code:
    atlc = FindWindow("Button", "Video Library")
    Didn't work . I got 0 for hWnd!! Can you look at the above attached image of the window that holds the listview and see if i we are in right path ?


    2 Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. 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
    3.  
    4.  
    5. Private Sub Command1_Click()
    6.  
    7. Dim hWnd As Long
    8. hWnd = getHwnd
    9.  
    10. MsgBox "value of hWnd:" & hWnd
    11. End Sub
    12.  
    13.  
    14.  
    15. Function getHwnd() As Long
    16. 'this part i used PAT or Jk's API spy 5.1
    17.  
    18. Dim atlc As Long, atlcf As Long, atla As Long
    19. 'atlc = FindWindow("atl:008047c0", vbNullString)
    20. atlc = FindWindow("Button", "Video Library")
    21. atlcf = FindWindowEx(atlc, 0&, "atl:00819cf0", vbNullString)
    22. atla = FindWindowEx(atlcf, 0&, "atl:00819a30", vbNullString)
    23.  
    24. getHwnd = atla
    25.  
    26. End Function

  6. #6
    Hyperactive Member
    Join Date
    Aug 2006
    Location
    TeXaS
    Posts
    497

    Re: Problem getting hwnd of external listview

    IMO it looks like the Listview is a child of a Frame; which would have a caption of "Video Library", the RatioBox at the top of the app also has a caption of "Video Library", and is more likely to be a "Button" Class than the frame would.

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