[comp.sys.mac.programmer] menu bar

choi@skivs.UUCP (Al Choi) (05/24/89)

     I was wondering if anybody could help me in trying to mask the menu bar.
     If it is possible, I would like to display an image over the menu bar.  
     I've tried FillRect(&screenBits,black). This blacks out everything on the
     screen except the strip of bar on the top of the screen where the menu bar
     would be had I defined one.  I'm using Lightspeed C, v.3.0.  I've also try
     simply drawing a window over it, but the menu bar refuses to go under.  

     I would greatly appreciate any help or suggestions.  Thanks in advance.  

     Albert Y. Choi  : internet address choi@skivs.ski.org
		       bitnet address choi%skivs.ski.org@uunet.uu.net

minow@mountn.dec.com (Martin Minow) (05/24/89)

In article <2832@skivs.UUCP> choi@skivs.UUCP (Al Choi) asks how to draw
an image over the menu bar.

I did the following to get a full-screen window, but note that it is very
fragile: the menu bar still responds to mouse clicks, and desk accessories
or inits such as superclock don't notice that you've covered the image.  It
works on both Mac SE's and color Mac II's.  It has not been blessed by Apple.
The actual drawing was done in response to the update event.

show_window()
{
	GrafPtr			old_port;

	GetPort(&old_port);
	SelectWindow(screen_window);
	ObscureCursor();
	ShowWindow(screen_window);
	/*
	 * This is needed to get a full-screen window.
	 * It effectively hides the menu bar.  It must
	 * be after ShowWindow().
	 */
	CopyRgn(screen_window->clipRgn, screen_window->visRgn);
	SetPort(screen_window);
	InvalRect(&thePort->portRect);		/* Trigger update event	*/
	SetPort(old_port);
}

screen_window was defined as follows:
	SetRect(
	    &window_bounds,
	    0,
	    0,
	    screenBits.bounds.right - screenBits.bounds.left,
	    screenBits.bounds.bottom - screenBits.bounds.top
	);
	/*
	 * Note that this window is the size of the entire screen, including
	 * the menu bar.  The call to CopyRgn in show_window() above
	 * changes the clip region so the menu bar is covered.  I have no
	 * idea if this is strictly koscher.
	 */
	screen_window = NewWindow(
			    NIL,		/* Allocate storage	*/
			    &window_bounds,	/* Screen size		*/
			    "\p",		/* No title		*/
			    FALSE,		/* Don't draw it yet	*/
			    plainDBox,		/* Plain box		*/
			    BRING_TO_FRONT,	/* Where on screen	*/
			    FALSE,		/* No GoAway box	*/
			    0			/* No refCon		*/
			);

Hope this helps.

Martin Minow
minow%thundr.dec@decwrl.dec.com

spector@vx2.GBA.NYU.EDU (David HM Spector) (06/06/89)

In article <2832@skivs.UUCP> choi@skivs.UUCP (Al Choi) writes:
>  I was wondering if anybody could help me in trying to mask the menu bar.
>  If it is possible, I would like to display an image over the menu bar.  
>  I've tried FillRect(&screenBits,black). This blacks out everything on the
>  screen except the strip of bar on the top of the screen where the menu bar
>  would be had I defined one.  I'm using Lightspeed C, v.3.0.  I've also try
>  simply drawing a window over it, but the menu bar refuses to go under.  

How about just doing SetMBarHeight(0) (or whatever the trap is called- look
in IM-IV or IM-V)?  This should get rid of the menubar entirely, and allow
you to use that part of the screen for a regular window. Just remember to
fix the menubar before you switch out (in MultiFinder).

---
Alexis Rosen
temporarily at spector@vx2.gba.nyu.edu
alexis@rascal.ics.utexas.edu  (last resort)

tim@hoptoad.uucp (Tim Maroney) (06/08/89)

In article <2832@skivs.UUCP> choi@skivs.UUCP (Al Choi) writes:
>  I was wondering if anybody could help me in trying to mask the menu bar.
>  If it is possible, I would like to display an image over the menu bar.  

In article <479@vx2.GBA.NYU.EDU> spector@vx2.UUCP (Alexis Rosen) writes:
>How about just doing SetMBarHeight(0) (or whatever the trap is called- look
>in IM-IV or IM-V)?  This should get rid of the menubar entirely, and allow
>you to use that part of the screen for a regular window. Just remember to
>fix the menubar before you switch out (in MultiFinder).

There's no such trap.  There is a low-memory global called MBarHeight.
Like all system low-memory globals, you should avoid writing to it;
Inside Mac v5 allows it to be written only by menu bar definition
procedures, and only to be set to a value larger than the size of the
system font.

Despite the fact that it's so commonly done, overwriting the menu bar
is a violation of the Mac user interface guidelines and should be
avoided.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"Now hear a plain fact: Swedenborg has not written one new truth: Now hear
  another: he has written all the old falshoods.
 And now hear the reason.  He conversed with Angels who are all religious, &
  conversed not with Devils who all hate religion..."
    - Blake, "The Marriage of Heaven and Hell"