How To Hide the MenuBar
How To Hide the MenuBar
/*
* How to hide the menubar
* This code sample shows how to hide the menubar. It isn't something that you
* should really be doing (see the Apple Q&A stack for more), and the extra
* space might not 'work' ok (ie, it might not receive mouse-clicks and such), but
* it will enable you to draw on (or just obscure) the menu bar. Also, you should
* avoid calling ExitToShell without first calling ShowMenuBar, because you'll
* find that you have no menu bar. This code hasn't been tested with multiple monitor
* environments.
*/
// Assumes inclusion of
void Init(void);
void HideMenuBar(void);
void ShowMenuBar(void);
void
Init(void)
{
InitGraf(&thePort);
}
short oldMBarHeight;
RgnHandle mBarRgn;
void HideMenuBar()
{
Rect mBarRect;
oldMBarHeight = GetMBarHeight();
MBarHeight = 0; /* make the Menu Bar's height zero */
SetRect(&mBarRect, screenBits.bounds.left, screenBits.bounds.top,
screenBits.bounds.right, screenBits.bounds.top + oldMBarHeight);
mBarRgn = NewRgn();
RectRgn(mBarRgn, &mBarRect);
UnionRgn(GrayRgn, mBarRgn, GrayRgn);/* tell the desktop it covers the menu
* bar
*/
PaintOne(nil, mBarRgn); /* redraw desktop */
}
void ShowMenuBar()
{
MBarHeight = oldMBarHeight; /* make the menu bar's height normal */
DiffRgn(GrayRgn, mBarRgn, GrayRgn); /* remove the menu bar from the
* desktop
*/
DisposeRgn(mBarRgn);
}
main()
{
Init();
HideMenuBar();
while (!Button())
;
ShowMenuBar();
}