C++ win32 winapi LVM_FINDITEM or ListView_FindItem returns -1 unexpectedly

If you can’t get LVM_FINDITEM to work and your project is unicode make sure that you are passing the tagLVFINDINFOW struct (unicode) and not the tagLVFINDINFOA struct (ANSI).
Working code snippet…
int findhit = 0;
tagLVFINDINFOW lvMeta;
lvMeta.flags = LVFI_STRING;
lvMeta.psz = L"10"; // search the first column for the number 10
findhit = SendMessage(lstGrid, LVM_FINDITEM, -1, (LPARAM)&lvMeta);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s