ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What is the RGB value of the colour of Excel's scroll bars (https://www.excelbanter.com/excel-programming/298454-what-rgb-value-colour-excels-scroll-bars.html)

Charles Jordan

What is the RGB value of the colour of Excel's scroll bars
 
Hi NG. We have surrounded an Excel scroll bar with cells coloured grey
(RGB(240,240,240) - but it's not a precise match. Does any on know the
RGB value of the scroll bars ?

Thanks Charles

Steve Garman

What is the RGB value of the colour of Excel's scroll bars
 
It appears to be 236,233,216

I found this by putting a scrollbar on a userform and running the sub
test, which I've reproduced below in case you need to check other colours.

Private Declare Function TranslateColor Lib "olepro32.dll" _
Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, _
ByVal palet As Long, col As Long) As Long

Sub test()
Dim RealColor As Long, test As OLE_COLOR
test = UserForm1.ScrollBar1.BackColor
TranslateColor test, 0, RealColor
MsgBox "The backcolor of this form is R=" & _
CStr(RealColor And &HFF&) & " G=" & _
CStr((RealColor And &HFF00&) / 2 ^ 8) & _
" B=" + CStr((RealColor And &HFF0000) / 2 ^ 16)
End Sub



Charles Jordan wrote:
Hi NG. We have surrounded an Excel scroll bar with cells coloured grey
(RGB(240,240,240) - but it's not a precise match. Does any on know the
RGB value of the scroll bars ?

Thanks Charles



Charles Jordan

What is the RGB value of the colour of Excel's scroll bars
 
Steve Garman wrote in message ...
It appears to be 236,233,216

I found this by putting a scrollbar on a userform and running the sub
test, which I've reproduced below in case you need to check other colours.

Private Declare Function TranslateColor Lib "olepro32.dll" _
Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, _
ByVal palet As Long, col As Long) As Long

Sub test()
Dim RealColor As Long, test As OLE_COLOR
test = UserForm1.ScrollBar1.BackColor
TranslateColor test, 0, RealColor
MsgBox "The backcolor of this form is R=" & _
CStr(RealColor And &HFF&) & " G=" & _
CStr((RealColor And &HFF00&) / 2 ^ 8) & _
" B=" + CStr((RealColor And &HFF0000) / 2 ^ 16)
End Sub



Charles Jordan wrote:
Hi NG. We have surrounded an Excel scroll bar with cells coloured grey
(RGB(240,240,240) - but it's not a precise match. Does any on know the
RGB value of the scroll bars ?

Thanks Charles



Thanks Steve - for accuracy, promptness, replying on a Sunday ..and a
very scientific solution. Charles

onedaywhen

What is the RGB value of the colour of Excel's scroll bars
 
This code should work for any location on the screen:

Option Explicit

Private Declare Sub Sleep _
Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Private Declare Function GetCursorPos _
Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Declare Function GetPixel _
Lib "gdi32" _
(ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long) As Long

Private Declare Function GetDC _
Lib "user32" _
(ByVal hwnd As Long) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Public Sub ColorUnderCursor()

Dim pCursorPos As POINTAPI
Dim lngColorUnderCursor As Long

Dim R As Long
Dim G As Long
Dim B As Long

' Sleep two seconds to allow cursor
' to move somewhere useful
Sleep 2000

GetCursorPos pCursorPos

lngColorUnderCursor = _
GetPixel(GetDC(0&), _
pCursorPos.x, pCursorPos.y)

SplitRGB lngColorUnderCursor, R, G, B

MsgBox CStr(lngColorUnderCursor) & _
":" & vbCrLf & _
"R=" & CStr(R) & vbCrLf & _
"G=" & CStr(G) & vbCrLf & _
"B=" & CStr(B)
End Sub

Sub SplitRGB( _
ByVal RGBValue As Long, _
ByRef R As Long, _
ByRef G As Long, _
ByRef B As Long _
)
R = RGBValue And 255
G = RGBValue \ 256 And 255
B = RGBValue \ 256 ^ 2 And 255
End Sub

Charles Jordan

What is the RGB value of the colour of Excel's scroll bars
 
(onedaywhen) wrote in message om...
This code should work for any location on the screen:

Option Explicit

Private Declare Sub Sleep _
Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Private Declare Function GetCursorPos _
Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Declare Function GetPixel _
Lib "gdi32" _
(ByVal hdc As Long, _
ByVal x As Long, _
ByVal y As Long) As Long

Private Declare Function GetDC _
Lib "user32" _
(ByVal hwnd As Long) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Public Sub ColorUnderCursor()

Dim pCursorPos As POINTAPI
Dim lngColorUnderCursor As Long

Dim R As Long
Dim G As Long
Dim B As Long

' Sleep two seconds to allow cursor
' to move somewhere useful
Sleep 2000

GetCursorPos pCursorPos

lngColorUnderCursor = _
GetPixel(GetDC(0&), _
pCursorPos.x, pCursorPos.y)

SplitRGB lngColorUnderCursor, R, G, B

MsgBox CStr(lngColorUnderCursor) & _
":" & vbCrLf & _
"R=" & CStr(R) & vbCrLf & _
"G=" & CStr(G) & vbCrLf & _
"B=" & CStr(B)
End Sub

Sub SplitRGB( _
ByVal RGBValue As Long, _
ByRef R As Long, _
ByRef G As Long, _
ByRef B As Long _
)
R = RGBValue And 255
G = RGBValue \ 256 And 255
B = RGBValue \ 256 ^ 2 And 255
End Sub


Hi OneDay. Thanks, but since I'm not a Windows programmer, could you
tell us whether your magnificent code will run with Excel 95 - our
lowest common denominator ? (And still the chosen development platform
since it is *so much* faster to develop in, in our view, than Excel 97
and up, *even after* porting to Excel 2004 which we do all the time).
Charles

onedaywhen

What is the RGB value of the colour of Excel's scroll bars
 
wrote ...

Hi OneDay. Thanks, but since I'm not a Windows programmer, could you
tell us whether your magnificent code will run with Excel 95 - our
lowest common denominator ?


It does for Excel95 on WinXP, subject to replacing 'vbCrLf' with
'Chr$(10)'. Who said it was my code? I recognize SplitRGB as being
from Chip Pearson's site.

(Excel95 is) still the chosen development platform
since it is *so much* faster to develop in, in our view, than Excel 97
and up, *even after* porting to Excel 2004 which we do all the time


A smell of petroleum prevails throughout, right?

--

Charles Jordan

What is the RGB value of the colour of Excel's scroll bars
 
(onedaywhen) wrote in message . com...
wrote ...

Hi OneDay. Thanks, but since I'm not a Windows programmer, could you
tell us whether your magnificent code will run with Excel 95 - our
lowest common denominator ?


It does for Excel95 on WinXP, subject to replacing 'vbCrLf' with
'Chr$(10)'. Who said it was my code? I recognize SplitRGB as being
from Chip Pearson's site.

(Excel95 is) still the chosen development platform
since it is *so much* faster to develop in, in our view, than Excel 97
and up, *even after* porting to Excel 2004 which we do all the time


A smell of petroleum prevails throughout, right?

--


Thanks OneDay - yess, we're knee deep in it Slows down my code a bit ! Tks C.


All times are GMT +1. The time now is 02:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com