[comp.sys.mac.programmer] Need help with special "floating" window

lindahl@violet.berkeley.edu (Ken Lindahl 642-0866) (03/30/90)

I am writing an application that supports selecting a selecting a rectangle
on a picture in the usual fashion (i.e. like the MacPaint selection tool).
I would like to put up a "selection information" window that would display
the width and height of the currently selected region. I want this window
to look and behave in similarly to the "Mouse Position" window in MacPaint:
that is:

    the drag region should be only 12 pixels tall and should be painted
    with a 1-pixel-out-of-4 pattern, with a smaller than usual go-away
    box and no title;

    the window should have the usual drop-shadow;

    the window should always "float" in front of all other windows but
    should never be the currently active window -- in other words the
    next window below it should always be active and highlighted.

The tear-off menus in MacPaint and HyperCard also have these attributes.

How is such a window implemented? I can "fake it" by using a altDBoxProc
window (no drag region, no go-away, no zoom, no resize) and implementing
a fake drag region and go-away box by checking the mouse location whenever
there is a click in the content region of the window. Whenever one of the
other windows in the application is selected, I call BringToFront() to
bring the "selection information" window to the front. There are other
(mostly unpleasant details) but you hopefully get the idea.

The "fake it" approach generally works except when one of the other windows
is moved. When the mouse is released, DragWindow() (or one of the toolbox
routines called by DragWindow()) causes the frame of the dragged window to
be drawn, if this intersects my "selection information" window, there is an
annoying flicker when the "selection information" window gets redrawn. This
does not occur in the MacPaint and HyperCard examples listed above. In those
cases, the pixels of the special window appear untouched when the underlying
window is dragged (except for the window outline while the mouse button is
held down).  The drop-shadow for altDBoxProc windows is also a pixel wider
than usual, but I can live with that.

Can someone point me in the right direction in terms of how to accomplish
this? I don't need a full-blown answer, just a pointer to the appropriate
references. (I have the suspicion that I'm missing something that is right
under my nose.) Do I have to write my own DragWindow() routine? Note that
the DragHook described in IM-I only affects what happens while the mouse is
button is down and not what happens after it is released, which is what I am
concerned with.

Thanks,

Ken Lindahl				lindahl@violet.berkeley.edu
Advanced Technology Planning,
Information Systems and Technology
University of California at Berkeley