Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtGridCellComboBox item selection Collapse All
Subject Author Date
Richard Rodruck Oct 8, 2007 - 10:25 AM

When I implement a CExtGridCellComboBox and populate it, if you type in a letter to go to an item nothing happens. In searching this forum it looks like it is supposed to work like a regular combo box and select the first item with that letter. This is true in the sample prof uis controls also. I am using version 2.80. Is there something I need to do to make this work? I overroad the function that is supposed to perform this operation and the message WM_CHAR never fires.

Technical Support Oct 11, 2007 - 11:38 AM

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.

Technical Support Oct 8, 2007 - 2:06 PM

We can regard your message as a feature request and implemented it very soon. Thank you.