Solved

Info about Scrollbars..

Posted on 1998-10-28
7
462 Views
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..
SBM_ENABLE_ARROWS, SBM_GETPOS, SBM_GETRANGE, SBM_GETSCROLLINFO, SBM_SETPOS, SBM_SETRANGE, SBM_SETRANGEREDRAW, SBM_SETSCROLLINFO

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?
0
Comment
Question by:GaryC
  • 6
7 Comments
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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.

continues.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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.
0
 

Author Comment

by:GaryC
Comment Utility
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?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
Comment Utility
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
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
>> 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.


0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
What is happening with this queston?  Do you still need help?
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
Still there?  Still need help?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now