Hey guys,
how do I go about changing the colour of the scrollbar in a text box?
Printable View
Hey guys,
how do I go about changing the colour of the scrollbar in a text box?
I also want to change the colour of the menu.
I don't think you can do that...Quote:
Originally posted by GingerNut
Hey guys,
how do I go about changing the colour of the scrollbar in a text box?
I reckon that should be possible. I don't know the code, but shouldn't setting the forcolor and/or backcolor of the scrollbar chnage its appearence? Afterall, IE does it in response to certain settings in HTML file.
I guess you're talking about changing the forecolor of a browser. He's asking how to change it to a TextBox.
It's a textbox scrollbar.
I've been searching all evening and can't find anything.
I got the menu sorted though.
This supposively would work :
VB Code:
Option Explicit Declare Function CallWindowProc Lib "user32" Alias _ "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _ ByVal hwnd As Long, ByVal Msg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Const GWL_WNDPROC = -4 public Const WM_CTLCOLORSCROLLBAR = 311 Public Sub Hook() lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _ AddressOf WindowProc) End Sub Public Sub Unhook() Dim temp As Long temp = SetWindowLong(gHW, GWL_WNDPROC, lpPrevWndProc) End Sub Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long If uMsg <> WM_CTLCOLORSCROLLBAR Then Debug.Print uMsg, hw WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam) End If End Function Option Explicit Dim lpPrevWndProc As Long Dim gHW As Long Private Sub Form_Load() gHW = Me.hwnd Command1.Caption = "Hook" Command2.Caption = "Unhook" End Sub Private Sub Command1_Click() Hook VScroll1.Refresh End Sub Private Sub Command2_Click() Unhook End Sub
See this HTML page. You can change the forecolor of the scroll bars. Ther are other properties too which can be modified.Quote:
Originally posted by Mc Brain
I guess you're talking about changing the forecolor of a browser. He's asking how to change it to a TextBox.
I know that you can change the colour to it... but if it's an HTM page, you're using a browser
James, I don't suppose you could put that into action for me.
I'm getting errors here.
amitabh, I need to change the colour in a vb form not a web page, but thanks anyway.
What I meant was that if IE could do it, there was a posibility of doing it through our code also.
Here you are.Quote:
Originally posted by GingerNut
James, I don't suppose you could put that into action for me.
I'm getting errors here.
amitabh, I need to change the colour in a vb form not a web page, but thanks anyway.
Not necesarilly... a Browser and a TextBox are way too different.Quote:
Originally posted by amitabh
What I meant was that if IE could do it, there was a posibility of doing it through our code also.
Sorry I missed that one... ;)Quote:
Originally posted by Mc Brain
Here you are.
Didn't do anything.
This code should work for NT Os' What are you using?
But they have scrollbars with similar base class I suppose.Quote:
Originally posted by Mc Brain
Not necesarilly... a Browser and a TextBox are way too different.
For some reason my project is hanging when trying to add this code into other project. Apparently... it doesn't like to be subclassed.
Now that you mention it, subclassing is a pian in the arse. I'll see if I can find another example...Quote:
Originally posted by Mc Brain
For some reason my project is hanging when trying to add this code into other project. Apparently... it doesn't like to be subclassed.
I'm using ME. (I'm too cheap to buy a decent OP ):D
Can't make it work... I mean, it work alone. But it hangs if I've already subclass the form.
I think I'm gonna have to give up on this. :(
Anyway... this code is to change a VScrollbar, not a TextBox scrollbar.
Right, I've gone through just about every vb site I know of and can't find how to change the scrollbar colour in a textbox, so I'm calling it a night.
If anyone does manage to find out how it's done, let me know.
I have searched many Vb forums, and I can't find any other code that the code I provided earlier...:(
Bummer. Ah well.
I suppose I could take the scrollbar off and use images to imitate the scrollbar, at least the up and down arrows.
What kind of data are you displaying anyways?
it's a chat program, so it's just text.