List box hit testing doesn't work properly in Windows XP.
Code:
UINT CAddSeqDlg::ItemFromPointNT(CPoint pt, BOOL& bOutside) const
// CListBox::ItemFromPoint does not work on NT.
{
if (m_lstFrames.GetCount()==0) return -1;
int nFirstIndex, nLastIndex;
nFirstIndex = m_lstFrames.GetTopIndex();
nLastIndex = nFirstIndex + m_lstFrames.GetCount();
bOutside = TRUE;
CRect Rect;
int nResult = -1;
for (int i = nFirstIndex;nResult==-1 && i<=nLastIndex;i++)
{
int result=m_lstFrames.GetItemRect(i,&Rect);
if (result==LB_ERR)
{
nResult=nLastIndex-1;
bOutside=FALSE;
}
else
{
if (Rect.PtInRect(pt))
{
nResult = i;
bOutside = FALSE;
}
}
}
return nResult;
}
This is from code I found either at codeguru or codeproject. This is MFC, but you should be able to convert to Win32 quite easily.