Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 481
  • Last Modified:

Listview control--searching subitems

I've got a listview control with several columns. I am using CListCtrl::FindItem to search.  It finds matches when i'm searching for data in the first column of the listcontrol, but not when i'm searching for data that exists in any other column.  How do I search other columns?
0
jerryross
Asked:
jerryross
  • 2
  • 2
1 Solution
 
jerryrossAuthor Commented:
I figured it out...here is the code if you're curious:
 
  // declare variables
  int nIndexStart;
  LV_FINDINFO lvfi={0};
  ::ZeroMemory (&lvfi, sizeof (LV_FINDINFO));

  LV_ITEM dwItemData;  //stucture to hold item search data
  LV_ITEM *pdwItemData; // point to item search data
  dwItemData.mask = LVIF_TEXT; // to search for text
  dwItemData.iSubItem = 2;  // to search subitem column 2
  dwItemData.pszText = "Looking for this text"
             
  lvfi.flags = LVFI_PARAM; // to tell it to look at the item structure
  lvfi.lParam = (LPARAM) pdwItemData; // point at item structure

  nIndexStart = DefWindowProc(LVM_FINDITEM, (WPARAM)-1, (LPARAM)&lvfi);  //do search and return the index of the match

My question now is this:  How does it know which listview control i'm asking it to search?  The code works though so i'm happy :)

0
 
Answers2000Commented:
LVM_FINDITEM is a message, use SendMessage to send it to a particular window

It knows with your code because it's DefWindowProc is a member of CWnd (base class of CListCtrl) and what you are really doing is :-

this->DefWindowProc(LVM_FINDITEM, (WPARAM)-1, (LPARAM)&lvfi);

0
 
Answers2000Commented:
The this-> is implicit

If you want to specify a particular window to call a member function for use

pWnd->_whatever__
( for CWnd * and pointers to derived classes of CWnd)
or

wnd.__whatever__
( for actual CWnd objects, and derived classes of CWnd)
0
 
jerryrossAuthor Commented:
Thank you ~!~
0
 
geo_134Commented:
i need to find a item in particuar row
and highlight that particular row.i am have 1000 rows and 10 columns.i have used rowlist sample from msdn help.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now