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 » Can't set CExtGridWnd cell selection color Collapse All
Subject Author Date
Krustys Donuts Jan 10, 2006 - 8:46 AM

I’ve searched on the forums, and the only method I could find is BackColorSet, passing in the constant CExtGridCell::__ECS_SELECTED. So if I call

pCell->BackColorSet( CExtGridCell::__ECS_SELECTED, RGB(0,0,0));


I would expect the highlight to be black (not that I’d every use this for real...). The reason I want to change the color is that the default dark blue makes black text hard to read. Ideally, I’d like to have the text color invert or something when selected.

So in summary, I guess I have a few questions:
1. Is BackColorSet the right way to change the selection color?
2. How can I change the foreground color when a cell is selected? I take it that I’ve have to handle the message for a selection, and then tell the cell to change its foreground color
3. The docs somewhere say that v2.42 and later use BackColorGet. My code was written before 2.42, and to change cell text color, I override OnQueryTextColor and OnPaintBackground. Was there an old-style way to change the selection color, just for comparison / testing purposes?

Krustys Donuts Jan 10, 2006 - 9:01 AM

Some more info: I thought that maybe the overrides were messing things up, so I commented out that code, and tried to use TextColorSet and BackColorSet exclusively. No matter what combination of colors or cell states I use, nothing seems to work.

Krustys Donuts Jan 10, 2006 - 9:18 AM

Ok, so it turns out that it didn’t work because my derived cell class inherited from CExtGridCellStringDM, instead of CExtGridCellString. Can you explain why the latter works? The only difference between the two *seems* to be the text string member in the former.

Krustys Donuts Jan 10, 2006 - 9:31 AM

I’ve got it working to my liking right now, but the one catch with the TextColorSet method is that once you change it, it also changes the background color to the same color!

I couldn’t just do this and retain the default blue selection background:

pCell->TextColorSet( CExtGridCell::__ECS_SELECTED, RGB(255,255,255));


But instead, had to do this:

pCell->TextColorSet( CExtGridCell::__ECS_SELECTED, RGB(255,255,255));
pCell->BackColorSet( CExtGridCell::__ECS_SELECTED, RGB(32,0,255));


Could you please explain this behavior, as well as my other question in the previous post? Thank you!

Technical Support Jan 11, 2006 - 2:52 AM

You need to use the CExtGridCell::__ECS_NORMAL constant.

Technical Support Jan 10, 2006 - 11:35 AM

The CExtGridCell class does not hold text/background colors. It’s a kind of lightweight class used by other derived classes. We added the CExtGCC template that allows a CExtGridCell-derived class to hold these values. CExtGCC template is designed to decorate any CExtGridCell-derived class. It allows you to specify text and background colors.

We also added the CExtGridCellEx class which implements a cell which is usually used as a base class for other cell objects with custom text and background colors and a custom hover cursor. The CExtGridCellString class derived from CExtGridCellEx and CExtGridCellStringDM does not.