void CCandidateWindow::_OnVScroll(DWORD dwSB, _In_ DWORD nPos)
{
    switch (dwSB)
    {
    case SB_LINEDOWN:
        _SetSelectionOffset(+1);
        _InvalidateRect();
        break;
    case SB_LINEUP:
        _SetSelectionOffset(-1);
        _InvalidateRect();
        break;
    case SB_PAGEDOWN:
        _MovePage(+1, FALSE);
        _InvalidateRect();
        break;
    case SB_PAGEUP:
        _MovePage(-1, FALSE);
        _InvalidateRect();
        break;
    case SB_THUMBPOSITION:
        _SetSelection(nPos, FALSE);
        _InvalidateRect();
        break;
    }
}
void CScrollButtonWindow::_OnLButtonUp(POINT pt)
{
    CButtonWindow::_OnLButtonUp(pt);

    _InvalidateRect();

    if (_IsTimer())
    {
        _EndTimer();
    }
}
bool CListViewCtrlEx::SetSubItemColor( int nItem, int nSubItem, COLORREF clr, BOOL bRedraw  )
{
    if(nItem>=0 && nItem<m_arrItems.size())
    {
        std::vector<TListSubItem> &subItems = m_arrItems[nItem]->subItems;
        if(nSubItem>=0 && nSubItem<subItems.size())
        {
            subItems[nSubItem].clr = clr;
            if(bRedraw)
                _InvalidateRect(nItem, nSubItem);
            return true;
        }
    }
    return false;
}
bool CListViewCtrlEx::SetSubItem( int nItem, int nSubItem, LPCTSTR lpszItem, E_SubItemType itemType/*=SUBITEM_TEXT*/, BOOL bRedraw )
{
    if(nItem>=0 && nItem<m_arrItems.size())
    {
        std::vector<TListSubItem> &subItems = m_arrItems[nItem]->subItems;
        if(nSubItem>=0 && nSubItem<subItems.size())
        {
            subItems[nSubItem].type = itemType;
            subItems[nSubItem].str = lpszItem;
            if(bRedraw)
                _InvalidateRect(nItem, nSubItem);
            return true;
        }
    }
    return false;
}
void CScrollBarWindow::_OnLButtonUp(POINT pt)
{
    if (_IsCapture())
    {
        CBaseWindow* pUIWnd = _GetTopmostUIWnd();
        if (pUIWnd)
        {
            CBaseWindow *pCapture = pUIWnd->_GetCaptureObject();
            if (pCapture && pCapture != this)
            {
                pCapture->_OnLButtonUp(pt);
            }
        }
    }
    else
    {
        RECT rc = {0, 0, 0, 0};

        _pBtnUp->_GetClientRect(&rc);
        if (PtInRect(&rc, pt))
        {
            _pBtnUp->_OnLButtonUp(pt);
        }
        else
        {
            _pBtnDn->_GetClientRect(&rc);
            if (PtInRect(&rc, pt))
            {
                _pBtnDn->_OnLButtonUp(pt);
            }
        }
    }

    if (_IsCapture())
    {
        _EndCapture();
    }
    if (_IsTimer())
    {
        _EndTimer();
    }

    _scrollDir = SCROLL_NONE_DIR;
    _InvalidateRect();
}
void CScrollBarWindow::_SetCurPos(int nPos, int dwSB)
{
    int posMax = (_scrollInfo.nMax <= _scrollInfo.nPage) ? 0 : _scrollInfo.nMax - _scrollInfo.nPage;

    nPos = min(nPos, posMax);
    nPos = max(nPos, 0);

    _scrollInfo.nPos = nPos;

    if (_IsWindowVisible()) {
        _InvalidateRect();
    }

    if ((_IsCapture() && dwSB != -1) || (dwSB == SB_THUMBPOSITION))
    {
        _NotifyCommand(WM_VSCROLL, dwSB, nPos);
    }
}