jerryross
asked on
example of GetListCtrl()
Could someone please provide an example of using GetListCtrl()?
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks,
Jerry
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
Thanks,
bye,
atari
ASKER
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
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
CListCtrl& ctrl = GetListCtrl();
int count = ctrl.GetItemCount();
for (int i = 0; i < count; i++)
{
// do something with each item
}