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 » Grid Columns Collapse All
Subject Author Date
Eddie Judson Jun 30, 2005 - 7:28 AM

If I have:

OuterRowCountTopSet( 1L, false );


OuterColumnCountLeftSet( 1L, false );


Is there anyway I can access the cell at the top left (intersection of the outer column and outer row) so I can downcast it to my own class?  Also I don’t spose you have any sample code that autosizes columns to the width of the text ?


Regards,


   Eddie

Eddie Judson Jul 4, 2005 - 8:25 PM

Thanks for the quick reply.  The reason I wanted to know was that I want to put a CExtDateTimeWnd control in the top left outer cell.  Is it possible to get a copy of the

CPageDateTimeDuration class from the samples as I can not find it in the source for the samples.


 

Technical Support Jul 5, 2005 - 12:52 PM

The CPageDateTimeDuration and CExtDateTimeWnd classes are available in Prof-UIS 2.40 which you can download right now. To put them into corners, just create their windows in appropriate positions of your grid window. You should also reposition them when the grid size is changed. This requires creation of your CExtGridWnd-derived class and implementing the CExtGridWnd::OnSwRecalcLayout() virtual method which should invoke the parent’s method and move your controls into grid corners in case of the bDoLayout parameter is true.

Technical Support Jun 30, 2005 - 12:44 PM

The grid control does not display cell objects in corners but you can repaint them if you need to display some information there. You should override the CExtGridBaseWnd::OnGbwEraseArea() virtual method like as follows:

void C_YOUR_GridWnd::OnGbwEraseArea(
    CDC & dc,
    const RECT & rcArea,
    DWORD dwAreaFlags
    ) const
{
    ASSERT_VALID( this );
    ASSERT( dc.GetSafeHdc() != NULL );
COLORREF clrDebugFill = COLORREF( -1L );
    switch( dwAreaFlags )
    {
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_TOP:
        clrDebugFill = RGB( 255, 128, 128 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_BOTTOM:
        clrDebugFill = RGB( 128, 255, 128 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_LEFT:
        clrDebugFill = RGB( 128, 128, 255 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_RIGHT:
        clrDebugFill = RGB( 128, 255, 255 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_LEFT|__EGBWA_OUTER_TOP:
        clrDebugFill = RGB( 255, 128, 255 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_LEFT|__EGBWA_OUTER_BOTTOM:
        clrDebugFill = RGB( 255, 255, 128 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_RIGHT|__EGBWA_OUTER_TOP:
        clrDebugFill = RGB( 255, 255, 128 );
    break;
    case __EGBWA_OUTER_CELLS|__EGBWA_OUTER_RIGHT|__EGBWA_OUTER_BOTTOM:
        clrDebugFill = RGB( 128, 128, 128 );
    break;
    case __EGBWA_INNER_CELLS:
        clrDebugFill = RGB( 255, 255, 224 );
    break;
    }
    if( clrDebugFill != COLORREF( -1L ) )
        dc.FillSolidRect( &rcArea, clrDebugFill );
}
This sample code allows you to see the areas of the grid window highlighted with custom colors.

If you have a pointer to the CExtGridCell object, you can downcast its type dynamically using MFC’s DYNAMIC_DOWNCAST macro:
CExtGridCell * pCell = . . .
CExtGridCellHeader * pHeaderCell =
    DYNAMIC_DOWNCAST(
        CExtGridCellHeader,
        pCell
        );
The pHeaderCell pointer will be NULL if the pCell pointer does not point to a CExtGridCellHeader object. This does not depend on the cell location in the grid window.