Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Highlight Grid Row with Windows System Colors
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Highlight Grid Row with Windows System Colors
Miscellaneous
Thread ID:
00096203
Message ID:
00096203
Views:
51
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
Map
View

Click here to load this message in the networking platform