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 |
|
Cyndi Chatman
|
Feb 13, 2007 - 8:08 AM
|
I am using the silver theme, with CExtReportGridWnd controls on a CDialog (as I do not want the theme on the background of my dialog). I am trying to set an alternating row color in my grid, using the function
pCell->BackColorSet(CExtGridCell::e_cell_state_t::__ECS_NORMAL,RGB(255,0,0));
but there is no affect. What am I doing wrong?
|
|
Gunasekaran Velu
|
Feb 13, 2007 - 10:16 PM
|
.cpp file
bool CDemoGrid::OnGridHookCellPaintBackground(const CExtGridCell & _cell, CDC & dc, LONG nVisibleColNo, LONG nVisibleRowNo, LONG nColNo, LONG nRowNo, INT nColType, INT nRowType, const RECT & rcCellExtra, const RECT & rcCell, const RECT & rcVisibleRange, DWORD dwAreaFlags, DWORD dwHelperPaintFlags ) const { ASSERT_VALID( this ); CExtReportGridWnd::OnGridHookCellPaintBackground(_cell, dc, nVisibleColNo, nVisibleRowNo, nColNo, nRowNo, nColType, nRowType, rcCellExtra, rcCell, rcVisibleRange, dwAreaFlags, dwHelperPaintFlags );
COLORREF clrBk; if ( nRowType < 0) { clrBk =RGB(200, 241, 252 ); } if ( nRowNo == 0 && nRowType ==0) { if (nRowNo==m_SelRow) clrBk =RGB(255,140,85); else clrBk =RGB(255,255,255); } if ( nRowNo > 0 ) { if ( (nRowNo%2)==0 ) {clrBk =RGB(255,255,255);} else {clrBk =RGB(140,255,255);} if (m_SelRow>=0) { if (nRowNo==m_SelRow) {clrBk =RGB(255,140,85);} } } dc.FillSolidRect( &rcCell, clrBk ); return true; }
.h file
class CDemoGrid : public CExtReportGridWnd { public: CDemoGrid(); ~CDemoGrid(); virtual bool OnGridHookCellPaintBackground( const CExtGridCell & _cell, CDC & dc, LONG nVisibleColNo, LONG nVisibleRowNo, LONG nColNo, LONG nRowNo, INT nColType, INT nRowType, const RECT & rcCellExtra, const RECT & rcCell, const RECT & rcVisibleRange, DWORD dwAreaFlags, DWORD dwHelperPaintFlags ) const; }
|
|
Cyndi Chatman
|
Feb 14, 2007 - 8:24 AM
|
THANKS! Works great. But, how do you set m_SelRow?
|
|
Gunasekaran Velu
|
Feb 14, 2007 - 9:27 PM
|
hi just leave it the variable... comment the line ...
|
|
Technical Support
|
Feb 14, 2007 - 12:29 PM
|
You can determine if a grid cell is selected using the CExtGridBaseWnd::SelectionGetForCellPainting() . If you need which cell/row/column is focused, you can use CExtGridBaseWnd::FocusGet() .
|
|