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 » Left click vs Right click on a cell Collapse All
Subject Author Date
Offer Har Mar 6, 2009 - 6:11 AM

Dear Support,


I’m implementing much custom cell, and I need to override OnPaintText, and I need to know when a cell is in focus, so that I will paint its text in light color, because the focused cell has a blue background.


However, I see that when I right click or left click on a cell, in both cases, __EGCPF_FOCUSED_CONTROL is set, but when I right-click on a cell, you do not chane its background to blue, you just draw the dotted line around the cell.


Is there any other way of knowing when you decide to change the color of the cell?


Thanks,


Ron.

Technical Support Mar 9, 2009 - 10:38 AM

There is a set of the __EGCPF_*** flags defined in the .../Prof-UIS/Include/ExtGridWnd.h file. These flags are used in the dwHelperPaintFlags parameter of many methods of grid cell and controls classes. The __EGCPF_FOCUSED_CONTROL flag indicates the focused state of the grid control - not the focused state of some cell. This flags allows to implement selection painting. When the grid window is focused, then all the selected cells are using the white text on dark blue background. This is not the only flag you need. The __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN flag indicates whether the grid cell is in the same column with the focused grid cell. The __EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW flag indicates whether the grid cell is in the same row with the focused grid cell. You need to check presence of both __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN|__EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW flags if the individual cells can be focused in your grid window. You need to check presence of the __EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW flag if your grid window is based on the full row focus and selection model.

Offer Har Mar 9, 2009 - 10:57 AM

Dear Support,


I tried this in my cell’s OnPaintText function:



    CPoint pt = wndGrid.FocusGet();
    if (pt.x==nColNo && pt.y==nRowNo && (dwHelperPaintFlags&(__EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN|__EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW)))
    {
        // I have blue background
    }
    else
    {
        // I have white background
    }

But now, I always get to the I have white background. Before I got to the I have blue bakcground if the cell was focused, even if it was right-clicked, which did not change the background color.


What am I doing wrong?


Thanks,


Ron.

Technical Support Mar 10, 2009 - 5:41 AM

The conditional statement is incorrect. It should be ( dwHelperPaintFlags & ( __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN | __EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW ) ) == ( __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN | __EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW ). I.e. both flags should be present. If both flags are present, then you should paint the selected background if the __EGCPF_FOCUSED_CONTROL flag is present (i.e. if the grid window is focused). If the __EGCPF_FOCUSED_CONTROL is absent, then you can draw dark gray background or not to draw any background depending on whether your grid has the "show selection always" style (CExtGridBaseWnd::NoHideSelectionGet()).