setCapture

展开阅读全文

CListCtrl派生类不可以SetCapture()?

06-27

[code=C/C++]rnBEGIN_MESSAGE_MAP(CHexCtrl, CListCtrl)rn //AFX_MSG_MAP(CHexCtrl)rn ON_NOTIFY_REFLECT(LVN_ITEMCHANGING, OnItemchanging)rn ON_WM_ERASEBKGND()rn ON_NOTIFY_REFLECT(NM_CLICK, OnClick)rn ON_WM_LBUTTONDOWN()rn ON_WM_MOUSEMOVE()rn ON_WM_LBUTTONUP()rn ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)rn //AFX_MSG_MAPrnEND_MESSAGE_MAP()rnrnvoid CHexCtrl::OnClick(NMHDR* pNMHDR, LRESULT* pResult) rnrn // TODO: Add your control notification handler code herern m_bBeginSel = FALSE;rn ReleaseCapture();rn rn *pResult = 0;rnrnrnvoid CHexCtrl::OnLButtonDown(UINT nFlags, CPoint point) rnrn // TODO: Add your message handler code here and/or call defaultrn m_bBeginSel = TRUE;rn rn CWnd* pWnd = SetCapture();rn rn LVHITTESTINFO lvhit;rn lvhit.pt = point;rn int item = SubItemHitTest(&lvhit);rn rn if (item != -1 && (lvhit.flags & LVHT_ONITEM))rn rn int subitem = lvhit.iSubItem;rn if (subitem > 0 && subitem < 17)rn rn m_nBeginItem = MAKELONG(subitem, item);rn m_nEndItem = m_nBeginItem;rn rn rn rn Invalidate(); rn CListCtrl::OnLButtonDown(nFlags, point);rnrnrnvoid CHexCtrl::OnMouseMove(UINT nFlags, CPoint point) rnrn // TODO: Add your message handler code here and/or call default rn CListCtrl::OnMouseMove(nFlags, point);rnrn if (m_bBeginSel)rn rn LVHITTESTINFO lvhit;rn lvhit.pt = point;rn int item = SubItemHitTest(&lvhit);rn if (item != -1 && (lvhit.flags & LVHT_ONITEM))rn rn int subItem = lvhit.iSubItem;rn int id = MAKELONG(subItem, item);rn if (id == m_nEndItem)rn return;rn rn if (subItem > 0 && subItem < 17)rn rn m_nEndItem = id;rn rn //TRACE("%08X~%08X", min(m_nBeginItem,m_nEndItem), max(m_nBeginItem,m_nEndItem));rn rn CRect rcSubItem;rn GetItemRect(item, rcSubItem, LVIR_BOUNDS);rn rn //InvalidateRect(&rcSubItem);rn Invalidate();rn rn rn rnrnrnvoid CHexCtrl::OnLButtonUp(UINT nFlags, CPoint point) rnrn // TODO: Add your message handler code here and/or call defaultrn m_bBeginSel = FALSE;rn ReleaseCapture();rn rn CListCtrl::OnLButtonUp(nFlags, point);rnrn[/code]rnrnclass CHexCtrl : public CListCtrlrnrn以上代码发现,当鼠标按下,按出List,放开鼠标,OnLButtonUp并不响应,何解?rn还有发现当鼠标快速点击,OnLButtonUp也不响应,而响应了OnClick,这又何解? 论坛

没有更多推荐了,返回首页