Although this doesn't directly answer your question, maybe this will do what you want. It takes colors from the user's Windows color settings.
lo_TextBox = CREATEOBJECT("TextBox")
lc_BackColor = TRANSFORM(lo_TextBox.BACKCOLOR)
lc_ForeColor = TRANSFORM(lo_TextBox.FORECOLOR)
lc_SelectedBackColor = TRANSFORM(lo_TextBox.SELECTEDBACKCOLOR)
lc_SelectedForeColor = TRANSFORM(lo_TextBox.SELECTEDFORECOLOR)
lo_TextBox = .NULL.
THISFORM.Grid1.SETALL( "DynamicBackColor", "IIF( ll_Test, " + lc_SelectedBackColor + ", " + lc_BackColor + ")", "Column" )
THISFORM.Grid1.SETALL( "DynamicForeColor", "IIF( ll_Test, " + lc_SelectedForeColor + ", " + lc_ForeColor + ")", "Column" )
>Hello
>I have a grid where the backcolor is set at runtime using the dynamicbackcolor property
>
>I need to make the text readable no matter the back color. I tried setting dynamicforecolor to bitxor(dynamicbackcolor, rgb(255,255,255)), but the results are disgusting
>
>I want to set dynamicforecolor to black if the back color is light and to white if the back color is dark. But I cannot find a function that reliably tells me the "intensity" or "luminance" of the color...
>
>Thanks!