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 » Problem with CExtGridCellCheckBox class Collapse All
Subject Author Date
Nader Mimouni May 8, 2006 - 3:35 AM

Good Day,

I have a small problem with CExtGridCellCheckBox class and I’m not sure if this is a bug or not:
I’m using grid in a dialog box wich contain some cell that looks like check box (I used for that CExtGridCellCheckBox class ). Those check box were defined to use 3 state mode. But when trying to initialise the check box to inderminate value (within OnInitDialog function), it looks like not checked. This is work when I tried to initialize it to checked value (1). Also it works when trying to affect the inditerminate value outside the dialog initialization.

Thanks to check and advise!!
And many thanks for your support.

Technical Support May 10, 2006 - 5:30 AM

We guess the cell states were initialized correctly but you simply forgot to re-paint these cells. To repaint a particular grid cell, just invoke the following code:

LONG nColNo = . . . 
LONG nRowNo = . . .
CExtGridWnd * pWndGrid = . . .
CRect rcCellExtra;
    if( pWndGrid->GridCellRectsGet( nColNo, nRowNo, 0, 0, NULL, &rcCellExtra ) )
        pWndGrid->InvalidateRect( &rcCellExtra );


Nader Mimouni May 11, 2006 - 4:56 AM

Good Day,
Thanks for your responce. I tried your code but invain. The same problem persist.
Also, I’m sure that cell’s state and value were correctly initialized as I checked that in runtime.
And it’s important to note that the cell don’t reflect the indeterminate state only when setting the indeterminate value during dialog initialization.
And when trying this after initialization, it works !!
So, please I need your help on this.

Technical Support May 11, 2006 - 8:51 AM

We are sorry. This is really our bug. Please find the CExtGridCellCheckBox::SetCheck() method and update it with this code:

INT CExtGridCellCheckBox::SetCheck( 
            INT nCheck
            )
{
            ASSERT_VALID( this );
INT nCheckPrev = GetCheck();
            if( !(nCheck == 0 || nCheck == 1 || ( nCheck == 2 && m_b3StateMode )) )
            {
                        ASSERT( FALSE );
                        return nCheckPrev;
            }
DWORD dwCellStyle = GetStyle();
            if( (dwCellStyle&__EGCS_READ_ONLY) != 0 )
                        return nCheckPrev;

            DWORD dwStyleAdd = 
                        nCheck == 1 
                                    ? __EGCS_CHECKED 
                                    : nCheck == 2 
                                                ? (__EGCS_CHK_INDETERMINATE|__EGCS_CHECKED)
                                                : 0;
            DWORD dwStyleRemove = 
                        nCheck == 0
                                    ? __EGCS_CHECKED
                                    : 0;
            
            dwStyleAdd |= __EGCS_CHK_CHECK;
            dwStyleRemove |= __EGCS_CHK_MASK;

            ModifyStyle( 
                        dwStyleAdd,
                        dwStyleRemove
                        );
            
            return nCheckPrev;
}