General information
Category:
Coding, syntax & commands
Title:
Highlight Grid Row with Windows System Colors
I can't find where this has been covered, so permit me to rehash. I know how to highlight the current grid row, but I want it to conform to whatever strange colors the user has chosen for his desktop. Remembering a tip from UT, I naturally steal the properties from a visible (if available) or invisible listbox or combobox. Being a little lazy for this example, I am using the Grid's tag property to store the current record number, in event AfterRowColChange.
Procedure grdExample.Init
LOCAL lnColor, lcRed, lcGreen, lcBlue, lcString
lnColor = ThisForm.cboColorReference.SelectedItemBackColor
lcRed = LTrim(Str(lnColor % 256, 3, 0))
lcGreen = LTrim(Str(Floor((lnColor % 65536) /256), 3, 0))
lcBlue = LTrim(Str(Floor(lnColor / 65536)))
lcString = "IIF(RecNo(This.RecordSource) = Val(This.Tag)," +;
"RGB(" + lcRed + "," + lcGreen + "," + lcBlue + "),"
lnColor = ThisForm.cboColorReference.ItemBackColor
lcRed = LTrim(Str(lnColor % 256, 3, 0))
lcGreen = LTrim(Str(Floor((lnColor % 65536) /256), 3, 0))
lcBlue = LTrim(Str(Floor(lnColor / 65536)))
lcString = lcString +;
"RGB(" + lcRed + "," + lcGreen + "," + lcBlue + "))"
This.SetAll("DynamicBackColor", lcString, "Column")
lnColor = ThisForm.cboColorReference.SelectedItemForeColor
lcRed = LTrim(Str(lnColor % 256, 3, 0))
lcGreen = LTrim(Str(Floor((lnColor % 65536) /256), 3, 0))
lcBlue = LTrim(Str(Floor(lnColor / 65536)))
lcString = "IIF(RecNo(This.RecordSource) = Val(This.Tag)," +;
"RGB(" + lcRed + "," + lcGreen + "," + lcBlue + "),"
lnColor = ThisForm.cboColorReference.ItemForeColor
lcRed = LTrim(Str(lnColor % 256, 3, 0))
lcGreen = LTrim(Str(Floor((lnColor % 65536) /256), 3, 0))
lcBlue = LTrim(Str(Floor(lnColor / 65536)))
lcString = lcString +;
"RGB(" + lcRed + "," + lcGreen + "," + lcBlue + "))"
This.SetAll("DynamicForeColor", lcString, "Column")
EndProc
PROCEDURE grdExample.AfterRowColChange
LPARAMETERS nColIndex
DoDefault()
If RecNo(This.RecordSource) != Val(This.Tag)
This.Tag = Str(Recno(This.RecordSource))
This.Refresh()
EndIf
ENDPROC
I build up the string in code because I had trouble sqeezing all of the necessary expressions into the Dynamic-Color properties. Anyway, this is nice, but what I really want is to read the colors from Windows. Comboboxes and Listboxes seem to read their color information from Color Scheme 10, I think. However, nowhere can I find a list of how the color pairs match to standard color properties. Does anyone have such a list, or some other way to read standard Windows color schemes for grids?
No doubt this will be fixed in the next release of VFP. *smirk*
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only