|
|
|
|
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 |
|
Mac Will
|
Jan 3, 2006 - 9:57 AM
|
Hello, In a grid I am looking to highlight multiple rows (2) at a time. i.e. I have objects that span 2 rows and I have overiden OnGbwSelectionChanged so that i can select objects (i.e. 2 rows) but I would also like to highlight objects in stead of rows when the mouse passes over the grid. Thanks
|
|
Mac Will
|
Jan 5, 2006 - 11:42 AM
|
Hi, sorry but i think i need a few lines of code as an example. right now I am trying to do this from my grid class in the fucntion OnGbwPaintCell do i need to also work from my dereived cell classes? just so it is clear. what i want is for when the mouse is hovering ontop a (for example) row 2 that both row 2 and 3 change background color. just a few lines and i should be able to figure it out. Also is it possible to change the color the the row changes to when the mouse is hovering over it? Thanks for your patience.
P.S. I am using prof-uis 2.5 full version
|
|
Technical Support
|
Jan 6, 2006 - 2:36 AM
|
Here we will describe how to highlight rows 1 and 2 when row 0 is hovered by the mouse. Please create a CExtGridWnd -derived class and override the CExtGridWnd::OnGbwPaintCell() virtual method: void CYourGrid::OnGbwPaintCell(
CDC & dc,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
const RECT & rcCellExtra,
const RECT & rcCell,
const RECT & rcVisibleRange,
DWORD dwAreaFlags,
DWORD dwHelperPaintFlags
) const
{
CPoint point;
::GetCursorPos( &point );
::ScreenToClient( &point );
CExtGridHitTestInfo htInfo( point );
HitTest( htInfo, false, true );
if( htInfo.m_nRowNo == 0 && ( nRowNo == 1 || nRowNo == 2 ) )
dwHelperPaintFlags |= __EGCPF_HOVER_BY_COLUMN | __EGCPF_HOVER_BY_ROW;
CExtGridWnd::OnGbwPaintCell(
dc,
nVisibleColNo,
nVisibleRowNo,
nColNo,
nRowNo,
rcCellExtra,
rcCell,
rcVisibleRange,
dwAreaFlags,
dwHelperPaintFlags
);
} It is not a problem to provide you with a sample application but it would be convenient to receive a startup project with the grid control from you first.
|
|
Mac Will
|
Jan 4, 2006 - 12:24 PM
|
I am affraid I don’t understand. If I change dwHelperPaintFlags to any of those values or combination of those values than my entire grid becomes permanently highlighted. I want objects to be higlighted when the mouse passes over them I need what this does for one row to happen for two rows __EGBS_EX_HVI_HIGHLIGHT_ROWS. What am I doing wrong? Thanks
|
|
Technical Support
|
Jan 5, 2006 - 10:50 AM
|
The OnPaintBackground virtual method has parameters nColNo and nRowNo for determining which cell is painted. If nRowNo is a row which should be additionally painted, then call the parent method with passing a modified value for dwHelperPaintFlags . Otherwise simply invoke the parent method.
|
|
Technical Support
|
Jan 4, 2006 - 11:49 AM
|
You can override the following virtual method in your CExtGridWnd -derived class: virtual void OnGbwPaintCell(
CDC & dc,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
const RECT & rcCellExtra,
const RECT & rcCell,
const RECT & rcVisibleRange,
DWORD dwAreaFlags,
DWORD dwHelperPaintFlags
) const; In your method, just call the parent method with passing a modified dwHelperPaintFlags value. This allows you to highlight custom cell areas. Here is the list of flags used in the dwHelperPaintFlags parameter, which are defined in the ExtGridWnd.h file: // values for dwHelperPaintFlags parameter of:
// CExtGridBaseWnd::OnGbwPaintCell()
// CExtGridCell::OnPaintBackground()
// CExtGridCell::OnPaintForeground()
// column of the cell is hovered
#define __EGCPF_HOVER_BY_COLUMN 0x00000001L
// row of the cell is hovered
#define __EGCPF_HOVER_BY_ROW 0x00000002L
// column of the cell contains at least one selected cell
#define __EGCPF_HIGHLIGHTED_BY_SELECTED_COLUMN 0x00000004L
// row of the cell contains at least one selected cell
#define __EGCPF_HIGHLIGHTED_BY_SELECTED_ROW 0x00000008L
// column of the cell contains focused cell
#define __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN 0x00000010L
// row of the cell contains focused cell
#define __EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW 0x00000020L
// grid control or any kind of its child window is focused
#define __EGCPF_FOCUSED_CONTROL 0x00000040L
// cell is highlighted by pressed row/column
#define __EGCPF_HIGHLIGHTED_BY_PRESSED_COLUMN 0x00000080L
#define __EGCPF_HIGHLIGHTED_BY_PRESSED_ROW 0x00000100L
// painting dragged outer cell content
#define __EGCPF_OUTER_DND 0x00000200L Use the first two of them.
|
|