Solved

Listview control--searching subitems

Posted on 1998-11-11
5
424 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

10 Experts available now in Live!

Get 1:1 Help Now