Solved

Listview control--searching subitems

Posted on 1998-11-11
5
431 Views
Last Modified: 2013-11-20
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
Comment
Question by:jerryross
  • 2
  • 2
5 Comments
 

Author Comment

by:jerryross
ID: 1324529
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
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1324530
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1324531
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
 

Author Comment

by:jerryross
ID: 1324532
Thank you ~!~
0
 

Expert Comment

by:geo_134
ID: 3930980
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now