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 » OnGridCellInputComplete called on CExtGridCellDropListComboBox even if selecting the same item Collapse All
Subject Author Date
Offer Har Dec 8, 2008 - 9:24 AM

Dear Support,


I have a drop-list cell of type CExtGridCellDropListComboBox, and when the user changes the selection I need to reset several depending cells. However, if the user selects the same item that was selected before, I do not need to do anything.


The problem is that I use OnGridCellInputComplete as my event handler for the drop-list change, and even if the user re-select the same item this event is called.


Is there a way to prevent this at the cell level, so that if the same item is selected it will not call OnGridCellInputComplete? or do i need to implement such mechanism to remember lat selected item?


Thanks,


Ron.

Technical Support Dec 9, 2008 - 9:56 AM

The CExtGridCell::OnPopupListBoxSelEndOK() virtual method handles the selection of a list box item and invokes CExtGridWnd::OnGridCellInputComplete() . We assume the selection of the same list box item can be useful because it can be interpreted as an event for refreshing some data views in your application. For your convenience, we added the following grid cell style which makes all the CExtGridCell***::OnPopupListBoxSelEndOK() virtual methods not invoking the the CExtGridWnd::OnGridCellInputComplete() virtual method if the text of the selected list box item is equal to grid cell text:

#define __EGCS_EX_DO_NOT_NOTIFY_LB_SEL_FOR_EQUAL_TEXT       0x00200000L


Here are the modified methods:

bool CExtGridCell::OnPopupListBoxSelEndOK(
            CExtPopupInplaceListBox & wndListBox,
            CExtGridCell::TrackCellStateInfo_t & _tcsi
            )
{
            ASSERT_VALID( this );
            ASSERT( (&_tcsi.m_cell) == this );
            ASSERT_VALID( (&wndListBox) );
            ASSERT_VALID( (&_tcsi.m_wndGrid) );
            _tcsi.m_nItemNoSelEndOK = wndListBox.GetCurSel();
            _tcsi.m_bHelperSelChanged = true;
            if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            {
                        LONG nItemCount = wndListBox.GetCount();
                        if( nItemCount > 0L )
                        {
                                    LONG nCurSel = wndListBox.GetCurSel();
                                    if( 0L <= nCurSel && nCurSel < nItemCount )
                                    {
                                                CString strSelLbText;
                                                wndListBox.GetText( nCurSel, strSelLbText );
                                                DWORD dwStyleEx = GetStyleEx();
                                                bool bSendSelEndOkOnEqualText = ( ( dwStyleEx & __EGCS_EX_DO_NOT_NOTIFY_LB_SEL_FOR_EQUAL_TEXT ) != 0 ) ? true : false;
                                                if( ! bSendSelEndOkOnEqualText )
                                                {
                                                            CExtSafeString strCurrentText;
                                                            TextGet( strCurrentText );
                                                            if( strCurrentText == LPCTSTR(strSelLbText) )
                                                                        return false;
                                                }
                                                if( ! strSelLbText.IsEmpty() )
                                                {
                                                            HRESULT hr = OnParseText( LPCTSTR(strSelLbText) );
                                                            if( hr == S_OK )
                                                            {
                                                                        TextSet( LPCTSTR(strSelLbText) );
                                                                        _tcsi.m_wndGrid.OnGridCellInputComplete( *this, _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColType, _tcsi.m_nRowType, wndListBox.GetSafeHwnd() );
                                                            } // if( hr == S_OK )
                                                } // if( ! strSelLbText.IsEmpty() )
                                    } // if( 0L <= nCurSel && nCurSel < nItemCount )
                        } // if( nItemCount > 0L )
            } // if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            return false;
}

bool CExtGridCellComboBox::OnPopupListBoxSelEndOK(
            CExtPopupInplaceListBox & wndListBox,
            CExtGridCell::TrackCellStateInfo_t & _tcsi
            )
{
            ASSERT_VALID( this );
            ASSERT( (&_tcsi.m_cell) == this );
            ASSERT_VALID( (&wndListBox) );
            ASSERT_VALID( (&_tcsi.m_wndGrid) );
            _tcsi.m_nItemNoSelEndOK = wndListBox.GetCurSel();
            _tcsi.m_bHelperSelChanged = true;
            if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            {
                        LONG nItemCount = wndListBox.GetCount();
                        if( nItemCount > 0L )
                        {
                                    LONG nCurSel = wndListBox.GetCurSel();
                                    if( 0L <= nCurSel && nCurSel < nItemCount )
                                    {
                                                SetCurSel( nCurSel );
                                                CString strSelLbText;
                                                wndListBox.GetText( nCurSel, strSelLbText );
                                                DWORD dwStyleEx = GetStyleEx();
                                                bool bSendSelEndOkOnEqualText = ( ( dwStyleEx & __EGCS_EX_DO_NOT_NOTIFY_LB_SEL_FOR_EQUAL_TEXT ) != 0 ) ? true : false;
                                                if( ! bSendSelEndOkOnEqualText )
                                                {
                                                            CExtSafeString strCurrentText;
                                                            TextGet( strCurrentText );
                                                            if( strCurrentText == LPCTSTR(strSelLbText) )
                                                                        return false;
                                                }
                                                TextSet( LPCTSTR(strSelLbText) );
                                                _tcsi.m_wndGrid.OnGridCellInputComplete( *this, _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColType, _tcsi.m_nRowType, wndListBox.GetSafeHwnd() );
                                    } // if( 0L <= nCurSel && nCurSel < nItemCount )
                        } // if( nItemCount > 0L )
            } // if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            return false;
}

