[comp.windows.ms.programmer] Help with scrollbars....

dpelland@hawk.ulowell.edu (David Pelland) (04/11/91)

Could someone please explain to me how I can have a child window
which is of a size larger than the parent window, has scroll bars,
and is easily managed?  The windows x and y position within the parent
is fixed.  I basically want to have the scroll bars modify which piece
of the subwindow the user is viewing at any point.

------------------------------------
|                                  |
|     Status information           |
|                                  |
|           -----------------------|    basically, I want to 
|          |                      ^|    be able to scroll the
|          |                      ||    graphics area without
|  list    |                      ||    it being an overlapped 
|  of      |                      ||    window and without 
|  items   |     graphics         ||    handling it myself.
|          |     window           ||
|          |                      ||
|          |                      v|
|          |<--------------------> |
------------------------------------

This is something easily done in MOTIF, OPEN LOOK and many other window
environments.  I tried a bunch of things but can't seem to get it to work
properly.  Any help is greatly appreciated, even if it is just to tell
me that I must handle the whole thing myself. 

David M Pelland
dpelland@hawk.ulowell.edu
(508)934-3613

davel@booboo.SanDiego.NCR.COM (David Lord) (04/12/91)

In article <1991Apr10.213253.20233@ulowell.ulowell.edu> dpelland@hawk.ulowell.edu (David Pelland) writes:
<
<Could someone please explain to me how I can have a child window
<which is of a size larger than the parent window, has scroll bars,
<and is easily managed?  The windows x and y position within the parent
<is fixed.  I basically want to have the scroll bars modify which piece
<of the subwindow the user is viewing at any point.
<
<------------------------------------
<|                                  |
<|     Status information           |
<|                                  |
<|           -----------------------|    basically, I want to 
<|          |                      ^|    be able to scroll the
<|          |                      ||    graphics area without
<|  list    |                      ||    it being an overlapped 
<|  of      |                      ||    window and without 
<|  items   |     graphics         ||    handling it myself.
<|          |     window           ||
<|          |                      ||
<|          |                      v|
<|          |<--------------------> |
<------------------------------------


Unfortunately you have to handle most of it yourself.

As a fairly new Windows programmer who just worked on this same problem
I can tell you that you should keep in mind: Scroll bars are the work of
the devil and are certain to make your life miserable forever.

Actually this one is a fairly easy problem. First you always have to make sure
your child window stays within your parent window. This means adjusting the
size with MoveWindow whenever the parent gets WM_SIZE. If you don't do this
your scroll bars will be off somewhere where you can't get at them. Don't 
forget to adjust the scroll range (SetScrollRange) at the same time.

Now you just have to catch the various scroll messages and take appropriate
actions, ie. scroll the window, set the button position, and keep track of
the x & y offset amounts so you can adjust for the new position when you
handle a WM_PAINT message.

See, what did I tell you, practically trivial :-).

Dave Lord