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 selecting text Collapse All
Subject Author Date
Paul Cowan Mar 8, 2007 - 8:54 AM

CExtGridCellComboBox behaives differently then a standard combo box when typeing a character to select an item. With a standard combo box, typeing a letter will select the item that begins with that letter, Repeating the same character will only select items starting with the letter. With CExtGridCellComboBox, it’s mataching any character in the string, not just the first one.
How do I get CExtGridCellComboBox to behaive like the standard combobox and only look at the starting characeter?

Paul Cowan Mar 9, 2007 - 9:23 AM

I and W do work, but only becasue they only appear as the first character in the strings. Pressing t or e will cycle all the items in the list. I’d like the control to only check the first character.

Technical Support Mar 13, 2007 - 11:49 AM

Thank you for reporting the problem. Please update the CExtGridCellComboBox::OnInplaceControlPreTranslateMessage() method with this one and recompile the library:

bool CExtGridCellComboBox::OnInplaceControlPreTranslateMessage(
    MSG * pMsg,
    HWND hWndInplaceControl,
    CExtGridWnd & wndGrid,
    LONG nVisibleColNo,
    LONG nVisibleRowNo,
    LONG nColNo,
    LONG nRowNo,
    INT nColType,
    INT nRowType,
    const RECT & rcCellExtra,
    const RECT & rcCell,
    const RECT & rcInplaceControl
    )
{
    ASSERT_VALID( this );
    ASSERT( hWndInplaceControl != NULL && ::IsWindow(hWndInplaceControl) );
    ASSERT_VALID( (&wndGrid) );
    rcInplaceControl;

DWORD dwCellStyle = GetStyle();
    if( (dwCellStyle&__EGCS_READ_ONLY) != 0 )
        return false;

CExtGridInplaceEdit * pEdit = 
        static_cast < CExtGridInplaceEdit * > ( CWnd::FromHandle( hWndInplaceControl ) );
    ASSERT( pEdit != NULL );
    ASSERT_VALID( pEdit );
    
    bool bEnumMode = GetEnumMode();
    if(        bEnumMode
        &&    pMsg->message == WM_LBUTTONDBLCLK 
        )
    {
        _DoItemsIterate(
            hWndInplaceControl,
            true,
            false
            );
        pEdit->DoEndEdit( true );
        return true;
    }
    if(        bEnumMode
        &&    pMsg->message == WM_MOUSEWHEEL
        )
    {
        SHORT zDelta = HIWORD( pMsg->wParam );
        if( zDelta != 0 )
            _DoItemsIterate(
                hWndInplaceControl,
                zDelta < 0 ? true : false,
                false
                );
        return true;
    }
    if( pMsg->message == WM_KEYDOWN )
    {
        DWORD dwBseStyle = wndGrid.BseGetStyle();
        switch( pMsg->wParam ) 
        {
        case VK_DOWN:
        case VK_UP:
            if(        bEnumMode 
                &&    (dwBseStyle&__EGWS_BSE_WALK_VERT) == 0
                )
            {
                _DoItemsIterate(
                    hWndInplaceControl,
                    ( pMsg->wParam == VK_DOWN ) ? true : false,
                    true
                    );
                return true;
            }
            break;
        case VK_F4:
                if(        (GetStyle()&__EGCS_BUTTON_DROPDOWN) != 0 
                    &&    IsButtonEnabled( __EBTT_DROPDOWN )
                    )
                {
                    CRect _rcCellExtra( rcCellExtra );
                    CRect _rcCell( rcCell );
                    pEdit->DoEndEdit( true );
                    OnButtonPressed(
                        wndGrid,
                        __EBTT_DROPDOWN,
                        _rcCellExtra,
                        _rcCell,
                        nVisibleColNo,
                        nVisibleRowNo,
                        nColNo,
                        nRowNo,
                        nColType,
                        nRowType
                        );
                return true;
            }
            break;
        case VK_DELETE:
            if( bEnumMode )
                return true;
            break;
        }
    } // if( pMsg->message == WM_KEYDOWN )

    if(        bEnumMode
        &&    pMsg->message == WM_CHAR 
        )
    {
        CString sSpecSymbols( _T("~`!@#$%ˆ&*()_-+={}[]:;\"’|\\<,>.?/ ") );
        TCHAR ch = (TCHAR)pMsg->wParam;
        if(        IsCharAlphaNumeric( (TCHAR)pMsg->wParam ) 
            ||    sSpecSymbols.FindOneOf( CString(ch) )
            )
        {
            LONG nNextItem = -1L;
            LONG nCurSel = GetCurSel();

            LONG nItemsProcessed = 0L;
            LONG nItem = nCurSel;
            LONG nSize = LONG( m_arrItems.GetSize() );
            while( nItemsProcessed < nSize )
            {
                if( nItem == -1L )
                    nItem = 0L;
                else if( nItem < nSize - 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 );
                ::SetWindowText( 
                    hWndInplaceControl, 
                    GetItemString( nNextItem ) 
                    );
                ::SendMessage( 
                    hWndInplaceControl, 
                    EM_SETSEL, 
                    0, -1 
                    );
            }
        }
        return true;
    }
    return false;
}

Technical Support Mar 9, 2007 - 9:54 AM

Thank you for clarifying the issue. We will fix this as soon as possible.

Technical Support Mar 9, 2007 - 8:57 AM

We tried to reproduce your report but failed. You can use the Prof-UIS_Controls sample to make sure of that yourself: simply change the way the first cell in the CPageGrid::_InitColumnComboBox method is initialized.

CExtGridCellComboBox * pCellComboBox0 =
	STATIC_DOWNCAST(
		CExtGridCellComboBox,
		m_wndGrid.GridCellGet( nColNo, 0L )
		);
pCellComboBox0->SetEnumMode( true );
pCellComboBox0->AddString( _T("Item1") );
pCellComboBox0->AddString( _T("Wtem1") );
pCellComboBox0->AddString( _T("Item2") );
pCellComboBox0->AddString( _T("Wtem2") );
pCellComboBox0->AddString( _T("Wtem3") );
pCellComboBox0->AddString( _T("Item3") );
pCellComboBox0->AddString( _T("Wtem4") );
pCellComboBox0->SetCurSel( 2 );
So if you repeatedly press I or W, you can see that items are selected in the proper way.