Info about Scrollbars..

Posted on 1998-10-28
Last Modified: 2008-03-17
A window can have scrollbars if the appropriate style bits are set.  As it is scrolled, WM_VSCROLL and WM_HSCROLL messages are sent to the window.  If I look at it with Spy++, I don't see any child windows (the scrollbars)  I am making a fully user drawn window and would like to have non-standard looking scrollbars without the hastle of creating them from scratch.  Spy++ lists these additional Scrollbar messages..

I suppose that I thought the scrollbars would be child windows that get these messages and would in turn send the WM_VSCROLL messages to it's parent.  I can't seem to get Spy++ to log a single SMB_ message.

So what's the deal?  I would ideally like to get device contexts to the different components of the scrollbar such as the thumb, slide and buttons.  That way, I could draw them to match my form but keep the normal functionality.

Is this possible?
Question by:GaryC
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
LVL 22

Expert Comment

ID: 1176406
There are two "types" of scroll bars.  There are "window scrollbars" which as you now know are not child windows.  They are part of the window's non-client area.  The other type are "scrollbar controls" these are child windows--just like other controls.

LVL 22

Expert Comment

ID: 1176407
To do your own scrollbars, you have two choices.  

You can continue with the windows design and not make your non-standard scroll bars child windows.  To do this you would paint them when you pain the non-client area of the window, or when scrolling messages occur.  

Or you can go with a bit "structured" design and make the scroll bars child windows.  (Which will be drawn when they get WM_PAINT messages).  If you go this route however, you will need to handle "communication" between the scroll bars controls and the window they belong to.  That is when they are scrolled they will need to send scroll messages to their parent..  (Also when the parent's information changes in size it needs to notify them.)  (one dissadvatage to this approach is that the scrollbars will be located in the client area--child windows cant be in the non-client area--this may make positioning/drawing calculations a little tougher.

Let me know if you have questions.

Author Comment

ID: 1176408
I have no other option to select (outside of accepting) then reject and that word seems so harsh.  I appreciate the input.

Yep, I know about scrollbar controls.  I'm dealing with the scrollbars that are "attached" to a window as definded in it's style bits.  I may or maynot be writing the code to link a scrollbar to a view.  I want my app to be able to subclass any of my forms however they were made so that I don't have to recreate the wheel for all the possible forms.  In theory, I would be able to hook into the message loop and draw what I want.  It's easy to do with the non-client area but i'm baffled with the scrollbars.  When I redraw, how do I know where to draw the thumb?  What processes the hit test to know what part of the scroll bar was hit?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 22

Accepted Solution

nietod earned 200 total points
ID: 1176409
You don;t have to reject an answer, if you just need more information.  Leave the grading boxes empty and post a comment asking for more info.

>>I'm dealing with the scrollbars that are "attached" to a
>> window as definded in it's style bits.
My point is that since you are doing it yourself, you can do it either way.  You might find adding controls easier.  Maybe not.

>> how do I know where to draw the thumb?
If you are usign window scrollbars use GetScrollInfo() and specify the window handle of the window (not the scrollbar control--as there is none) and also specufy SB_VERT or SB_HORS in the fnBar parameter to indicate which scroll bar you are interested in
LVL 22

Expert Comment

ID: 1176410
>> What processes the hit test to know what part of the scroll bar was hit?

I'm not sure what you mean.  You will process the WM_HSCROLL AND WM_VSCROLL to scroll your client are to a new position.  I.e. you will do scroll specific information in those message handles.  Ussually you will calculate and record the new position and then just invalidate the client area so that the next WM_PAINT draws things in the new scroll position.

LVL 22

Expert Comment

ID: 1176411
What is happening with this queston?  Do you still need help?
LVL 22

Expert Comment

ID: 1176412
Still there?  Still need help?

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question