MFC 继承CListBox 在重载OnVScroll的时候发现拖动关东条的时候鼠标没有放开的时候可以正常拖动,当鼠标放开了以后会自动回到原点,请问这个问题怎么解决,谢谢了代码如下:
void CWMCheckListBox::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
SetTopIndex(nPos);
}

解决方案 »

  1.   

    http://xulin.blog.51cto.com/264387/65569
      

  2.   

    问题解决
    void CWMCheckListBox::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    {
    int TopIndex = GetTopIndex();
    int nCount   = GetCount();
    CString str;
    str.Format(L"%d\n",TopIndex);
    TRACE(str);
    TRACE(L"nPos  %d\n", nPos);
    ::SendMessage( GetParent()->GetDlgItem( IDC_CUSTOM_COLORLIST )->GetSafeHwnd(), WM_CHECKLIST_VSCROLL, (WPARAM)TopIndex, (LPARAM)nCount ); Invalidate(TRUE);
    CCheckListBox::OnVScroll(nSBCode,   nPos,   pScrollBar); }
      

  3.   

    问题解决
    void CWMCheckListBox::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    {
    int TopIndex = GetTopIndex();
    int nCount   = GetCount();
    CString str;
    str.Format(L"%d\n",TopIndex);
    TRACE(str);
    TRACE(L"nPos  %d\n", nPos);
    ::SendMessage( GetParent()->GetDlgItem( IDC_CUSTOM_COLORLIST )->GetSafeHwnd(), WM_CHECKLIST_VSCROLL, (WPARAM)TopIndex, (LPARAM)nCount ); Invalidate(TRUE);
    CCheckListBox::OnVScroll(nSBCode,   nPos,   pScrollBar); }