bool CExtGridCellBool::OnPopupListBoxSelEndOK(
            CExtPopupInplaceListBox & wndListBox,
            CExtGridCell::TrackCellStateInfo_t & _tcsi
            )
{
            ASSERT_VALID( this );
            ASSERT( (&_tcsi.m_cell) == this );
            ASSERT_VALID( (&wndListBox) );
            ASSERT_VALID( (&_tcsi.m_wndGrid) );
            _tcsi.m_nItemNoSelEndOK = wndListBox.GetCurSel();
            _tcsi.m_bHelperSelChanged = true;
            if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            {
                        LONG nItemCount = wndListBox.GetCount();
                        if( nItemCount > 0L )
                        {
                                    LONG nCurSel = wndListBox.GetCurSel();
                                    if( 0L <= nCurSel && nCurSel < nItemCount )
                                    {
                                                CString strSelLbText;
                                                wndListBox.GetText( nCurSel, strSelLbText );
                                                DWORD dwStyleEx = GetStyleEx();
                                                bool bSendSelEndOkOnEqualText = ( ( dwStyleEx & __EGCS_EX_DO_NOT_NOTIFY_LB_SEL_FOR_EQUAL_TEXT ) != 0 ) ? true : false;
                                                if( ! bSendSelEndOkOnEqualText )
                                                {
                                                            CExtSafeString strCurrentText;
                                                            TextGet( strCurrentText );
                                                            if( strCurrentText == LPCTSTR(strSelLbText) )
                                                                        return false;
                                                }
                                                bool bData = ( wndListBox.GetItemData( nCurSel ) != 0 ) ? true : false;
                                                DataSet( bData );
                                                _tcsi.m_wndGrid.OnGridCellInputComplete( *this, _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColType, _tcsi.m_nRowType, wndListBox.GetSafeHwnd() );
                                    } // if( 0L <= nCurSel && nCurSel < nItemCount )
                        } // if( nItemCount > 0L )
            } // if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            return false;
}

bool CExtGridCellUpDownFontWeight::OnPopupListBoxSelEndOK(
            CExtPopupInplaceListBox & wndListBox,
            CExtGridCell::TrackCellStateInfo_t & _tcsi
            )
{
            ASSERT_VALID( this );
            ASSERT( (&_tcsi.m_cell) == this );
            ASSERT_VALID( (&wndListBox) );
            ASSERT_VALID( (&_tcsi.m_wndGrid) );
            _tcsi.m_nItemNoSelEndOK = wndListBox.GetCurSel();
            _tcsi.m_bHelperSelChanged = true;
            if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            {
                        LONG nItemCount = wndListBox.GetCount();
                        if( nItemCount > 0L )
                        {
                                    LONG nCurSel = wndListBox.GetCurSel();
                                    if( 0L <= nCurSel && nCurSel < nItemCount )
                                    {
                                                CString strSelLbText;
                                                wndListBox.GetText( nCurSel, strSelLbText );
                                                DWORD dwStyleEx = GetStyleEx();
                                                bool bSendSelEndOkOnEqualText = ( ( dwStyleEx & __EGCS_EX_DO_NOT_NOTIFY_LB_SEL_FOR_EQUAL_TEXT ) != 0 ) ? true : false;
                                                if( ! bSendSelEndOkOnEqualText )
                                                {
                                                            CExtSafeString strCurrentText;
                                                            TextGet( strCurrentText );
                                                            if( strCurrentText == LPCTSTR(strSelLbText) )
                                                                        return false;
                                                }
                                                DWORD dwFontWeight = (DWORD) wndListBox.GetItemData( nCurSel );
                                                CString strText;
                                                strText.Format( _T("%d"), int(dwFontWeight) );
                                                TextSet( LPCTSTR(strText) );
                                                _tcsi.m_wndGrid.OnGridCellInputComplete( *this, _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColType, _tcsi.m_nRowType, wndListBox.GetSafeHwnd() );
                                    } // if( 0L <= nCurSel && nCurSel < nItemCount )
                        } // if( nItemCount > 0L )
            } // if( (wndListBox.GetStyle()&LBS_HASSTRINGS) != 0 )
            return false;
}


Offer Har Dec 9, 2008 - 4:56 PM

Thanks


Will try that out - looks like exactly what I need.