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 » Property Grid Customisation Collapse All
Subject Author Date
Michael Valentine Nov 4, 2005 - 9:25 AM

I want to alter the look and behaviour of the property grid slightly. I would like to know how to:


1) Change the background colour and text colour of categories, that is CExtPropertyCategory elements only, not other property cells.


2) Allow for single click to expand categories, at present they are expanded on double click.


3) Allow the mouse wheel to be used in the numeric up/down grid cells to adjust their values.


 


Thanks.

Technical Support Nov 7, 2005 - 6:30 AM

The mouse-wheel input is available in Prof-UIS 2.50. The CExtGridCellUpDown class uses it by default. The CExtGridCellComboBox also supports the mouse-wheel input, when the enumeration mode is turned on by invoking the SetEnumMode() method.

You can alter the text/background color by overriding the CExtPropertyGridCtrl::OnPgcCreateGrids() virtual method in a CExtPropertyGridCtrl-derived class. This method should be the same as the original one except for creating your version of the categorized tree grid window. In your CExtPropertyGridWndCategorized()-derived class, please implement the CExtGridWnd::OnGridCellQueryFont(), CExtGridWnd::OnGridCellQueryTextColor() and/or CExtGridWnd::OnGridCellQueryBackColor() to customize appearance of the grid cells. If the nColType and nRowType parameters of these methods are equal to zero, the nColNo parameter specifies the column index of the property (0 - name column and 1 - value column) and the nRowNo parameter specifies the row index in the tree grid. You can get a CExtPropertyItem pointer for the nRowNo row using the following code:

HTREEITEM hTreeItem =
    ItemGetByVisibleRowIndex( nRowNo );
if( hTreeItem != NULL )
{
    const CExtPropertyItem * pPropertyItem =
        PropertyItemFromTreeItem( hTreeItem );
    if( pPropertyItem != NULL )
    {
        . . .
pPropertyItem can be either a CExtPropertyValue or CExtPropertyCategory object. So, you can detect whether you need to return font and color parameters for property values or for categories. You can even use different appearance for name and value columns.

To change the mouse click behavior, just override the CExtTreeGridWnd::OnGbwAnalyzeCellMouseClickEvent() method like as follows:
bool CYourCatgorizedGridWnd::OnGbwAnalyzeCellMouseClickEvent(
    UINT nChar, // VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only
    UINT nRepCnt, // 0 - button up, 1 - single click, 2 - double click, 3 - post single click & begin editing
    UINT nFlags, // mouse event flags
    CPoint point // mouse pointer in client coordinates
    )
{
    if( nChar == VK_LBUTTON && nRepCnt == 1 )
    {
        CExtGridHitTestInfo htInfo( point );
        HitTest( htInfo, false, true );
        INT nColType = htInfo.GetInnerOuterTypeOfColumn();
        INT nRowType = htInfo.GetInnerOuterTypeOfRow();
        if(        (! htInfo.IsHoverEmpty() ) && htInfo.IsValidRect()
             && nColType == 0 && nRowType == 0
             )
        {
            HTREEITEM hTreeItem =
                ItemGetByVisibleRowIndex( nRowNo );
            if( hTreeItem == NULL )
            {
                const CExtPropertyItem * pPropertyItem =
                    PropertyItemFromTreeItem( hTreeItem );
                if(         pPropertyItem != NULL
                    &&   pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyCategory) )
                    )
                {
                    OnTreeGridToggleItemExpandedState(
                        htInfo.m_nRowNo, &htInfo );
                    return true;
                }
            }
        }
    }
    return
        CExtPropertyGridWndCategorized::OnGbwAnalyzeCellMouseClickEvent(
            nChar, nRepCnt, nFlags, point );
}