[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

example of GetListCtrl()

Posted on 1998-11-13
6
Medium Priority
?
931 Views
Last Modified: 2013-11-20
Could someone please provide an example of using GetListCtrl()?
0
Comment
Question by:jerryross
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1324651
This code is from a member function of a class derived from CListView:

 CListCtrl& ctrl = GetListCtrl();
 int count = ctrl.GetItemCount();
 for (int i = 0; i < count; i++)
 {
   // do something with each item
 }


0
 

Author Comment

by:jerryross
ID: 1324652
That makes sense, but my goal is to call FindItem for a ListView control.  I created the ListView control as a dialog resource, and now I want to search the control.  The I'm trying to call FindItem from code outside of the listview control.  Here is the code:

  CListView* pLB = (CListView*) GetDlgItem(IDC_LISTVIEW);
  CListCtrl *pLC;
  pLC = &(pLB->GetListCtrl());

  nIndex = ListView_FindItem( pLC->m_hWnd,-1,&plvfi);

Can you see a problem with the above?  FindItem returns with -1 every time even when it should match.
0
 
LVL 1

Accepted Solution

by:
atari earned 400 total points
ID: 1324653
CListView in a dialog ? There must be something wrong, you can only have a CListCtrl in a dialog box, and then what you only need to do is to define a member variable with class wizard as control for it. Then you could call:

LV_FINDINFO lvfi;
lvfi.flags = LVFI_STRING;      // Search strings
int index = m_YourListCtrl.FindItem(&lvfi, -1);

That's it,
bye,
atari
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jerryross
ID: 1324654
I had renamed the dialog and this prevented class wizard from showing new IDCs so I coudn't add a member variable for the list control.  I have done that, the next step is to figure out why FindItem doesn't work when i'm trying to search subItems.

Thanks,
Jerry
0
 
LVL 1

Expert Comment

by:atari
ID: 1324655
If you change something, that class wizard don't recognize then simply delete the .clw-file in your project folder and from within Visual C++ type Ctrl+W and let the class wizard build the .clw-file again. That's what one often had to do when including new files to the project or if some changes in the resource-file will be made that class wizard don't recognize.

Thanks,
bye,
atari
0
 

Author Comment

by:jerryross
ID: 1324656
Thank you!! That is very useful information.  

I didn't get FindItem to work so I just used the member variable created with class wizard to call GetText.  I just iterate through the list control comparing each subItem.  I'm sure this method is not as fast as FindItem, but it works.  Thank you for your help!

Jerry
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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 will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

656 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