Professional UI Solutions
Site Map   /  Register


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 » Custom button can't find its "parent" Collapse All
Subject Author Date
Takis Takoglou Apr 21, 2009 - 7:44 AM

Good day,

I am using your property grid and used a custom button within my grid using the OnButtonPressed() this way:

IMPLEMENT_SERIAL(ExtraProperties, PropertyValue, VERSIONABLE_SCHEMA|1 );

ExtraProperties::ExtraProperties(MyProperty *pProp)
	: PropertyValue(_T("More"), pProp)
	CustomButt *pValue = STATIC_DOWNCAST(CustomButt, ValueActiveGetByRTC( RUNTIME_CLASS(CustomButt)));
	pValue->ParentSet(this); //When this is initialized pValue->ParentProps is filled!

void ExtraProperties::Apply(CExtGridCell * pValue)
	PropertyValue::Apply( pValue );


CustomButt::CustomButt(CExtGridDataProvider * pDataProvider // = NULL
    : CExtGridCellButton( pDataProvider )

void CustomButt::OnButtonPressed(CExtGridWnd & wndGrid, INT nButtonType,
    const RECT & rcCellExtra, const RECT & rcCell, LONG nVisibleColNo, LONG nVisibleRowNo,
    LONG nColNo, LONG nRowNo, INT nColType, INT nRowType)
   ASSERT_VALID( this );   
   ASSERT_VALID( (&wndGrid) );    
   CExtGridCellButton::OnButtonPressed(wndGrid, nButtonType,	  
       rcCellExtra, rcCell, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo,	   
       nColType, nRowType); 
        this->ParentProps;//This should be the pointer to the PropertyValue but is NULL...


void CustomButt::ParentSet(ExtraProperties *par)
    this->ParentProps = par;

I have highlited the problem. I was expecting to find the pointer to the "parent" so i could use something like :

Propstore.ItemGetByName("Button1") or Propstore.ItemGetByName("Button2") etc. depending on which button i want to refer to was pressed.

Why is this happening? Is there any other way to overcome this? (Refere to the parent within the OnButtonPressed implementation)

Thanx in advance,



Technical Support Apr 22, 2009 - 11:34 AM

The CustomButt grid cell class should have the IMPLEMENT_ExtGridCell_Clone macro in class declaration. Please read this:
There is an example of grid cell code in this article (CMyCustomCell). Please note IMPLEMENT_DYNCREATE line should be placed at the very beginning of the CPP file before the debug version of MFC’s new operator. The CustomButt class should implement the CExtGridCell::Assign() virtual method which should detect whether the assignment query is from the grid cell of the same CustomButt type and assign it’s specific properties. For example, this is how the CExtGridCellHyperLink class in Prof-UIS implements this virtual method:

void CExtGridCellHyperLink::Assign( const CExtGridCell & other )
            ASSERT_VALID( this );
            CExtGridCellString::Assign( other );
CExtGridCellHyperLink * pCell = DYNAMIC_DOWNCAST( CExtGridCellHyperLink, ( const_cast < CExtGridCell * > ( &other ) ) );
            if( pCell != NULL )
                        // copy cell
                        m_clrTextVisited = pCell->GetTextColorVisited();
                        m_bHoverTextUnderline = pCell->GetTextHoverUnderline();
                        m_bAllowVisitedState = pCell->GetAllowVisitedState();
                        m_strURL = pCell->GetURL();
            } // if( pCell != NULL )
                        // clear cell
                        m_clrTextVisited = RGB( 128, 0, 128 );
                        m_bHoverTextUnderline = FALSE;
                        m_bAllowVisitedState = TRUE;
                        m_strURL = _T("");
            } // else if( pCell != NULL )