The feature is implemented. Now when the user is typing a letter something and the focus is on a combo box cell or the popup list box is visible, the corresponding item whose text begins with this letter is selected. If there are several items with text beginning with the same letter, they are selected cyclically. This behavior is identical to that in the standard combo box.
Please update the source code for the CExtGridCellComboBox
class. Add the following method declaration
virtual bool OnKey(
CExtGridWnd & wndGrid,
bool bKeyDownEvent, // true - key-down event, false - key-up event
UINT nChar, // virtual key code
UINT nRepCnt, // key-down/key-up press count
UINT nFlags // key-down/key-up event flags
);
here its implementation:
bool CExtGridCellComboBox::OnKey(
CExtGridWnd & wndGrid,
bool bKeyDownEvent, // true - key-down event, false - key-up event
UINT nChar, // virtual key code
UINT nRepCnt, // key-down/key-up press count
UINT nFlags // key-down/key-up event flags
)
{
ASSERT_VALID( this );
ASSERT_VALID( (&wndGrid) );
DWORD dwCellStyle = GetStyle();
if( (dwCellStyle&__EGCS_READ_ONLY) != 0 )
return false;
if( bKeyDownEvent )
{
CString sSpecSymbols( _T("~`!@#$%ˆ&*()_-+={}[]:;\"’|\\<,>.?/ ") );
TCHAR ch = (TCHAR)nChar;
if( IsCharAlphaNumeric( ch )
|| sSpecSymbols.FindOneOf( CString(ch) )
)
{
LONG nNextItem = -1L;
LONG nCurSel = GetCurSel();
LONG nItemsProcessed = 0L;
LONG nItem = nCurSel;
LONG nCount = GetCount();
while( nItemsProcessed < nCount )
{
if( nItem == -1L )
nItem = 0L;
else if( nItem < nCount - 1L )
nItem++;
else
nItem = 0L;
ITEM_INFO * pItemInfo = m_arrItems[ nItem ];
ASSERT( pItemInfo != NULL );
CExtSafeString sItemString = pItemInfo->m_sString;
if( sItemString.GetLength() > 0 )
{
CExtSafeString sStringToFind = ch;
sItemString.MakeLower();
sStringToFind.MakeLower();
if( sItemString[0] == sStringToFind[0] )
{
nNextItem = nItem;
break;
}
}
nItemsProcessed++;
}
if( nNextItem >= 0L
&& nNextItem != nCurSel
)
{
SetCurSel( nNextItem, true );
CPoint ptFocus = wndGrid.FocusGet();
if( ptFocus.x >= 0 && ptFocus.y >= 0 )
wndGrid.OnGridCellInputComplete(
*this,
ptFocus.x,
ptFocus.y,
0,
0
);
}
return true;
}
} // if( bKeyDownEvent )
return
CExtGridCellString::OnKey(
wndGrid,
bKeyDownEvent,
nChar,
nRepCnt,
nFlags
);
}
Then update the
CExtPopupListBoxMenuWnd::_OnKeyDown()
method
bool CExtPopupListBoxMenuWnd::_OnKeyDown(
UINT nChar,
UINT nRepCnt,
UINT nFlags,
bool & bNoEat
)
{
ASSERT_VALID( this );
if( GetSafeHwnd() == NULL )
return true; //false;
if( GetSite().GetAnimated() != NULL )
return true;
if( _IsResizingMode() )
{
bNoEat = true;
return false;
}
TranslateKeyboardEventData_t _td( this, nChar, nRepCnt, nFlags, bNoEat );
if( _td.Notify() )
{
bNoEat = _td.m_bNoEat;
return true;
}
if( nChar == VK_F4 )
{
bNoEat = false;
_EndSequence();
return true;
}
CExtPopupInplaceListBox * pListBox =
STATIC_DOWNCAST(
CExtPopupInplaceListBox,
CWnd::FromHandlePermanent( GetChildCtrlHWND() )
);
ASSERT( pListBox != NULL );
ASSERT_VALID( pListBox );
CString sSpecSymbols( _T("~`!@#$%ˆ&*()_-+={}[]:;\"’|\\<,>.?/ ") );
TCHAR ch = (TCHAR)nChar;
if( IsCharAlphaNumeric( ch )
|| sSpecSymbols.FindOneOf( CString(ch) )
)
{
LONG nNextItem = -1L;
LONG nCurSel = pListBox->GetCurSel();
LONG nItemsProcessed = 0L;
LONG nItem = nCurSel;
LONG nCount = pListBox->GetCount();
while( nItemsProcessed < nCount )
{
if( nItem == -1L )
nItem = 0L;
else if( nItem < nCount - 1L )
nItem++;
else
nItem = 0L;
CExtSafeString sItemString;
pListBox->GetText( nItem, sItemString );
if( sItemString.GetLength() > 0 )
{
CExtSafeString sStringToFind = ch;
sItemString.MakeLower();
sStringToFind.MakeLower();
if( sItemString[0] == sStringToFind[0] )
{
nNextItem = nItem;
break;
}
}
nItemsProcessed++;
}
if( nNextItem >= 0L
&& nNextItem != nCurSel
)
pListBox->SetCurSel( nNextItem );
}
return
CExtPopupControlMenuWnd::_OnKeyDown(
nChar,
nRepCnt,
nFlags,
bNoEat
);
}
Recompile the Prof-UIS library after that.