Contrasting Colours -
01-14-2012
, 03:13 AM
My Post on Convert RGB Colours to HSL may well be irrelevant, so I will ask
the basic question instead of guessing the answer. I have a continuous form
based on about 15 records where, using conditional formatting, the user can
choose the background colour of a control called "CalendarShort". This is
done by double clicking the field which brings up the Colour Picker dialog
box and stores the RGB colour in the Calendar Table.
What I want to do is ensure that the ForeColor of the CalendarShort is in as
contrasting colour as possible to the Background so that it can be read
easily.
So I need some sort of function like
Function Contrast(ColIn as Long) as Long
I have a shaky function that returns either VbBlack or VBWhite, but it doesnt
always get it right, but realy need colours that stand out
I can then apply that to the conditional formating
Without going ito all the details, this bit works fine
Sub SetFormatCondCal(ChangeForeColour As Boolean)
Blah Blah
Me!CalendarShort.FormatConditions(i).BackColor i).BackColor =
CalendarSet!CalendarColour If ChangeForeColour = True Then ' Contrasting
ForColor Me!CalendarShort.FormatConditions(i).ForeColor = _
Contrast(Nz(CalendarSet!CalendarColour))
End If
Any ideas please
Phil
Any ideas please |