Home All Groups Group Topic Archive Search About

Setting background in vscrollbar to gray

Author
7 Mar 2006 5:42 PM
Dan
I'm working in VB6 and would like to set the background of the VScrollbar
control to gray (it defaults to white).  There is backcolor property for this
control; is there any way to do what I want.

Thanks...

Dan

Author
7 Mar 2006 6:25 PM
Karl E. Peterson
Dan wrote:
> I'm working in VB6 and would like to set the background of the
> VScrollbar control to gray (it defaults to white).  There is
> backcolor property for this control; is there any way to do what I
> want.

Unfortunately, that's a bug in (all versions of) 32-bit VB.  See the 2nd
Question in this article:

  http://vb.mvps.org/articles/ap199810.pdf

Short story is, you need to subclass the form, and "eat" the
WM_CTLCOLORSCROLLBAR messages it gets.
--
Working without a .NET?
http://classicvb.org/
Author
7 Mar 2006 7:01 PM
Dan
By "eat", do you mean that I return a brush handle to paint the background
gray, or do you mean that I should simply return 0?

Dan

Show quoteHide quote
"Karl E. Peterson" wrote:

> Dan wrote:
> > I'm working in VB6 and would like to set the background of the
> > VScrollbar control to gray (it defaults to white).  There is
> > backcolor property for this control; is there any way to do what I
> > want.
>
> Unfortunately, that's a bug in (all versions of) 32-bit VB.  See the 2nd
> Question in this article:
>
>   http://vb.mvps.org/articles/ap199810.pdf
>
> Short story is, you need to subclass the form, and "eat" the
> WM_CTLCOLORSCROLLBAR messages it gets.
> --
> Working without a .NET?
> http://classicvb.org/
>
>
>
Author
7 Mar 2006 7:46 PM
Karl E. Peterson
Dan wrote:
> By "eat", do you mean that I return a brush handle to paint the
> background gray, or do you mean that I should simply return 0?

As I wrote in that column:

  "By simply instructing MsgHook to intercept this message, but not reacting
in any fashion whatsoever to the receipt of the message, you instruct
Windows to use the default colors for these controls."

So, yeah, returning zero would be the proper non-response. <g>
--
Working without a .NET?
http://classicvb.org/



Show quoteHide quote
> "Karl E. Peterson" wrote:
>
>> Dan wrote:
>>> I'm working in VB6 and would like to set the background of the
>>> VScrollbar control to gray (it defaults to white).  There is
>>> backcolor property for this control; is there any way to do what I
>>> want.
>>
>> Unfortunately, that's a bug in (all versions of) 32-bit VB.  See the
>> 2nd Question in this article:
>>
>>   http://vb.mvps.org/articles/ap199810.pdf
>>
>> Short story is, you need to subclass the form, and "eat" the
>> WM_CTLCOLORSCROLLBAR messages it gets.
>> --
>> Working without a .NET?
>> http://classicvb.org/
Author
7 Mar 2006 8:40 PM
Dan
Thanks Karl.  I downloaded MsgHook, and applied the code from your article,
but I'm still getting the same behavior.  I wonder if it's because the
vscrollbar is part of Francesco Balena's Superlistbox control:
http://www.fawcette.com/archives/premier/mgznarch/VBPJ/1999/08aug99/fb0899.pdf



Show quoteHide quote
"Karl E. Peterson" wrote:

> Dan wrote:
> > By "eat", do you mean that I return a brush handle to paint the
> > background gray, or do you mean that I should simply return 0?
>
> As I wrote in that column:
>
>   "By simply instructing MsgHook to intercept this message, but not reacting
> in any fashion whatsoever to the receipt of the message, you instruct
> Windows to use the default colors for these controls."
>
> So, yeah, returning zero would be the proper non-response. <g>
> --
> Working without a .NET?
> http://classicvb.org/
>
>
>
> > "Karl E. Peterson" wrote:
> >
> >> Dan wrote:
> >>> I'm working in VB6 and would like to set the background of the
> >>> VScrollbar control to gray (it defaults to white).  There is
> >>> backcolor property for this control; is there any way to do what I
> >>> want.
> >>
> >> Unfortunately, that's a bug in (all versions of) 32-bit VB.  See the
> >> 2nd Question in this article:
> >>
> >>   http://vb.mvps.org/articles/ap199810.pdf
> >>
> >> Short story is, you need to subclass the form, and "eat" the
> >> WM_CTLCOLORSCROLLBAR messages it gets.
> >> --
> >> Working without a .NET?
> >> http://classicvb.org/
>
>
>
>
Author
7 Mar 2006 8:51 PM
Ken Halter
"Dan" <D**@discussions.microsoft.com> wrote in message
news:B26F3F44-12D0-4051-B6A5-7D86BE48A6CE@microsoft.com...
> Thanks Karl.  I downloaded MsgHook, and applied the code from your
> article,
> but I'm still getting the same behavior.  I wonder if it's because the
> vscrollbar is part of Francesco Balena's Superlistbox control:
> http://www.fawcette.com/archives/premier/mgznarch/VBPJ/1999/08aug99/fb0899.pdf
>

