Search code examples
csendmessagesyslistview32

Enumerating SysListView32 items with C


All examples I found was C# related, but I'm unfamiliar with it. My task is to provide some kind of automation for testing. I have installer which first buttons are inside of SysListView32, as I can understand My target is to select them, choose button by its name and click it The last part is obvious:

GetWindowText(control, window_name, 256);
if(strcmp.....
{
do smth
}

But when it comes to SysListView32 I can't understand how to extract its object and names in C


Solution

  • Take a look at LVM_GETITEM. The MSDN documentation page is here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb774953(v=vs.85).aspx. The documentation is actually pretty thorough.

    A short example that will retrieve the "lParam", the image list index for the icon and the text of an item:

    LVITEM lvItem;
    TCHAR szBuffer[MAX_PATH + 1] = { 0 };
    
    lvItem.mask       = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
    lvItem.iItem      = iItem;
    lvItem.iSubItem   = 0;
    lvItem.pszText    = szBuffer;
    lvItem.cchTextMax = MAX_PATH;
    
    if(ListView_GetItem(m_hListView,&lvItem))
    {
        /* success! the item details are in lvItem */ 
    }