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 cell focus problem Collapse All
Subject Author Date
Offer Har Mar 30, 2008 - 12:03 PM

I have a grid, in which I need to highlight certain cells from some rules.

I do it by calling BackColorSet on those cells. I only set the __ECS_NORMAL state, because I do want the focus cell to be distinguished.


My problem is when the grid loses focus - the focus cell is displayed in the normal back-color (default is white) and not in the colot is set as its background color for normal display. It seems that this cell still have the focus attributes, but is painted as a normal cell. It would be wiser that if the grid has not focus, and the focus cell does not look differently then other cell, that it would be painted with the normal back color, and not some color I don’t even know where to set.




Below are two images depicting the problem:


Offer Har Mar 31, 2008 - 12:01 PM

Dear Support,


I will try this out at the grid level, however, how do I set the back color for a focus cell when the grid has no focus? and why isn’t it one of the 4 __ECC*** values?


Ron.


 

Technical Support Apr 1, 2008 - 4:28 AM

The virtual methods we mentioned in our previous answer in this thread will be invoked during painting of all the visible grid cells independently of the the focused state of the grid window.

We would like to keep the custom coloring constants as simple as possible. Typically they are needed for highlighting some specific part of the grid window and they do their work. Of course, we can increase the number of these constants at least by eight times: for selected and/or focused state of grid cells with intersection with the focused state of grid control. But we are not sure if this would be convenient to specify such a number of colors for each grid cell.

Offer Har Apr 1, 2008 - 6:10 AM

Keeping is simple as possible would mean that the back color of a focused cell when the grid has no focus would be taken from the same color set for a normal cell - currently the user cannot set this color for the cell at all when calling BackColorSet.


I did however solve my problem using OnGridCellQueryBackColor as you suggested and having this test in it for the focus cell:



      CPoint ptFocus = FocusGet();

        // If in focus row, and not focus cell, or grid has no focus:
        if (nRowNo==ptFocus.y && (nColNo!=ptFocus.x || (__EGCPF_FOCUSED_CONTROL&dwHelperPaintFlags)==0))
        {
            return MY_CUSTOM_COLOR;
        }

This line colors the current row with a custom color, leaving the focus cell with its color if the grid have focus.


Thanks,


Ron.

Technical Support Mar 31, 2008 - 11:57 AM

The following methods allow you to customize how a certain cell(s) looks (you should override them): the CExtGridCell::OnQueryTextColor() / CExtGridCell::OnQueryBackColor() methods in your grid cell class (at a cell level) or the CExtGridWnd::OnGridCellQueryTextColor() / CExtGridWnd::OnGridCellQueryBackColor() virtual method in your grid window class (at a grid level). The dwHelperPaintFlags parameter in both methods contain a set of __EGCPF_*** flags that describe the details about the state of a grid cell and a grid window.