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 General Discussion » CExtGridCellUpDown Increment/Decrement Problem Collapse All
Subject Author Date
CompSys Engineer Jan 25, 2010 - 7:25 AM

I have a custom class that inherits from CExtGridCellUpDown and have overridden the necessary functions. This custom class works correctly using ProfUIS 254. When I changed to ProfUIS 283, clicking the up/down spinner control arrows no longer trigger the OnValueIncrement()/OnValueDecrement() callbacks in my custom class. Can you please advise if this is a bug or if this code works differently in version 283? If this is not a bug, what do I need to change in my existing code to get this to work correctly with the new libraries?


Regards.

Technical Support Jan 26, 2010 - 1:44 PM

Most of grid cells use the decrement/increment enabled state checking methods provided by the CExtGridCell class:

bool CExtGridCell::OnQueryEnabledDecrement(
            const CExtGridWnd & wndGrid,
            LONG nColNo,
            LONG nRowNo,
            INT nColType,
            INT nRowType
            ) const

But the CExtGridCellVariant-based classes use the following version:
bool CExtGridCellVariant::OnQueryEnabledDecrement(
            LPCVARIANT pvarValue,
            const CExtGridWnd & wndGrid,
            LONG nColNo,
            LONG nRowNo,
            INT nColType,
            INT nRowType
            ) const

CompSys Engineer Jan 27, 2010 - 8:22 AM

The previous reply is not clear. I already know which version is being used as the particular cells in this subject are derived from the CExtGridCellVariant class. The custom class definition is as follows:


class CMyGridCellUpDown : public CExtGridCellUpDown

{   

public:

    DECLARE_DYNCREATE( CMyGridCellUpDown );

    IMPLEMENT_ExtGridCell_Clone( CMyGridCellUpDown, CExtGridCellUpDown );

    CMyGridCellUpDown(

        CExtGridDataProvider * pDP = NULL

    );



    virtual bool OnQueryEnabledIncrement() const

    {

        // custom stuff

        return false;

    };

    virtual bool OnQueryEnabledDecrement() const

    {

        // custom stuff

        return false;

    };

    virtual bool OnValueDecrement()

    {

        // custom stuff

        return true;

    }

    virtual bool OnValueIncrement()

    {

        // custom stuff

        return true;

    }

    virtual void TextGet( CString &strCopy ) const

    {

        // custom stuff

    }

    virtual bool OnInplaceControlTextInputVerify(

        HWND hWndInplaceControl,

        CExtGridWnd & wndGrid,

        LONG nVisibleColNo,

        LONG nVisibleRowNo,

        LONG nColNo,

        LONG nRowNo,

        INT nColType,

        INT nRowType,

        LPCTSTR sTextInitial,

        LPCTSTR sTextPrevious,

        CString & sTextNew,

        bool bEndEdit

    ) const

    {

        return true;

    }

};


Why would these 2.54 callbacks no longer be called in 2.83?

Technical Support Jan 27, 2010 - 1:09 PM

Here is the fixed version of your class:

class CMyGridCellUpDown : public CExtGridCellUpDown
{    
public:
            DECLARE_SERIAL( CMyGridCellUpDown );
            IMPLEMENT_ExtGridCell_Clone( CMyGridCellUpDown, CExtGridCellUpDown );
            CMyGridCellUpDown( CExtGridDataProvider * pDP = NULL ) : CExtGridCellUpDown( pDP ) { }
            virtual bool OnQueryEnabledIncrement(
                        const CExtGridWnd & wndGrid,
                        LONG nColNo,
                        LONG nRowNo,
                        INT nColType,
                        INT nRowType
                        ) const
            {
                        // custom stuff
                        return false;
            }
            virtual bool OnQueryEnabledDecrement(
                        const CExtGridWnd & wndGrid,
                        LONG nColNo,
                        LONG nRowNo,
                        INT nColType,
                        INT nRowType
                        ) const
            {
                        // custom stuff
                        return false;
            };
            virtual bool OnValueDecrement(
                        CExtGridWnd & wndGrid,
                        LONG nColNo,
                        LONG nRowNo,
                        INT nColType,
                        INT nRowType
                        )
            {
                        // custom stuff
                        return true;
            }
            virtual bool OnValueIncrement(
                        CExtGridWnd & wndGrid,
                        LONG nColNo,
                        LONG nRowNo,
                        INT nColType,
                        INT nRowType
                        )
            {
                        // custom stuff
                        return true;
            }
            virtual void TextGet( CExtSafeString & strCopy ) const
            {
                        // custom stuff
            }
            virtual bool OnInplaceControlTextInputVerify(
                        HWND hWndInplaceControl,
                        CExtGridWnd & wndGrid,
                        LONG nVisibleColNo,
                        LONG nVisibleRowNo,
                        LONG nColNo,
                        LONG nRowNo,
                        INT nColType,
                        INT nRowType,
                        __EXT_MFC_SAFE_LPCTSTR sTextInitial,
                        __EXT_MFC_SAFE_LPCTSTR sTextPrevious,
                        CExtSafeString & sTextNew,
                        bool bEndEdit
            ) const
            {
                        return true;
            }
};



CompSys Engineer Jan 27, 2010 - 1:40 PM

Aha! Excellent. Thanks.

CompSys Engineer Jan 26, 2010 - 5:48 AM

The cells are being initialized with _VariantAssign() in OnInitDialog. As I stated, the code works correctly using version 2.54. This unchanged code no longer works when using 2.83. In other words, something in 2.83 related to these classes has changed from 2.54, for good or bad, and is causing the problem. Please advise.

Technical Support Jan 25, 2010 - 1:47 PM

The CExtGridCellUpDown class is a CExtGridCellNumber class with up-down buttons displayed. If the up-down buttons does not work, then you didn’t initialize the number cell with some numeric value. I.e. you didn’t invoke code like this:

CExtGridCellUpDown * pGridCellUpDown = . . .
            pGridCellUpDown->_VariantAssign( 123, VT_I4 );

CompSys Engineer Jan 26, 2010 - 5:49 AM

The cells are being initialized with _VariantAssign() in OnInitDialog. As I stated, the code works correctly using version 2.54. This unchanged code no longer works when using 2.83. In other words, something in 2.83 related to these classes has changed from 2.54, for good or bad, and is causing the problem. Please advise.

CompSys Engineer Jan 26, 2010 - 6:34 AM

Additional info: The OnQueryEnabledIncrement() and OnQueryEnabledDecrement() callbacks are not triggered. These should be called just by moving or hovering the mouse over the grid or cell.