Prev: How to use the WebBrowser control to open an Office document
Next: Does anyone still use vbAdvance?
From: C. Kevin Provance on 10 Feb 2010 18:52 "Rick Rothstein" <rick.newsNO.SPAM(a)NO.SPAMverizon.net> wrote in message news:OeM30s1pKHA.5224(a)TK2MSFTNGP05.phx.gbl... | To make it easier for those wanting you to use your formula in their own | code, here it is cast into a function that takes the Long value normally | returned by the various controls' BackColor properties... | | Function TextColorToUse(BackColor As Long) As Long | Dim Luminance As Long | Luminance = 77 * (BackColor Mod &H100) + _ | 151 * ((BackColor \ &H100) Mod &H100) + _ | 28 * ((BackColor \ &H10000) Mod &H100) | ' Default value of TextColorToUse is 0-Black, set | ' it to White if the Luminance is less than 32640 | If Luminance < 32640 Then TextColorToUse = vbWhite | End Function | | And for those who expect such things from me, here's the one-liner version | of the above function<g>... | | Function TextColorToUse2(BackColor As Long) As Long | TextColorToUse2 = -vbWhite * (77 * (BackColor Mod &H100) + _ | 151 * ((BackColor \ &H100) Mod &H100) + 28 * _ | ((BackColor \ &H10000) Mod &H100) < 32640) | End Function Check out this little gem I did not know existed till about two minutes ago. Declare Sub ColorRGBToHLS Lib "shlwapi" _ (ByVal clrRGB As Long, _ ByRef pwHue As Integer, _ ByRef pwLuminance As Integer, _ ByRef pwSaturation As Integer)
From: Mike Williams on 11 Feb 2010 00:55 "C. Kevin Provance" <*@*.*> wrote in message news:OdpDfwqqKHA.5956(a)TK2MSFTNGP02.phx.gbl... > Check out this little gem I did not know existed till about two minutes > ago. > Declare Sub ColorRGBToHLS Lib "shlwapi" _ > (ByVal clrRGB As Long, _ > ByRef pwHue As Integer, _ > ByRef pwLuminance As Integer, _ > ByRef pwSaturation As Integer) That's quite nice. I notice there is also a ColorHLSToRGB function. Mike
From: Jack T. on 11 Feb 2010 15:04 If anyone is interested, I found this cool program called Colour Contrast Analyser. It's free. http://www.wat-c.org/tools/CCA/1.1/ "Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message news:ewfnX7tqKHA.728(a)TK2MSFTNGP04.phx.gbl... > "C. Kevin Provance" <*@*.*> wrote in message > news:OdpDfwqqKHA.5956(a)TK2MSFTNGP02.phx.gbl... > >> Check out this little gem I did not know existed till about two minutes >> ago. >> Declare Sub ColorRGBToHLS Lib "shlwapi" _ >> (ByVal clrRGB As Long, _ >> ByRef pwHue As Integer, _ >> ByRef pwLuminance As Integer, _ >> ByRef pwSaturation As Integer) > > That's quite nice. I notice there is also a ColorHLSToRGB function. > > Mike > >
First
|
Prev
|
Pages: 1 2 3 Prev: How to use the WebBrowser control to open an Office document Next: Does anyone still use vbAdvance? |