static CWnd* PASCAL WindowFromPoint( POINT point );Return ValueA pointer to the window object in which the point lies. It is NULL if no window exists at the given point. The returned pointer may be temporary and should not be stored for later use.关键是你在什么地方用了?这个返回的指针不能保存的
OnMouseMove中写的
CListBox* pWnd=(CListBox*)WindowFromPoint(point);
if(pWnd==NULL)
return;
pWnd->GetCount();
结果为正确的 没问题
CWnd *pWnd = WindowFromPoint ( pt);
if ( pWnd->IsKindOf(RUNTIME_CLASS(CListBox))
{
...
}