Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
scroll bars Cutearmychic Excel Worksheet Functions 1 August 22nd 08 08:53 PM
SCROLL BARS GSB Excel Discussion (Misc queries) 1 September 28th 07 05:03 PM
Scroll bars Tazzy via OfficeKB.com Excel Discussion (Misc queries) 3 December 10th 06 10:28 PM
Excel's scroll bar [email protected] Excel Discussion (Misc queries) 5 November 3rd 06 03:42 PM
Scroll bars Embalmer Excel Discussion (Misc queries) 1 December 31st 05 05:05 PM


All times are GMT +1. The time now is 10:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"