[comp.sys.mac.programmer] Scroll Bars using Think C

gilbert@grad1.cis.upenn.edu (Michael Gilbert) (10/29/90)

I've been having trouble using scroll bars in a Think C program.  They
used to work, but...

The problem is that is that when I re-size a window, I often will
change it's contents using SetOrigin.  Once I do this, I call
MoveControl and SizeControl for my scroll bars to move them into the
right places, relative to the window's new coordinate system.  This
seems to work fine, as when the window is re-drawn, the controls are
put into their correct places.

However, MouseDowns events in the scroll bars are no longer being
registered.  Strangely, sometimes when I click in strange places in
the window, the scroll bars will indeed act up.  I am converting my
points using GlobalToLocal ( &(thePoint) ); but I can't figure this
one out.

Any help appreciated...

===============================================================================
| Call me "Kelly"                      | #include <disclaim.h>                |
|-----------------------------------------------------------------------------|
|  _ _ _                               | Better the pride that resides,       |
| ' ) ) )   /                          | In a citizen of the world,           |
|  / / / o /_  _                       | Than the pride that divides,         |
| / ' (_<_/ <_</_                      | When a colourful rag is unfurled     |
| gilbert@grad1.cis.upenn.edu          |      --- Neil Peart                  |
| gilbert@eniac.seas.upenn.edu         |                                      |
|-----------------------------------------------------------------------------|
| CZECHOSLOVAKIA CHIEFS --- IGBA Champs 1984-1985 1986-Tourney 1987 1988-1989 |
===============================================================================

oster@well.sf.ca.us (David Phillip Oster) (10/30/90)

Inside Mac, Vol 1, Control Manager chapter states that you must be in
SetOrigin(0,0) for controls to work.
-- 
-- David Phillip Oster - Note new signature. Old one has gone Bye Bye.
-- oster@well.sf.ca.us = {backbone}!well!oster

llama@eleazar.dartmouth.edu (Joe Francis) (10/30/90)

In article <21408@well.sf.ca.us> oster@well.sf.ca.us (David Phillip Oster) writes:
>Inside Mac, Vol 1, Control Manager chapter states that you must be in
>SetOrigin(0,0) for controls to work.

Really?  In my experience, this is not true.  I have implemented a Paned
Window class in C++.  The Pane object sets the clippin region, ORIGIN, font,
etc everytime the pane gets passed a message.  It then calls virtual functions
in your derived pane class which can be written as if it's upper-left
corner in it's enclosing rectangle is at 0,0.

I have numerous controls, including scrolling lists, in these panes, some
of which do not have their upper-left corners at 0,0.  It all works.
I've tested it on a plus, II, and IIcx.

My guess is it's something different, like only calling LClick if the click
was in the list.  The scroll bar is actually outside the list rect, so
you need to add 15 (or is it 16 - I never can remember :-) to the width
of your rect when your are testing your GlobalTolocalled hitpoint.  This
"feature" has bit many a list novice - including moi.

------------------------------------------------------------------------------
"Read My Lips: No Nude Texans!" - George Bush clearing up a misunderstanding

wdh@well.sf.ca.us (Bill Hofmann) (10/31/90)

In article <21408@well.sf.ca.us> oster@well.sf.ca.us (David Phillip Oster) writes:
>Inside Mac, Vol 1, Control Manager chapter states that you must be in
>SetOrigin(0,0) for controls to work.
While using SetOrigin is a lovely idea, this is only one of the managers that
assumes the origin is 0.  The Window Manager routine DrawGrowIcon also assumes
the origin is 0, as does all of TextEdit.  If you must use SetOrigin, one
strategy that works is to only use it when you actually draw (in your update
routine, mostly) and immediately set it back to 0,0 after you draw your objects,
but before you call DrawControls and DrawGrowIcon.

-Bill Hofmann