home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / oop / macapp3 / 186 < prev    next >
Encoding:
Text File  |  1992-12-14  |  3.6 KB  |  116 lines

  1. Newsgroups: comp.sys.mac.oop.macapp3
  2. Path: 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
  3. From: Steven McGee <mcgee@ils.nwu.edu>
  4. Subject: Re: Hiding the Menubar?
  5. Message-ID: <1992Dec14.152543.28657@ils.nwu.edu>
  6. Sender: usenet@ils.nwu.edu (Mr. usenet)
  7. Nntp-Posting-Host: mac144.ils.nwu.edu
  8. Organization: The Institute for the Learning Sciences
  9. X-Useragent: Nuntius v1.1
  10. References: <724083957.7086716@AppleLink.Apple.COM>
  11. Date: Mon, 14 Dec 1992 15:25:43 GMT
  12. Lines: 102
  13.  
  14. Here is a discussion that I pulled off of comp.sys.mac.programmer a while
  15. ago. I have not tried it but it will give a starting place.
  16.  
  17. /*Code to hide the menubar*/
  18. /*Taken from the Usenet Mac Programmer's guide, page 258-260*/
  19. /*Call remove_menubar, passing a RgnHandle to hold the desktop region*/
  20. /*The function returns the height of the menubar*/
  21. /*Call restore_menubar to return everything to normal*/
  22.  
  23.  
  24. void SetMBarHeight(int newheight) {
  25.    MBarHeight = newheight;  /*MBarHeight is a low-mem global*/
  26. }                           /*It may not be supported in the future*/
  27.  
  28.  
  29. /*remove_menubar removes the menubar and adjusts the desktop*/
  30. /* so that the menu is gone*/
  31. /*It returns the original height of the menubar and sets gray_rgn to
  32. the*/ /*original gray region */
  33.  
  34. int remove_menubar (RgnHandle gray_rgn) {
  35. int old_height;
  36. RgnHandle newgray_region;
  37. Rect newgray_rect;
  38.  
  39.    old_height = GetMBarHeight();
  40.    SetMBarHeight(0);  /*shrink menubar to 0*/
  41.  
  42.    newgray_region = NewRgn();
  43.    CopyRgn(GetGrayRgn(),gray_rgn);
  44.    SetRect(&newgray_rect,screenBits.bounds.left,screenBits.bounds.top,
  45.            screenBits.bounds.right,screenBits.bounds.bottom);
  46.    RectRgn(newgray_region,&newgray_rect);
  47.    CopyRgn(newgray_region,GetGrayRgn());
  48.    PaintOne((WindowPeek)0L,newgray_region);/*update desktop over menubar
  49. rgn*/
  50.    CalcVis((WindowPeek)0L);
  51.    
  52.    DisposeRgn(newgray_region);
  53.    return old_height;
  54. }
  55.  
  56. /*restore_menubar puts it back*/
  57. void restore_menubar(int mbarheight,RgnHandle gray_rgn) {
  58. RgnHandle current_region;
  59. Rect mbarrect;
  60. RgnHandle mbar_region;
  61. WindowPeek front;
  62.  
  63.    SetRect(&mbarrect,screenBits.bounds.left,screenBits.bounds.top,
  64.            screenBits.bounds.right,screenBits.bounds.top+mbarheight);
  65.    mbar_region = NewRgn();
  66.    RectRgn(mbar_region,&mbarrect);
  67.    current_region = NewRgn();
  68.    SetMBarHeight(mbarheight);
  69.    CopyRgn(GetGrayRgn(),current_region);
  70.    CopyRgn(gray_rgn,GetGrayRgn());
  71.    front = (WindowPeek)FrontWindow();
  72.    CalcVis(front);
  73.    CalcVisBehind(front,mbar_region);
  74.    CalcVisBehind(front,current_region);
  75.    HiliteMenu(0);
  76.    DrawMenuBar();
  77.    DisposeRgn(current_region);
  78.    DisposeRgn(mbar_region);
  79. }
  80.  
  81. /*Steve*/
  82.  
  83. ---------------------------------
  84. In article <kePQOia00WBM04mmoS@andrew.cmu.edu>, sr0o+@andrew.cmu.edu
  85. (Steven 
  86. Ritter) writes:
  87. > int remove_menubar (RgnHandle gray_rgn) {
  88. > int old_height;
  89. > RgnHandle newgray_region;
  90. > Rect newgray_rect;
  91. >  
  92. >    old_height = GetMBarHeight();
  93. >    SetMBarHeight(0);  /*shrink menubar to 0*/
  94. >    newgray_region = NewRgn();
  95. >    CopyRgn(GetGrayRgn(),gray_rgn);
  96. >    SetRect(&newgray_rect,screenBits.bounds.left,screenBits.bounds.top,
  97. >            screenBits.bounds.right,screenBits.bounds.bottom);
  98. >    RectRgn(newgray_region,&newgray_rect);
  99. >    CopyRgn(newgray_region,GetGrayRgn());
  100.  
  101. Ack! no!  Now you've just eliminated any other monitors besides your main
  102. monitor from the desktop!
  103.  
  104. Try something like:
  105.  
  106.     SetRect(&newgray_rect, screenBits.bounds.left, screenBits.bounds.top,
  107.             screenBits.bounds.right, old_height);
  108.     RectRgn(newgray_region, &newgray_rect);
  109.     UnionRgn(GrayRgn, newgray_region, GrayRgn);
  110.  
  111. or so.
  112. --
  113. Scott Lindsey <wombat@claris.com>
  114.