BOOL CListBox::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { switch (message) { case WM_DRAWITEM: ASSERT(pResult == NULL); // no return value expected DrawItem((LPDRAWITEMSTRUCT)lParam); break; case WM_MEASUREITEM: ASSERT(pResult == NULL); // no return value expected MeasureItem((LPMEASUREITEMSTRUCT)lParam); break; case WM_COMPAREITEM: ASSERT(pResult != NULL); // return value expected *pResult = CompareItem((LPCOMPAREITEMSTRUCT)lParam); break; case WM_DELETEITEM: ASSERT(pResult == NULL); // no return value expected DeleteItem((LPDELETEITEMSTRUCT)lParam); break; case WM_VKEYTOITEM: *pResult = VKeyToItem(LOWORD(wParam), HIWORD(wParam)); break; case WM_CHARTOITEM: *pResult = CharToItem(LOWORD(wParam), HIWORD(wParam)); break; default: return CWnd::OnChildNotify(message, wParam, lParam, pResult); } return TRUE; }
BOOL CListBox::OnChildNotify( UINT message, WPARAM wParam, LPARAM lParam, LRESULT *pResult ) /**********************************************/ { switch( message ) { case WM_CHARTOITEM: *pResult = CharToItem( LOWORD( wParam ), HIWORD( wParam ) ); return( TRUE ); case WM_COMPAREITEM: *pResult = CompareItem( (LPCOMPAREITEMSTRUCT)lParam ); return( TRUE ); case WM_DELETEITEM: DeleteItem( (LPDELETEITEMSTRUCT)lParam ); return( TRUE ); case WM_DRAWITEM: DrawItem( (LPDRAWITEMSTRUCT)lParam ); return( TRUE ); case WM_MEASUREITEM: MeasureItem( (LPMEASUREITEMSTRUCT)lParam ); return( TRUE ); case WM_VKEYTOITEM: *pResult = VKeyToItem( LOWORD( wParam ), HIWORD( wParam ) ); return( TRUE ); } return( FALSE ); }
//***************************************************************************** // // Function Name: RGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) // // Description: Message handler for WM_KEYDOWN. // // Returns: None // // Exceptions: None // //***************************************************************************** void RGridCtrlBase::OnKeyDown(UINT nChar, UINT, UINT) { int nCurSel = GetCurSel() ; int nRowOffset = 0 ; int nColOffset = 0 ; int nCurRow = nCurSel / m_nNumCols ; int nCurCol = nCurSel % m_nNumCols ; switch (nChar) { case VK_UP: nRowOffset = -1; break ; case VK_DOWN: nRowOffset = 1 ; break ; case VK_LEFT: nColOffset = -1 ; break ; case VK_RIGHT: nColOffset = 1 ; break ; case VK_PRIOR: nRowOffset = -m_cxVisibleRows ; break ; case VK_HOME: nRowOffset = -nCurRow ; nColOffset = -nCurCol ; break ; case VK_NEXT: nRowOffset = m_cxVisibleRows ; break ; case VK_END: nRowOffset = GetCount() / m_nNumCols - nCurRow ; nColOffset = GetCount() % m_nNumCols - nCurCol ; break ; default: // See if we're suppose to send it off to the parent if (GetStyle() & LBS_WANTKEYBOARDINPUT) { VKeyToItem( nChar, GetCurSel() ) ; } return ; } if (nCurSel < 0) { // // If there was no previously selected item, default // to the first item in the list. // nCurRow = nCurCol = 0 ; nRowOffset = nColOffset = 0 ; } else { // // Determine the new row and column, making sure to // keep them within bounds // nCurRow += nRowOffset ; nCurRow = max( 0, min( nCurRow, GetCount() / m_nNumCols ) ) ; nCurCol += nColOffset ; nCurCol = max( 0, min( nCurCol, m_nNumCols - 1 ) ) ; if (nCurRow == GetCount() / m_nNumCols) { nCurCol = min( nCurCol, GetCount() % m_nNumCols - 1 ) ; } } int nNewSel = nCurRow * m_nNumCols + nCurCol ; if (nNewSel != nCurSel) { if (nCurRow < m_nTopCellRow || nCurRow >= m_nTopCellRow + m_cxVisibleRows || nCurCol < m_nTopCellCol || nCurCol >= m_nTopCellCol + m_cxVisibleCols) { SetTopIndex( max( 0, GetTopIndex() + (nNewSel - nCurSel) )) ; } SetCurSel( nNewSel ) ; if (GetStyle() & LBS_NOTIFY) { GetParent()->PostMessage(WM_COMMAND, MAKEWPARAM( GetDlgCtrlID(), LBN_SELCHANGE ), (LPARAM) GetSafeHwnd()) ; } } }