PDA

Click to See Complete Forum and Search --> : help with scrollbars, please help!!!


Pierroth
Mar 4th, 2002, 07:49 AM
Hey out there!!!!

need help with scroolbars, i want to change the color, of a scrollbar without changin' all of the system colors, if anyone knows how or knows a control that i may use please tell me, i'll apreciate it.

thanx. :)

tropy@hotmail.com

MerrionComputin
Mar 4th, 2002, 08:01 AM
What you need to do is subclass the form that the scrollbar is on and look for the message WM_CTLCOLORSCROLLBAR.
When you get that message you create a LOGBRUSH and return it's handle from the window proc and the scrollbar control will be drawn with it.

I have coded this into the ApiWindow.ControlColour part of the EventVB.dll release which is due to go public on Friday - can you wait that long? If not send me a private message with your email and I'll send you the dll...

MerrionComputin
Mar 4th, 2002, 09:28 AM
Right - the updated EventVB.dll is available to download at this page (http://www.merrioncomputing.com/Download/index.htm)

To use it to make your scrollbars blue (for example):

Option Explicit

Dim WithEvents vbLink As EventVB.APIFunctions
Dim WithEvents vbWnd As EventVB.ApiWindow

Private Sub Form_Load()

Set vbLink = New APIFunctions

Set vbWnd = New ApiWindow
vbWnd.hWnd = Me.hWnd

vbLink.SubclassedWindows.Add vbWnd

End Sub

Private Sub Form_Unload(Cancel As Integer)

vbLink.SubclassedWindows.Remove vbWnd

End Sub

Private Sub vbWnd_ControlColour(ByVal ControlType As EventVB.StandardControlTypes, ByVal DeviceContext As EventVB.ApiDeviceContext, ByVal ControlWindow As EventVB.ApiWindow, ColourBrush As EventVB.ApiLogBrush)

Dim colThis As ApiColour

Set colThis = New ApiColour
With colThis
.Blue = 255
.Green = 0
.Red = 0
End With

If ControlType = Control_Scrollbar Then
Set ColourBrush.Colour = colThis
End If

End Sub


For a more special effect, set the ColourBrush.Bitmap value to a 16x16 image which will be used (tiled) to paint the scrollbar background.