"The SuperListBox control comprises two constituent controls: a standard
listbox and a vertical scrollbar."

If that scrollbar is the instrinsic scrollbar that's always in the toolbox
then.... no. It shouldn't make a difference.
If that scrollbar is part of the Windowless library he mentions in that
article then.... yes. Forget about subclassing code having any effect on
that one. No window = no hWnd = no subclassing.... even Windows isn't
keeping track of that one.

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Author
7 Mar 2006 9:04 PM
Karl E. Peterson
Dan wrote:
> Thanks Karl.  I downloaded MsgHook, and applied the code from your
> article,

Remember, MsgHook is but a convenience, especially since VB5 added AddressOf
to the arsenal.  To see my method of native subclassing, check out:

  http://vb.mvps.org/samples/HookMe

> but I'm still getting the same behavior.  I wonder if it's
> because the vscrollbar is part of Francesco Balena's Superlistbox
> control:
>
http://www.fawcette.com/archives/premier/mgznarch/VBPJ/1999/08aug99/fb0899.pdf

Ah, well, as Ken says, all bets are off in that case.  I have no idea what
Francesco did, without a lot of dissection.  The reason I was hooking the
form in the first place, was Windows sends that message to the scrollbar's
parent window.  You familiar with Spy++?
--
Working without a .NET?
http://classicvb.org/
Author
7 Mar 2006 9:31 PM
Dan
Yes, I'm very familiar with Spy++ (not sure whether to brag about it though :).

I think Ken is right: there is no hWnd property on Balena's scrollbar (even
though it's named vScrollBar).

Show quoteHide quote
"Karl E. Peterson" wrote:

> Dan wrote:
> > Thanks Karl.  I downloaded MsgHook, and applied the code from your
> > article,
>
> Remember, MsgHook is but a convenience, especially since VB5 added AddressOf
> to the arsenal.  To see my method of native subclassing, check out:
>
>   http://vb.mvps.org/samples/HookMe
>
> > but I'm still getting the same behavior.  I wonder if it's
> > because the vscrollbar is part of Francesco Balena's Superlistbox
> > control:
> >
> http://www.fawcette.com/archives/premier/mgznarch/VBPJ/1999/08aug99/fb0899.pdf
>
> Ah, well, as Ken says, all bets are off in that case.  I have no idea what
> Francesco did, without a lot of dissection.  The reason I was hooking the
> form in the first place, was Windows sends that message to the scrollbar's
> parent window.  You familiar with Spy++?
> --
> Working without a .NET?
> http://classicvb.org/
>
>
>
Author
7 Mar 2006 9:43 PM
Karl E. Peterson
Dan wrote:
> Yes, I'm very familiar with Spy++ (not sure whether to brag about it
> though :).

<g>

> I think Ken is right: there is no hWnd property on Balena's scrollbar
> (even though it's named vScrollBar).

Ouch.  Well, time to reinvent the wheel, then, eh?  Bummer...

Hmmmm, why don't you just wave the Spy++ window finder cursor over it, just
to be sure.
--
Working without a .NET?
http://classicvb.org/
Author
7 Mar 2006 11:00 PM
Dan
Nope, it doesn't show up as a window.  I wonder why he was using a windowless
control there.

Show quoteHide quote
"Karl E. Peterson" wrote:

> Dan wrote:
> > Yes, I'm very familiar with Spy++ (not sure whether to brag about it
> > though :).
>
> <g>
>
> > I think Ken is right: there is no hWnd property on Balena's scrollbar
> > (even though it's named vScrollBar).
>
> Ouch.  Well, time to reinvent the wheel, then, eh?  Bummer...
>
> Hmmmm, why don't you just wave the Spy++ window finder cursor over it, just
> to be sure.
> --
> Working without a .NET?
> http://classicvb.org/
>
>
>
Author
7 Mar 2006 11:08 PM
Ken Halter
"Dan" <D**@discussions.microsoft.com> wrote in message
news:3953C6CF-4B90-4457-AB81-FE4565345F7B@microsoft.com...
> Nope, it doesn't show up as a window.  I wonder why he was using a
> windowless
> control there.
>

Performance...

On the first page ot that article, there's a benchmark that compares a
regular textbox to a windowless textbox. The windowless version shows that
it ran "2.5 times faster".

Considering the fact that he tested this on a poor old 333mhz PC, I'll bet
you can swap the windowless version for the "real thing" and never know the
difference (performance wise)

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm