List control ignores FindItem?
-
Hi, I have an (owner drawn) list control and handle the LVN_ODFINDITEM message. For testing purposes:
void CIndexDlg::OnLvnOdfinditemData(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVFINDITEM pFindInfo = reinterpret_cast(pNMHDR);
*pResult = (rand() % 999) + 1;
}This works good when typing something inside the control. But now I also want to have an external way to find an entry. So I places an edit control in the dialog and want to call FindItem manually:
LVFINDINFO fi;
ZeroMemory(&fi, sizeof(fi));
fi.flags = LVFI_PARTIAL | LVFI_STRING;
fi.psz = m_strWhat;m_ctrlData.FindItem(&fi);
//m_ctrlData.SendMessage(LVM_FINDITEM, -1, (LPARAM)&fi);But in this case, my OnLvnOdfinditemData handler never gets called! I also tried sending manually with SendMessage but it did not work either. What could be the problem?
-
Hi, I have an (owner drawn) list control and handle the LVN_ODFINDITEM message. For testing purposes:
void CIndexDlg::OnLvnOdfinditemData(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVFINDITEM pFindInfo = reinterpret_cast(pNMHDR);
*pResult = (rand() % 999) + 1;
}This works good when typing something inside the control. But now I also want to have an external way to find an entry. So I places an edit control in the dialog and want to call FindItem manually:
LVFINDINFO fi;
ZeroMemory(&fi, sizeof(fi));
fi.flags = LVFI_PARTIAL | LVFI_STRING;
fi.psz = m_strWhat;m_ctrlData.FindItem(&fi);
//m_ctrlData.SendMessage(LVM_FINDITEM, -1, (LPARAM)&fi);But in this case, my OnLvnOdfinditemData handler never gets called! I also tried sending manually with SendMessage but it did not work either. What could be the problem?
- Could you use Spy++ to investigate what messages (with wparam and lparam? Not sure if Spy++ tracks those) are sent when doing an incremental search using the keyboard
- Have you verified your
FindItem
call is successful with a non-virtual/non-owner data list control?
Aside from that, can't see as you're doing anything wrong :-(
-
- Could you use Spy++ to investigate what messages (with wparam and lparam? Not sure if Spy++ tracks those) are sent when doing an incremental search using the keyboard
- Have you verified your
FindItem
call is successful with a non-virtual/non-owner data list control?
Aside from that, can't see as you're doing anything wrong :-(
Hi and thank you for the help! I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:
<00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
<00005> 00070E74 R LVM_FINDITEMA iIndex: 86I really don't know why my message handler is not called :-( Niki
-
Hi and thank you for the help! I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:
<00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
<00005> 00070E74 R LVM_FINDITEMA iIndex: 86I really don't know why my message handler is not called :-( Niki
I know what is my error: FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position. Is there a way to implement this? I already tried UpdateWindow() and also SetSelectionMark()... Thank you!
-
I know what is my error: FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position. Is there a way to implement this? I already tried UpdateWindow() and also SetSelectionMark()... Thank you!
That I can help you with :-)
CListCtrl::EnsureVisible
makes a specified item visible.CListCtrl::Scroll
gives you more control over how the list control's view is altered.