Our product uses an owner-draw grid (TStringGrid) - where we are drawing all off the grid. I am trying to make this respect the VCL style that is used by the application. Most of this works, but when i try and get the selected colour for the grid, then it either appears to be black (not great when the style being used is already dark), or a seemingly random gradient. Here is the code I am using to get the selected colour (it maybe that I am using the wrong element or ElementColor
to get the expected colour).
StyleServices.GetElementColor (StyleServices.GetElementDetails (tgCellSelected), ecFillColor, theColor);
Any help would be appreciated. Thanks
Not all the
TElementColor
(ecBorderColor, ecFillColor, ecTextColor, ..) are defined for all the possibleTThemedElementDetails
, So you must always check the boolean result returned by theGetElementColor
function.If the result is false means which the color is not defined. In your case the there is not a color value defined for the
ecFillColor
when the Element istgCellSelected
.Try this sample, which uses the
tgClassicCellSelected
element instead and if not exist just use the HighLight color of the active VCL Style.