Scroll bar colour 
Author Message
 Scroll bar colour

Riddle me this, one of ye bright young scholars:

If the standard Windows colour scheme is used, scrollbars are dithered (even
on my 16-bit colour system).  The dither appears to be between the button
face and button highlight colours.  If a colour scheme is used where the 3d
objects colour is not the standard grey, this dither does not happen.

How do I reliably get a brush with the right pattern?  I have tried
GetSysColorBrush(COLOR_SCROLLBAR), but it just returns the 3d face colour.
I need to create a control kinda like a scrollbar, and I want the background
to look right on any system.

Ideas gratefully received!

    - Paul



Sun, 18 Mar 2001 03:00:00 GMT  
 Scroll bar colour
Followup:

I don't know if there's a better way, but I eventually resorted to a
workaround:

I check the system 3D colour, and the scrollbar colour.  If they are
different, GetSysColorBrush and use the scrollbar brush - fine.

If they are the same, I CreatePatternBrush instead, using an 8x8 dithered
bitmap.  This is a bit of a pain, since I have to create and draw the
dithered bitmap myself, but it seems to work with all the colour schemes I
have tried.

Still open to better suggestions!

    - Paul

 >Riddle me this, one of ye bright young scholars:
 >
 >If the standard Windows colour scheme is used, scrollbars are dithered
(even
 >on my 16-bit colour system).  The dither appears to be between the button
 >face and button highlight colours.  If a colour scheme is used where the
3d
 >objects colour is not the standard grey, this dither does not happen.
 >
 >How do I reliably get a brush with the right pattern?  I have tried
 >GetSysColorBrush(COLOR_SCROLLBAR), but it just returns the 3d face colour.
 >I need to create a control kinda like a scrollbar, and I want the
background
 >to look right on any system.
 >
 >Ideas gratefully received!
 >
 >    - Paul



Mon, 19 Mar 2001 03:00:00 GMT  
 Scroll bar colour

Quote:
> Riddle me this, one of ye bright young scholars:

> If the standard Windows colour scheme is used, scrollbars are dithered
(even
> on my 16-bit colour system).  The dither appears to be between the button
> face and button highlight colours.  If a colour scheme is used where the
3d
> objects colour is not the standard grey, this dither does not happen.

> How do I reliably get a brush with the right pattern?  I have tried
> GetSysColorBrush(COLOR_SCROLLBAR), but it just returns the 3d face
colour.
> I need to create a control kinda like a scrollbar, and I want the
background
> to look right on any system.

> Ideas gratefully received!

>     - Paul

I use different colors for 3D objects, and I get the described dither
anyway: perhaps you need to look closer (try a graphics program with zoom
capability!).

Here's some code to get a brush to draw in that dithered color:

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Function CreatePatternBrush& Lib "gdi32" (ByVal hBitmap As
Long)
Private Declare Function DeleteObject& Lib "gdi32" (ByVal hObject As Long)

Private Sub Command1_Click()
    Dim ret As Long
    Dim hBrush As Long
    Dim MyRect As RECT
    Dim i As Long, j As Long

    '---one-time setup: put this in it's own routine------
    'set (invisible) picturebox properties for creating a brush
    picBrush.ScaleMode = 3
    picBrush.AutoRedraw = True
    'draw the dither in it
    For i = 0 To 7
        For j = 0 To 7
            If (i + j) Mod 2 Then
                picBrush.PSet (i, j), vb3DHighlight
            Else
                picBrush.PSet (i, j), vb3DFace
            End If
        Next j
    Next i
    '---end of one-time setup------

    'create the brush from it
    hBrush = CreatePatternBrush(picBrush.Image.Handle)
    'draw on the form with that brush
    MyRect.Bottom = 100
    MyRect.Right = 100
    ret = FillRect(Form1.hdc, MyRect, hBrush)
    'clean up
    ret = DeleteObject(hBrush)
End Sub

Jim Deutch
MS Dev MVP



Fri, 23 Mar 2001 03:00:00 GMT  
 Scroll bar colour
Jim,

Thanx for the reply.  I used a routine very like the one you describe to
create the pattern brush, except that I am doing it entirely in API calls.

As far as the dithered scrollbars are concerned, now that I try it (I had to
format C: and re-install NT4 last week) I am always getting dithered
scrollbars as well.  Strange...

I wonder why GetSysColorBrush doesn't return a pattern brush for
COLOR_SCROLLBAR?

    - Paul



Fri, 23 Mar 2001 03:00:00 GMT  
 Scroll bar colour
Hi Jim --

Quote:
>I use different colors for 3D objects, and I get the described dither
>anyway: perhaps you need to look closer (try a graphics program with zoom
>capability!).

Really?  I've got a solid one here.  Color depth, perhaps?

Later...   Karl



Fri, 23 Mar 2001 03:00:00 GMT  
 Scroll bar colour
Hi Paul --

Quote:
>If the standard Windows colour scheme is used, scrollbars are dithered (even
>on my 16-bit colour system).

Odd.  Not here, but I'm using True Color [sic].

Quote:
>The dither appears to be between the button
>face and button highlight colours.  If a colour scheme is used where the 3d
>objects colour is not the standard grey, this dither does not happen.

>How do I reliably get a brush with the right pattern?  I have tried
>GetSysColorBrush(COLOR_SCROLLBAR), but it just returns the 3d face colour.
>I need to create a control kinda like a scrollbar, and I want the background
>to look right on any system.

Man, this looks like some testing is gonna be required on different color depths.
There's gotta be a rule, but I sure don't know what it is.  FWIW, the following...

   Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
   Private Const COLOR_SCROLLBAR = 0
   Private Const COLOR_BTNFACE = 15

   Private Sub Form_Load()
      Debug.Print "COLOR_SCROLLBAR = &h" & _
         Hex(GetSysColor(COLOR_SCROLLBAR))
      Debug.Print "COLOR_BTNFACE = &h" & _
         Hex(GetSysColor(COLOR_BTNFACE))
   End Sub

run here, definitely returns two distinct colors...

   COLOR_SCROLLBAR = &hD1DCE2
   COLOR_BTNFACE = &hA3BAC7

Good luck...   Karl



Fri, 23 Mar 2001 03:00:00 GMT  
 Scroll bar colour
Hi Karl,

Thanks for replying.  On my machine at the moment, I am getting dithered
scrollbars.  Two weeks ago, (before I had to scratch-reinstall NT) I had
solid scrollbars, on the same display configuration!

I am now assuming that either can be the case, depending on the system
configuration (or something).  I have to handle both cases, since the app is
for retail.  What I am doing is checking whether the 3d colour is the same
as the scrollbar colour.  If it is, I am creating a pattern brush by
dithering the 3d colour with the 3d highlight colour, and using it instead.
So far, it seems to be working OK.

Weird!

    - Paul



Sat, 24 Mar 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Building A Scroll Bar / Scroll Bar Colors

2. Scroll without scroll bar - VB.net

3. vertical scroll bars to scroll a maximized form??

4. Scrolling data with Vertical scroll bar ?

5. Scrolling without scroll bars (question)

6. contents won't scroll when scroll bar is dragged

7. Scroll 2 textboxes off a single scroll bar

8. Scroll bar keeps scrolling within Flexgrid

9. listbox and scroll vertical scroll bar

10. Creating Outlook Bar - Scroll Bar in my Application

11. Change the colour of a Form's Title Bar

12. Change Colour for Listview's Column bar

 

 
Powered by phpBB® Forum Software