List框(列表框)能否接受键盘或者鼠标消息呀?
如果能请告诉怎么接收?
谢谢了

解决方案 »

  1.   

    可以,CListCtrl是从cwnd派生的,cwnd可以响应ON_WM_MOUSEMOVE,ON_WM_LBUTTONDOWN,ON_WM_LBUTTONUP等消息
    还可以留意下HitTest(CPoint pt,UINT &nFlags)这个函数,下面是段示例的代码
    CRect rcItem;
    nFlags = 0;
    for (int i = 0; i < GetCount(); i++)
    {
        GetItemRect(i,rcItem);
        if (rcItem.PtInRect(pt))
        {
               ...
         }
    }
      

  2.   

    int CMyList::HitTest(CPoint pt,UINT &nFlags)
    {
    CRect rcItem;
    nFlags = 0;
    for (int i = 0; i < GetCount(); i++)
    {
    GetItemRect(i,rcItem);
    if (rcItem.PtInRect(pt))
    {
                          .......
                       }
              }
    }