Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Color for highlighted row in grid
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00530979
Message ID:
00531297
Views:
10
This message has been marked as the solution to the initial question of the thread.
Hi Joel,

Here's a bit of really obtuse code that does exactly what you're after. Lisa Slater-Nicholls presented this at a conference in Sydney about 5 years ago. It uses the oft-forgotten fact that VFP populates colorscheme 15 (as well as 13 and 14) from the display properties colours, and then does some string manipulation to grab the RGB values from the RGBSCHEME() function. Get ready <g>:
this.setall("DynamicBackColor", "iif(recno() = this.nRecordNumber, EVAL('RGB(' + SUBSTR(RGBSCHEME(15, 6), ;
  AT(',', RGBSCHEME(15, 6), 3) + 1)), EVAL('RGB(' + SUBSTR(RGBSCHEME(15, 2), AT(',', RGBSCHEME(15, 2), 3) + 1)))", ;
  "Column")
this.setall("DynamicForeColor", "iif(recno() = this.nRecordNumber, EVAL(LEFT(RGBSCHEME(15, 6), ;
  AT(',', RGBSCHEME(15, 6), 3) - 1) + ')'), EVAL(LEFT(RGBSCHEME(15, 2), AT(',', RGBSCHEME(15, 2), 3) - 1) + ')'))", ;
  "Column")
This code sits in the init of one of my grid base classes and I haven't had to look at it for quite some time. RGBSCHEME() returns a string that's in the format "RGB(fcR, fcG, fcB, bcR, bcG, bcB)", so the code above grabs the backcolor for the selected items:
'RGB(' + SUBSTR(RGBSCHEME(15, 6),  AT(',', RGBSCHEME(15, 6), 3) + 1)
which evaluates to "RGB(bcR, bcG, bcB)". It does the same for the other three RGB values (selected forecolor, unselected backcolor and unselected forecolor).

From some investigations I'm doing at the moment, RGBSCHEME(15, 6) gets its values from the Selected Items display property, and RGBSCHEME(15,2) gets its values from changes to the Message Box and Window display properties. I'm planning to post the results of my investigations on the WIKI as soon as they're fully assembled.

Cheers,

Andrew

>I am using the common technique of setting the DynamicBackColor and DynamicForeColor properties of all columns to highlight a row in a grid. I would like the color of the row to match the Windows Display Properties. I thought about adding a textbox as a property to the grid at runtime and getting the SelectedForeColor and SelectedBackColor properties from it. Is there a better way to do this, perhaps one that uses fewer clock cycles? I don't want to depend on a certain control being in a column.
>
>I noticed a different method mentioned on the ProFox list that uses a textbox to simulate highlighting the row instead of Dynamic color properties, but the download at leafe.com was corrupted. If someone wouldn't mind emailing this to me (jleach@mbs-intl.com), maybe I can kill two birds with one stone. Thanks.


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform