void CLibraryAlbumView::SelectTo(int nDelta) { if ( m_nCount == 0 ) return; int nFocus = GetTrackIndex( m_pFocus ); if ( nFocus < 0 ) { nFocus = 0; } else { nFocus += nDelta; if ( nFocus < 0 ) nFocus = 0; if ( nFocus >= m_nCount ) nFocus = m_nCount - 1; } if ( SelectTo( m_pList[ nFocus ] ) ) Invalidate(); }
BOOL CLibraryAlbumView::SelectTo(CLibraryAlbumTrack* pTrack) { BOOL bChanged = FALSE; if ( pTrack ) { m_pFocus = pTrack; int nFirst = GetTrackIndex( m_pFirst ); int nFocus = GetTrackIndex( m_pFocus ); if ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) { bChanged = Select( m_pFocus, TRI_UNKNOWN ); } else if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) { bChanged = DeselectAll(); if ( nFirst >= 0 && nFocus >= 0 ) { if ( nFirst <= nFocus ) { for ( ; nFirst <= nFocus ; nFirst++ ) Select( m_pList[ nFirst ], TRI_TRUE ); } else { for ( ; nFocus <= nFirst ; nFocus++ ) Select( m_pList[ nFocus ], TRI_TRUE ); } bChanged = TRUE; } else { bChanged |= Select( m_pFocus, TRI_TRUE ); } } else { if ( m_pFocus->m_bSelected == FALSE ) bChanged = DeselectAll( m_pFocus ); bChanged |= Select( m_pFocus ); } if ( m_nSelected == 1 && m_pFocus->m_bSelected ) m_pFirst = m_pFocus; CRect rcClient, rcItem; GetClientRect( &rcClient ); GetItemRect( m_pFocus, &rcItem ); if ( rcItem.top < rcClient.top + m_szTrack.cy ) ScrollBy( rcItem.top - rcClient.top - m_szTrack.cy ); else if ( rcItem.bottom > rcClient.bottom ) ScrollBy( rcItem.bottom - rcClient.bottom ); } else if ( ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) == 0 && ( GetAsyncKeyState( VK_CONTROL ) & 0x8000 ) == 0 ) { bChanged = DeselectAll(); } if ( m_nSelected == 0 ) m_pFirst = NULL; return bChanged; }