Hey guys,

Does anybody know how to change the coloring of the scrollbar on a rich edit control? There is the WM_CTLCOLORSCROLLBAR message, but it only handles the background of the scrollbar and not the scrollbar itself, or the thumb. Is there a way to address those other parts of the scrollbar?

Any help is appreciated.

- Chris
Posted on 2002-08-18 19:28:50 by bit
Chris,

As far as I know, you can only set the scrollbar colors in the system settings, I have not seen a way to do it for individual instances of a control. There may be a way to do it but I have not seen it myself. Perhaps you could try subclassing the scrollbar and do some work on the messages in it.

Regards,

hutch@movsd.com
Posted on 2002-08-18 22:04:47 by hutch--
Yeah, I had that in the back of my mind, but was hoping it wouldn't come to that. :(

So, as far as you know, in order to change the scrollbars (e.g. to something similar to the ones on this website) I would have to do the following steps.

1. Make the richedit window without a scrollbar.

2. Create a separate scrollbar instance and make it the child of the rich edit window.

3. Make the scrollbar owner drawn so I can draw the thing with the colors I desire.

4. Map the line-up, page-up, etc. messages as well as the keys to "scroll messages" and send those to the parent (in this case the rich edit window).

Am I missing anything or doing something overly complicated with this approach? This shouldn't be too bad to implement, but I might as well make sure there ain't an easier way.

Gracias.

- Chris
Posted on 2002-08-18 22:20:54 by bit

1. Make the richedit window without a scrollbar.

2. Create a separate scrollbar instance and make it the child of the rich edit window.

3. Make the scrollbar owner drawn so I can draw the thing with the colors I desire.

4. Map the line-up, page-up, etc. messages as well as the keys to "scroll messages" and send those to the parent (in this case the rich edit window).

Am I missing anything or doing something overly complicated with this approach? This shouldn't be too bad to implement, but I might as well make sure there ain't an easier way.


1. Make a richedit with a scrollbar.

2. use API GetScrollInfo with SB_HORZ or SB_VERT to get the hWnd of the scrollbar you want.

3. Subclass it and pass all those scroll messages to the default handler =)
Posted on 2002-08-19 00:38:37 by Graebel
bit,

Once concession, could you STOP posting messages that are all in bold, it makes them hard to read and it does not gain any extra notice by doing so.

Regards,

hutch@movsd.com
Posted on 2002-08-19 05:59:31 by hutch--
Done, hutch. Old habit from other message boards. Not done for any extra notice, so NBD.

Graebel, how can you subclass the scrollbar with the results of a call to GetScrollInfo? The GetScrollInfo function doesn't return the hwnd of the scrollbar and the scrollinfo structure doesn't have a field for it either. What am I missing?

- Chris
Posted on 2002-08-19 10:05:50 by bit
Your right bit, I thought the info structure contained the hWnd. Looks like it
does not. Perhaps ChildWindowFromPoint would work? I have not tried to
use this on built in scroll bar controls before so I cant be sure...
Posted on 2002-08-19 13:35:58 by Graebel
ChildWindowFromPoint might work but it is a very unreliable way to do it. Enumerate the child windows and get the handle from that. A better way is to use the Flat scroll bars API, that will allow you to set the colors:

invoke InitializeFlatSB,hEdit

invoke FlatSB_SetScrollProp, hEdit, WSB_PROP_VBKGCOLOR, rgbcolor, TRUE
Posted on 2003-12-20 09:27:15 by donkey
there's a topic related to this at research.microsoft.com. search for detours. haven't read it thoroughly, but seems to be in the same area as this. it says you cannot change the color of a scrollbar directly, you'll need to use a binary replacement or detour to do it, if i am not wrong.
Posted on 2003-12-20 13:47:26 by evil__donkey