0

I have a VB6 application with a ListView (MSCOMCTL.OCX). I need to get the window handle (hwnd) for a listviewitem, or preferably (if something like that exists) - of a specific subitem.

I know I can get the handle for the column headers using FindWindowEx and looking for the class msvb_lib_header, but I don't know how to get the handle for the item. Spy++ shows a msvb_lib_header window as the child of the listview, but does not show any other windows.

user884248
  • 2,134
  • 3
  • 32
  • 57
  • Listview items are not windows, they are simply drawn into the LV. The API identifies them by index and their subitems with an additional index. What are you trying to achieve? – Alex K. Nov 11 '14 at 14:27
  • Thanks for replying Alex. I'm trying to create a multiline tooltip that has different contents for each item. I found code for this and it works, except that it needs to attach to a window handle. – user884248 Nov 11 '14 at 14:31
  • Are you trying to add a tooltip to a listview? I'm sure there's an example somewhere on MSDN of doing just that, but I can't find it right now for some reason... – andlabs Nov 11 '14 at 14:43
  • 1
    Be aware that the VB6 MSCOMCTL's ListView is a partial port of the Windows ListView class so support for the underlying API is not 100%. – Alex K. Nov 11 '14 at 14:45
  • 1
    @Alex K. Older `Microsoft Windows Common Controls 5.0 (SP2)` directly use windows common controls *and* can be themed. – wqw Nov 11 '14 at 18:55

2 Answers2

3

List view items and subitems are not window handles. They are internal children of the list view, exposed using the LVM_GETITEM and LVM_SETITEM messages and the LVITEM structure. (Subitems use the same interface; the iSubItem member of LVITEM would be nonzero in this case.)

andlabs
  • 11,290
  • 1
  • 31
  • 52
0

ListView.ListItem object has not hwnd.

You should search ListView by class name, next use SendMessage() to send the message LVM_GETITEM and using the LVITEM structure to get info about items:

LVM_GETITEM message (Windows)

https://msdn.microsoft.com/en-us/library/windows/desktop/bb774953(v=vs.85).aspx

LVITEM structure (Windows)

https://msdn.microsoft.com/en-us/library/windows/desktop/bb774760(v=vs.85).aspx

this reference page may help you:

List-View Control Reference (Windows) https://msdn.microsoft.com/en-us/library/windows/desktop/ff485973(v=vs.85).aspx

Giorgio Brausi
  • 414
  • 3
  • 7