Results 1 to 9 of 9

Thread: scrollbar color

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Enterprise
    Posts
    101

    Question scrollbar color

    some weeks back i found in the forum a thread where someone wanted to have the scrollbar of a treeview in another color. as this was not possible his was gaven the advice to replace the scrollbar of the treeview with a custom scrollbar and change its' color.
    well i don't need it for a treeview but anyways i cannot find a scrollbar with a 'color' property. (there are two kinds of scrollbars - the standard one and the FlatScrollBar but neither of them has a color or backcolor property)
    any idea?
    thx
    Geordi: Data... I made that joke seven years ago"
    Data: "I know.... I just got it!"

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Create one yourself with two pictureboxes (one -the cursor- moving inside the other)
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    When a VB form has a standard scrollbar on it, whenever that scrollbar needs to be redrawn the first thing it does is send a WM_CTLCOLORSCROLLBAR message to the parent form. If you subclass that form you can alter the colour used.
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Enterprise
    Posts
    101
    Originally posted by MerrionComputin
    When a VB form has a standard scrollbar on it, whenever that scrollbar needs to be redrawn the first thing it does is send a WM_CTLCOLORSCROLLBAR message to the parent form. If you subclass that form you can alter the colour used.
    can you give me an example how?
    (or give me an advice where i could find it?)
    thx
    Geordi: Data... I made that joke seven years ago"
    Data: "I know.... I just got it!"

  5. #5
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    I would think hard if you should subclass the form to get it working. You should probably use a "custom scrollbar"
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  6. #6
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  7. #7
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Example of purple scrollbars, using the EventVB.dll:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim WithEvents vbLink As EventVB.APIFunctions
    4. Dim WithEvents vbWnd As EventVB.ApiWindow
    5.  
    6. Dim colScrollbars As EventVB.ApiColour
    7.  
    8. Private Sub Form_Load()
    9.  
    10. Set vbLink = New APIFunctions
    11.  
    12. '\\ Decide what colour to use for the scrollbars
    13. Set colScrollbars = New ApiColour
    14. With colScrollbars
    15.     .Red = 100 '\\ Out of 255
    16.     .Green = 0
    17.     .Blue = 100
    18. End With
    19.  
    20. Set vbWnd = New ApiWindow
    21. vbWnd.hWnd = Me.hWnd
    22.  
    23. vbLink.SubclassedWindows.Add vbWnd
    24.  
    25. End Sub
    26.  
    27. Private Sub vbWnd_ControlColour(ByVal ControlType As EventVB.StandardControlTypes, ByVal DeviceContext As EventVB.ApiDeviceContext, ByVal ControlWindow As EventVB.ApiWindow, ColourBrush As EventVB.ApiLogBrush)
    28.  
    29. If ControlType = Control_Scrollbar Then
    30.     Set ColourBrush.Colour = colScrollbars
    31. End If
    32.  
    33. End Sub

    Or if you don't want to include a dll, do a search on MSDN for WM_CTLCOLORSCROLLBAR for how it works....

    Hope this helps,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Enterprise
    Posts
    101

    thanks MerrionComputin but...

    it still doesn't make the whole scrollbar coloured. is it possible or should i stick to the two pictureboxes and a custom made scrollbar?
    Geordi: Data... I made that joke seven years ago"
    Data: "I know.... I just got it!"

  9. #9
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    There doesn't seem to be a scrollbar forecolor property nor API call equivalent.
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width