|
|
|
|
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.
Subject |
Author |
Date |
|
Tor Erik Ottinsen
|
Oct 14, 2005 - 4:37 AM
|
I have a CExtGridWnd with the __EGBS_EX_CORNER_AREAS_3D style set, and with custom colors for outer cells. Is it possible to draw the corner cells with the same colors as the outer cells?
|
|
Technical Support
|
Oct 14, 2005 - 5:41 AM
|
To repaint corner areas in the grid window, you need to override the CExtGridBaseWnd::OnGbwEraseArea() virtual method. Here is a sample code snippet which can be used as a start up version of your method: void CYourGridWindow::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;
} // switch( dwAreaFlags )
if( clrDebugFill != COLORREF( -1L ) )
dc.FillSolidRect( &rcArea, clrDebugFill );
}
|
|
Tor Erik Ottinsen
|
Oct 14, 2005 - 6:13 AM
|
Thank you very much, that did the trick. A couple of more questions: 1) How can i write some text to a corner cells? I would like the outer column have a title just like the rest. 2) Is it possible to change the color of the 3D-border on the outer cells? When using another bacckground color than the default, I would like to use custom colors for the 3D border as well.
|
|
Technical Support
|
Oct 14, 2005 - 7:57 AM
|
In fact, there are no cell objects in the corner areas. You need to paint text in these areas directly. You can implement your own CExtGridCellHeader -derived class that has a custom background and/or borders. What you need to do is to override the CExtGridCell::OnPaintBackground() method in your cell class and paint a background using the rcCell parameter (which species the cell rectangle). If this method returns false , the default background is painted. Otherwise, the grid window assumes your code implements a custom background.
|
|
Tor Erik Ottinsen
|
Oct 14, 2005 - 6:33 AM
|
I found the answer to question number 2 myself. I just overrided OnSiwGetSysColor().
|
|