Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: How do I make the Menu Bar disappear Message-ID: <12865@dartvax.Dartmouth.EDU> Date: 4 Apr 89 00:53:19 GMT References: <28192@apple.Apple.COM> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Thayer School of Engineering Lines: 147 In article <28192@apple.Apple.COM> kmcentee@Apple.COM (Kevin McEntee) writes: > >Does anyone know of a quick and dirty way that a multifinder application can >make the menu bar disappear? Like in HyperCard? > > You mean like this? Earle ----------------------cut here---------------------- { This unit provides the ability to hide the Menu Bar, and to show it. When the Menu Bar is hidden, windows may be placed in the area normally used for the Menu Bar. Usage: PROCEDURE MBar_Init: Used to initialize global variables used here. Call once at beginning of application code. PROCEDURE MBar_be_Gone; Hides the Menu Bar. PROCEDURE MBar_Restore; Shows the Menu Bar. Call this whenever you are going to be put into the background. Call before Exit. The procedures in this unit will probably break under some future release of the Macintosh Operating System, because they manipulate the GrayRgn. They do work under MultiFinder 6.1a2. The most serious warning I can give concerning use of these routines is that you must never allow your application to be placed into the background with the Menu Bar hidden. This file is part of Earle R. Horton's private source code library. Earle R. Horton assumes no responsibility for any damages arising out of use of this source code for any purpose. Earle R. Horton places no restrictions on use of all or any part of this source code, except that this paragraph may not be altered or removed. Original Language: MPW Pascal, v. 2.0.2 Origination Date: March 20, 1989 } UNIT MenuBar; INTERFACE USES {$Load PasDump.dump} Memtypes, Quickdraw, OSIntf, Script, ToolIntf; CONST pop_a_long = $21DF; GrayRgn = $09EE; PROCEDURE MBar_be_Gone; PROCEDURE MBar_Restore; PROCEDURE MBar_Init; { INLINE Procedures used for setting low memory globals. } PROCEDURE SetMBarHeight(newheight:integer); INLINE smPopStack2Word,smMBarHeight; { move.w (a7)+,$0BAA } PROCEDURE SetGrayRgn(new_gray_rgn:RgnHandle); INLINE pop_a_long,GrayRgn; { move.l (a7)+,$09EE } VAR Real_MBar_Height: integer; { Copy of lowmem MBarHeight } Real_Gray_Region: RgnHandle; { Copy of GrayRgn } Hidden_Flag: Boolean; { State info } MBar_Rect: Rect; { Rect in which MBar is drawn } IMPLEMENTATION PROCEDURE MBar_Init; BEGIN Hidden_FLag := false; Real_MBar_Height := GetMBarHeight; SetRect(MBar_Rect, screenBits.bounds.left, screenBits.bounds.top, screenBits.bounds.right, screenBits.bounds.top + Real_MBar_Height); END; { Make the Menu Bar go away under MultiFinder or UniFinder. Since this procedure manipulates the Gray Region, future compatibility is unknown. } PROCEDURE MBar_be_Gone; VAR New_Gray_Region: RgnHandle; MBar_Region: RgnHandle; theWindow: WindowPeek; BEGIN IF not Hidden_Flag THEN BEGIN Hidden_Flag := true; { Get some Regions to work with. } New_Gray_Region := NewRgn; MBar_Region := NewRgn; { Set the Menu Bar height to zero. } SetMBarHeight(0); { Save the old GrayRgn. } Real_Gray_Region := GetGrayRgn; { Fix up GrayRgn to cover the old GrayRgn plus the Menu Bar Rect. } RectRgn(MBar_Region,MBar_Rect); UnionRgn(Real_Gray_Region,MBar_Region,New_Gray_Region); SetGrayRgn(New_Gray_Region); { Paint and fix up visRgn for any windows with exposed area. } theWindow := WindowPeek(FrontWindow); PaintOne(theWindow,MBar_Region); PaintBehind(theWindow,MBar_Region); CalcVis(theWindow); CalcVisBehind(theWindow,MBar_Region); DisposeRgn(MBar_Region); { Clean up, leave. } END; END; { Restore the Menu Bar and GrayRgn to normality. Call when app is put into background. } PROCEDURE MBar_Restore; VAR MBar_Region: RgnHandle; theWindow: WindowPeek; BEGIN IF Hidden_Flag THEN BEGIN Hidden_Flag := false; { (Re-use old GrayRgn.) } MBar_Region := GetGrayRgn; { Restore to original } SetGrayRgn(Real_Gray_Region); { Restore Menu Bar height } SetMBarHeight(Real_MBar_Height); { Fix up any covered windows } RectRgn(MBar_Region,MBar_Rect); theWindow := WindowPeek(FrontWindow); CalcVis(theWindow); CalcVisBehind(theWindow,MBar_Region); DisposeRgn(MBar_Region); { Draw the Menu, get out of here } HiliteMenu(0); DrawMenuBar; END; END; END.