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 » Keyboard-input in a CExtGrid crashes application. Collapse All
Subject Author Date
Arjan Nov 13, 2009 - 6:34 AM

Keyboard-input in a CExtGrid crashes application.

To be more precise, we’re using a CExtTreeGridWnd.
Cells are of the class CExtGridCellString.
Styled applied to the cell is __EGCS_NO_INPLACE_CONTROL.

When a cell is selected and there’s keyboard input, nothing should happen.
However, the effect is that the application crashes.

We discovered the problem to be caused in CExtGridWnd::OnGbwBeginEdit (file "ExtGridWnd.cpp").
Eventualy theres the following code in that routine:
    if( strStartEditText != NULL )
    {
        bool bSetText = true;
        TCHAR strClassName[512];
        ::GetClassName( m_hWndInplaceControl, strClassName, 512 );
        if( _tcslen( strClassName ) > 0 )
        {
....etc.

What happens is that there is no InplaceControl, which implies m_hWndInplaceControl==NULL.
This also implies that GetClassName does nothing.
This also implies that strClassName is undefined/uninitialized.
This also implies that ( _tcslen( strClassName ) > 0 ) is undefined.

A simple solution would be, the make sure strClassName is always initialized with an empty string.
We’ve changed the code to the following:        
        TCHAR strClassName[512];
        strClassName[0] = 0;
        ::GetClassName( m_hWndInplaceControl, strClassName, 512 );

Eventhough this seems to work, the real question ofcourse is why we’re even in this part of the routine since m_hWndInplaceControl==NULL.
Perhaps this is something to take in consideration in a new release of ProfUIS.


Kind regards,
Arjan Lukkesen
Ellips B.V.


Technical Support Nov 13, 2009 - 1:42 PM

Thank you very much for reporting us this issue. Here is the corrected part of the CExtGridWnd::OnGbwBeginEdit() method:

   if(                     strStartEditText != NULL
                        &&        _tcslen( strStartEditText ) > 0
                        &&        m_hWndInplaceControl != NULL
                        &&        ::IsWindow( m_hWndInplaceControl )
                        )
            {
                        bool bSetText = true;
                        TCHAR strClassName[512+1];
                        ::memset( &strClassName, 0, sizeof(strClassName) );
                        ::GetClassName( m_hWndInplaceControl, strClassName, 512 );
                        if( _tcslen( strClassName ) > 0 )
                        {