home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 12884 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  3.9 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!hp-cv!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sr0o+
  2. From: sr0o+@andrew.cmu.edu (Steven Ritter)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Removing the menubar?
  5. Message-ID: <kePQOia00WBM04mmoS@andrew.cmu.edu>
  6. Date: 22 Jul 92 12:35:58 GMT
  7. References: <1992Jul21.201452.23920@nic.umass.edu>
  8.     <1992Jul22.115153.20732@uswmrg.mrg.uswest.com.mrg.uswest.com>
  9. Organization: Doctoral student, Psychology, Carnegie Mellon, Pittsburgh, PA
  10. Lines: 93
  11. In-Reply-To: <1992Jul22.115153.20732@uswmrg.mrg.uswest.com.mrg.uswest.com>
  12.  
  13. >In article <1992Jul21.201452.23920@nic.umass.edu> not in use,
  14. >wonko@titan.ucc.umass.edu writes:
  15. >>I am writing a program for a client that is VERY unmac in its operation
  16. >>and I need to remove the MenuBar from the screen. I am Using Lightspeed
  17. >>pascal 4.0 and have looked in all the inside macss as well as my other
  18. >>normal sources. 
  19. >First, I assume that the program is interactive? Just a guess, don't
  20. >InitMenus() in the first place. No? 
  21. >But why? Do they find menus offensive? Did they have a traumatic
  22. >experience with a menu as a child, or do they just want to remove 
  23. >access to them to the user? What about when you are running
  24. >Multifinder/Sys7? I think there are a million questions that will 
  25. >pop up here. Would it be sufficient just to have the Apple, File, and 
  26. >Edit menus there? They wouldn't have to be functional, just stub in 
  27. >the MenuChoice() code, and don't do anything after MenuSelect().
  28.  
  29. Yeesh, we could all do without the lecture. The original poster said the
  30. program was "VERY unmac" so why not assume he had a good reason for it
  31. to be so? I've written a number of psychology experiments that hide the
  32. menubar because:
  33.  1. I need the extra screen real estate
  34.  2. It's visual distracting (for some tasks)
  35.  3. I would prefer that my subjects do the experiment rather than
  36. playing Tetris
  37.  
  38. Anyway, here's the code:
  39.  
  40. /*Code to hide the menubar*/
  41. /*Taken from the Usenet Mac Programmer's guide, page 258-260*/
  42. /*Call remove_menubar, passing a RgnHandle to hold the desktop region*/
  43. /*The function returns the height of the menubar*/
  44. /*Call restore_menubar to return everything to normal*/
  45.  
  46.  
  47. void SetMBarHeight(int newheight) {
  48.    MBarHeight = newheight;  /*MBarHeight is a low-mem global*/
  49. }                           /*It may not be supported in the future*/
  50.  
  51.  
  52. /*remove_menubar removes the menubar and adjusts the desktop*/
  53. /* so that the menu is gone*/
  54. /*It returns the original height of the menubar and sets gray_rgn to
  55. the*/ /*original gray region */
  56.  
  57. int remove_menubar (RgnHandle gray_rgn) {
  58. int old_height;
  59. RgnHandle newgray_region;
  60. Rect newgray_rect;
  61.  
  62.    old_height = GetMBarHeight();
  63.    SetMBarHeight(0);  /*shrink menubar to 0*/
  64.  
  65.    newgray_region = NewRgn();
  66.    CopyRgn(GetGrayRgn(),gray_rgn);
  67.    SetRect(&newgray_rect,screenBits.bounds.left,screenBits.bounds.top,
  68.            screenBits.bounds.right,screenBits.bounds.bottom);
  69.    RectRgn(newgray_region,&newgray_rect);
  70.    CopyRgn(newgray_region,GetGrayRgn());
  71.    PaintOne((WindowPeek)0L,newgray_region);/*update desktop over menubar rgn*/
  72.    CalcVis((WindowPeek)0L);
  73.    
  74.    DisposeRgn(newgray_region);
  75.    return old_height;
  76. }
  77.  
  78. /*restore_menubar puts it back*/
  79. void restore_menubar(int mbarheight,RgnHandle gray_rgn) {
  80. RgnHandle current_region;
  81. Rect mbarrect;
  82. RgnHandle mbar_region;
  83. WindowPeek front;
  84.  
  85.    SetRect(&mbarrect,screenBits.bounds.left,screenBits.bounds.top,
  86.            screenBits.bounds.right,screenBits.bounds.top+mbarheight);
  87.    mbar_region = NewRgn();
  88.    RectRgn(mbar_region,&mbarrect);
  89.    current_region = NewRgn();
  90.    SetMBarHeight(mbarheight);
  91.    CopyRgn(GetGrayRgn(),current_region);
  92.    CopyRgn(gray_rgn,GetGrayRgn());
  93.    front = (WindowPeek)FrontWindow();
  94.    CalcVis(front);
  95.    CalcVisBehind(front,mbar_region);
  96.    CalcVisBehind(front,current_region);
  97.    HiliteMenu(0);
  98.    DrawMenuBar();
  99.    DisposeRgn(current_region);
  100.    DisposeRgn(mbar_region);
  101. }
  102.  
  103. /*Steve*/
  104.