Article View: comp.sys.mac.oop.macapp3
Article #133Re: Hiding the Menubar?
From: Steven McGee
Date: Mon, 14 Dec 1992 15:25
Date: Mon, 14 Dec 1992 15:25
102 lines
3833 bytes
3833 bytes
Here is a discussion that I pulled off of comp.sys.mac.programmer a while
ago. I have not tried it but it will give a starting place.
/*Code to hide the menubar*/
/*Taken from the Usenet Mac Programmer's guide, page 258-260*/
/*Call remove_menubar, passing a RgnHandle to hold the desktop region*/
/*The function returns the height of the menubar*/
/*Call restore_menubar to return everything to normal*/
void SetMBarHeight(int newheight) {
MBarHeight = newheight; /*MBarHeight is a low-mem global*/
} /*It may not be supported in the future*/
/*remove_menubar removes the menubar and adjusts the desktop*/
/* so that the menu is gone*/
/*It returns the original height of the menubar and sets gray_rgn to
the*/ /*original gray region */
int remove_menubar (RgnHandle gray_rgn) {
int old_height;
RgnHandle newgray_region;
Rect newgray_rect;
old_height = GetMBarHeight();
SetMBarHeight(0); /*shrink menubar to 0*/
newgray_region = NewRgn();
CopyRgn(GetGrayRgn(),gray_rgn);
SetRect(&newgray_rect,screenBits.bounds.left,screenBits.bounds.top,
screenBits.bounds.right,screenBits.bounds.bottom);
RectRgn(newgray_region,&newgray_rect);
CopyRgn(newgray_region,GetGrayRgn());
PaintOne((WindowPeek)0L,newgray_region);/*update desktop over menubar
rgn*/
CalcVis((WindowPeek)0L);
DisposeRgn(newgray_region);
return old_height;
}
/*restore_menubar puts it back*/
void restore_menubar(int mbarheight,RgnHandle gray_rgn) {
RgnHandle current_region;
Rect mbarrect;
RgnHandle mbar_region;
WindowPeek front;
SetRect(&mbarrect,screenBits.bounds.left,screenBits.bounds.top,
screenBits.bounds.right,screenBits.bounds.top+mbarheight);
mbar_region = NewRgn();
RectRgn(mbar_region,&mbarrect);
current_region = NewRgn();
SetMBarHeight(mbarheight);
CopyRgn(GetGrayRgn(),current_region);
CopyRgn(gray_rgn,GetGrayRgn());
front = (WindowPeek)FrontWindow();
CalcVis(front);
CalcVisBehind(front,mbar_region);
CalcVisBehind(front,current_region);
HiliteMenu(0);
DrawMenuBar();
DisposeRgn(current_region);
DisposeRgn(mbar_region);
}
/*Steve*/
---------------------------------
In article <kePQOia00WBM04mmoS@andrew.cmu.edu>, sr0o+@andrew.cmu.edu
(Steven
Ritter) writes:
>
> int remove_menubar (RgnHandle gray_rgn) {
> int old_height;
> RgnHandle newgray_region;
> Rect newgray_rect;
>
> old_height = GetMBarHeight();
> SetMBarHeight(0); /*shrink menubar to 0*/
>
> newgray_region = NewRgn();
> CopyRgn(GetGrayRgn(),gray_rgn);
> SetRect(&newgray_rect,screenBits.bounds.left,screenBits.bounds.top,
> screenBits.bounds.right,screenBits.bounds.bottom);
> RectRgn(newgray_region,&newgray_rect);
> CopyRgn(newgray_region,GetGrayRgn());
Ack! no! Now you've just eliminated any other monitors besides your main
monitor from the desktop!
Try something like:
SetRect(&newgray_rect, screenBits.bounds.left, screenBits.bounds.top,
screenBits.bounds.right, old_height);
RectRgn(newgray_region, &newgray_rect);
UnionRgn(GrayRgn, newgray_region, GrayRgn);
or so.
--
Scott Lindsey <wombat@claris.com>
Technical Details
Message-ID:
<1992Dec14.152543.28657@ils.nwu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!mp.cs.niu.edu!uxa.ecn.bgu.edu!news.ils.nwu.edu!nuntiusReferences:
<724083957.7086716@AppleLink.Apple.COM>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.mac.oop.macapp3 Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!mp.cs.niu.edu!uxa.ecn.bgu.edu!news.ils.nwu.edu!nuntius From: Steven McGee <mcgee@ils.nwu.edu> Subject: Re: Hiding the Menubar? Message-ID: <1992Dec14.152543.28657@ils.nwu.edu> Sender: usenet@ils.nwu.edu (Mr. usenet) Nntp-Posting-Host: mac144.ils.nwu.edu Organization: The Institute for the Learning Sciences X-Useragent: Nuntius v1.1 References: <724083957.7086716@AppleLink.Apple.COM> Date: Mon, 14 Dec 1992 15:25:43 GMT Lines: 102