[comp.sys.mac.programmer] Getting Rid of the Menu Bar

alves@castor.usc.edu (William Alves) (08/05/89)

I'm told this question pops up periodically in this newsgroup, but,
nevertheless, I haven't been on long enough to see the answer. So
feel free to email responses. Also, are some ways "better" than others?
Thanks in advance!

Bill Alves
alves@castor.usc.edu

CXT105@psuvm.psu.edu (Christopher Tate) (01/22/91)

I *know* this has been batted around before, so if someone can just take
pity on a poor helpless programmer and tell me the vital nitty gritty,
I'll be much obliged....

How do I make the menu bar go away, so that I can draw where it usually
sits?  Specifically, I want to open a window the size of the screen, and
obscure the menu bar with it.  I'm writing a screen saver (yes, I know;
the last thing we need is *another* screen saver, but there are legal
reasons for this project), and the window has to be put up (and the menu
bar taken care of) from within a trap patch.  I've gotten the window to
display beautifully, but the menu bar stays visible.

As I recall, getting rid of the menu bar involves setting the low-memory
global MBarHeight to zero, and calling DrawMenuBar().  There's more to it
than that, though, because I'm *doing* that, and it doesn't work!  Do I
need to set the clip region of the Window Manager GrafPort to include the
menu bar?  That sounds pretty hairy....

I'm using THINK C, so my globals are referenced off of A4 instead of A5.
Is this going to cause problems?  (I'm saving and restoring ALL registers
that I use in the trap patches, and I'm *NOT* tail patching anything!)
The traps I'm patching are _SystemEvent (to look for events that will cancel
or delay the screen-saving) and _SystemTask (to get periodic time without
all the hassle of VBL tasks).

-------
Christopher Tate                   |    somewhere i have never travelled,
cxt105@psuvm.psu.edu               |    gladly beyond any experience,
 ..!psuvax1!psuvm.bitnet!cxt105    |    your eyes have their silence.

mxmora@unix.SRI.COM (Matt Mora) (01/23/91)

There is an article in the UMPG about hiding the menubar. Its in pascal
but I'm sure C programmers have no problem with converting Pascal to C :-)

Matt



-- 
___________________________________________________________
Matthew Mora                |  my Mac  Matt_Mora@QM.SRI.COM
SRI International           |  my SUN   mxmora@unix.sri.com
___________________________________________________________

hairston@henry.ece.cmu.edu (David Hairston) (01/23/91)

[CXT105@psuvm.psu.edu (Christopher Tate) writes:]
[] How do I make the menu bar go away, so that I can draw where it usually
[] sits?  Specifically, I want to open a window the size of the screen, and
[] obscure the menu bar with it.  I'm writing a screen saver (yes, I know;
[] the last thing we need is *another* screen saver, but there are legal
[] reasons for this project), and the window has to be put up (and the menu
[] bar taken care of) from within a trap patch.  I've gotten the window to
[] display beautifully, but the menu bar stays visible.
[]
[] As I recall, getting rid of the menu bar involves setting the low-memory
[] global MBarHeight to zero, and calling DrawMenuBar().  There's more to it
[] than that, though, because I'm *doing* that, and it doesn't work!  Do I
[] need to set the clip region of the Window Manager GrafPort to include the
[] menu bar?  That sounds pretty hairy....

try to get a hold of Lunarmobiscuit's Darkness or Tom Dowdy's Darkside
of the Mac (should be available at sumex) for example source code.

i think there are two strategies for getting rid of the menu bar (i've
only used one myself, haven't figured the other one out yet ...)

1) the window manager likes to enforce the menu bar so you have to
"override" this intrusion.  setting MBarHeight = 0 and then doing
a DrawMenuBar() is useful for "cooperative" code (i.e. this will
get rid of SuperClock).  you can draw in the menu bar by adding that
region to your window's visRgn.  as an example, you could get the
gdRect of the screen of interest and RectRgn() it to a region and
then UnionRgn() this to ()->visRgn.  overkill but it's simple ...

2) haven't tried this ... but the idea is to get the window manager
to do your dirty work for you.  since the window manager determines
the menu bar height from the size of the system font, you have to
"convince" the window manager that the system font has height 0.
the manager manager will then automatically give you a visRgn over
the entire screen and not draw the menu bar, etc.  if anyone has
done this and is willing to share a pointer, i'd like to hear
about it ...

[] I'm using THINK C, so my globals are referenced off of A4 instead of A5.
[] Is this going to cause problems?  (I'm saving and restoring ALL registers
[] that I use in the trap patches, and I'm *NOT* tail patching anything!)
[] The traps I'm patching are _SystemEvent (to look for events that will
[] cancel or delay the screen-saving) and _SystemTask (to get periodic time
[] without all the hassle of VBL tasks).

_personally_, i think a screensaver should not involve trap patches.
i believe you can do all you want simply using MultiFinder but,
obviously, you have to assume MultiFinder.  with system 7, that's
not a bad assumption ... ;)

  -dave-  
hairston@henry.ece.cmu.edu

john@newave.UUCP (John A. Weeks III) (01/24/91)

In article <91021.231449CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:

> How do I make the menu bar go away, so that I can draw where it usually
> sits?  Specifically, I want to open a window the size of the screen, and
> obscure the menu bar with it.

The "Macintosh Programming Primer" volume 1 tells you how to do this.
Basically, you just set a global variable called MBarHeight to zero,
then join a region covering the menu bar to an existing window.  The
book gives the exact details.

> I'm writing a screen saver (yes, I know;
> the last thing we need is *another* screen saver, but there are legal
> reasons for this project), and the window has to be put up (and the menu
> bar taken care of) from within a trap patch.

You might want to consider writing a module for After Dark or Pyro
rather than reinventing the wheel.  In fact, you can make some types of
specailized screen savers in After Dark without programming, such as 
slide shows, logos, messages, and password protection.

-john-

-- 
===============================================================================
John A. Weeks III               (612) 942-6969               john@newave.mn.org
NeWave Communications                 ...uunet!rosevax!tcnet!wd0gol!newave!john
===============================================================================

bin@primate.wisc.edu (Brain in Neutral) (01/26/91)

From article <614@newave.UUCP>, by john@newave.UUCP (John A. Weeks III):
> The "Macintosh Programming Primer" volume 1 tells you how to do this.
> Basically, you just set a global variable called MBarHeight to zero,
> ...

Make sure you're not running on a 64K ROM machine first (are there any
left?), since they don't have that global.
--
Paul DuBois
dubois@primate.wisc.edu