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 » Using CExtPropertyGrid with non-static MFC objects Collapse All
Subject Author Date
Evgeny Mankov Jun 25, 2007 - 5:34 AM

Hello,

In example of using CExtPropertyGrid "CompoundProperies", at first, you created CExtPropertyStore by the GetPropertyStore method. All properties of CCanvasObject was modified through the CExtPropertyGrid control. I need to modify internal properties of MyObject by few ways: 1) by the CExtPropertyGrid, 2) by the code in my program (it’s may be handling of some event).

For solving porblem #1, I implemented myself CExtPropertyValue clase on base CExtPropertyValue and overrided constructor and Apply methods as in SimpleProperties example. How to correctly solve the second problem? MyObject class has GetPropertyStore method, which return CExtPrpertyStore object. And now, If the internal properies of MyObjec was changed by the some event, I want to present new properies in CExtPropertyGrid.

How to do it?

Thank you.

Technical Support Jun 25, 2007 - 1:53 PM

You can programmatically update your data objects, put the data into the active grid cells in the property value(s). This means the content of the property tree will correspond to the latest state of your object. But the tree grid controls inside the property grid control contain cloned copies of the active grid cells stored in each CExtPropertyValue object. So finally you should invoke the CExtPropertyGridCtrl::PropertyStoreSynchronize() method to update the content of the property grid.

Svetlozar Kostadinov Jun 26, 2007 - 10:46 AM

And is there some way to optimize the speed of synchronization? Something like synchronization of only the property which is changed. Because if I have an object with 20 properties & compound properties and modify them in realtime, then the speed becomes a problem. I know in release builds the speed will get notable boost, but I’m not sure if it will be sufficient.

Technical Support Jun 27, 2007 - 10:42 AM


It is possible to access to tree items of tree grid windows inside the property grid controls and modify them directly. The following code demonstrates how to do this:

CExtPropertyGridCtrl & _PGC = . . .
CExtPropertyValue * pModifiedPropertyValue = . . .
CExtGridCell * pModifiedCell = pPropertyValue->ValueActiveGet() ;
      ASSERT_VALID( pModifiedCell );
CTypedPtrArray < CPtrArray, CExtPropertyGridWnd * > arrGrids;
    _PGC.OnPgcQueryGrids( arrGrids );
INT nGridIdx = 0, nGridCount = INT( arrGrids.GetSize() );
    for( ; nGridIdx < nGridCount; nGridIdx ++ )
    {
        CExtPropertyGridWnd * pGrid = arrGrids[ nGridIdx ];
        ASSERT_VALID( pGrid );
        HTREEITEM hTreeItem = pGrid->PropertyItemToTreeItem( pModifiedPropertyValue );
        if( hTreeItem == NULL )
            continue;
        CExtGridCell * pGridCellToAssign = pGrid->ItemGetCell( hTreeItem, 1 );
        if( pGridCellToAssign == NULL )
            continue;
        ASSERT_VALID( pGridCellToAssign );
        pGridCellToAssign ->Assign( pModifiedCell );
        if( (pGrid->GetStyle()&WS_VISIBLE) == 0 )
            continue;
        LONG nRowNo = pGrid->ItemGetVisibleIndexOf( hTreeItem );
        if( nRowNo < 0 )
            continue;
        CRect rc;
        if( pGrid->GridCellRectsGet( 1, nRowNo, 0, 0, NULL, &rc ) )
        {
            CRect rcClient;
            pGrid->GetClientRect( &rcClient );
            rc.left = rcClient.left;
            rc.right = rcClient.right;
            pGrid->InvalidateRect( &rc );
        }
    }