bool CACListWnd::EnsureVisible(int item, bool m_bWait)
{
	if(item > m_lTopIndex && item < m_lTopIndex + m_VisibleItems)
		return false; // ist visible

	if(item > m_lTopIndex)	// scroll down
	{
		long m_len = item;
		for(int i = m_lTopIndex; i < m_len; i++)
		{
			if(i >= m_lCount-m_VisibleItems)
				break;
			if(i >= m_lCount-m_VisibleItems || i + m_VisibleItems > item)
			{
				break;
			}

			m_lTopIndex++;

			if(m_bWait)
			{
				InvalidateAndScroll();
				Sleep(10);
				DoPaintMessageLoop();
			}
		}
		InvalidateAndScroll();
		return true;
	}

	if(item < m_lTopIndex)	// scroll up
	{
		while(item < m_lTopIndex)
		{
			if(m_lTopIndex > 0)
				m_lTopIndex--;
			else
			{
				break;
			}

			if(m_bWait)
			{
				InvalidateAndScroll();
				Sleep(10);
				DoPaintMessageLoop();
			}
		}

		InvalidateAndScroll();
		return true;
	}

	return false;
}
Example #2
0
void CACListWnd::OnLButtonDown(UINT nFlags, CPoint point) {
  CWnd::OnLButtonDown(nFlags, point);
  int sel = HitTest(point);

  if (sel >= 0) {

    if (!EnsureVisible(sel, true))
      Invalidate();

    m_lSelItem = sel;
    m_pEditParent->SendMessage(ENAC_UPDATE, WM_KEYDOWN, GetDlgCtrlID());
    DoPaintMessageLoop();
    Sleep(500);
    ShowWindow(SW_HIDE);
  } else {
    CRect rc;
    GetClientRect(rc);
    if (!rc.PtInRect(point))
      ShowWindow(SW_HIDE);
  }
}
Example #3
0
void CACListWnd::InvalidateAndScroll() {
  m_VertBar.SetScrollPos(m_lTopIndex, TRUE);
  Invalidate();
  DoPaintMessageLoop();
}