• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

ResEdit and WIND resources

HippieMac

Active member
Hello everyone, does anyone happen to know how to create a blank WIND resource using ResEdit? I’m using ResEdit 2.0 with a Mac Plus and all of the temples provided include the bar at the top for buttons like the file and Apple menus but I’m just trying to figure out how to create a blank screen to build on without the bar on top. I tried covering it up using a rectangle but it must have priority over everything else because it just goes underneath the bar area. Anyone know of have any ideas on how to create a blank WIND template or preference file? Thank you
 

cheesestraws

Well-known member
I think you're confusing two separate things here, and ResEdit's preview has got the two even more muddled. The important thing here is this:

The menu bar is separate from any windows you have on the screen, and is managed separately from it. The preview in ResEdit shows the menu bar just because it is almost always displayed when any window is.

This means that whether the menu bar is displayed or not is not something that the WIND resource controls. All the WIND resource controls is the window itself.

To hide or show the menu bar, there's this article from MacTech: http://preserve.mactech.com/articles/mactech/Vol.07/07.02/MenuHide,Seek/index.html

There may well be a nicer way to do it in newer versions of the OS. I'm unsure how HyperCard does it, for example, but it may well use this trick.
 

Crutch

Well-known member
If all you want to do is hide the menu bar in a simple app that takes over the whole screen and will never re-show it, all you have to do is:

1. Set the global variable MBarHeight = 0
2. Union the region previously occupied by the menubar with the global variable GrayRgn. You can do this with (coding from memory, excuse small errors):
  • RgnHandle mBarRgn = NewRgn();
  • SetRectRgn(mBarRgn, 0, 0, screenBits.bounds.right, MBarHeight);
  • UnionRgn(mBarRgn, GrayRgn, GrayRgn);
  • DisposeRgn(mBarRgn);
  • MBarHeight = 0;
Now you can put up a full-screen window with its topleft at (0,0).

If you don’t want to put up a window and want to see the desktop under the old menubar area, or if you put up your window before hiding the menubar, you need to do the PaintBehind/CalcVisBehind stuff from the MacTech article. Otherwise, don’t worry about it.

Since each application has its own copy of MBarHeight and GrayRgn, you don’t need to put anything back when you quit. I think. I haven’t done this in a bit. If that doesn’t work, just restore them when you’re done.
 

HippieMac

Active member
Thank you for the help and I’m going to try this out as soon as get back to my computer. I’m just now learning pascal and have downloaded a lot of books but none have shown me anything like this. Do either of you have a book for pascal that y’all would recommend for building small apps and things like games? I’m using think pascal 4.0 currently because it is the only one I could find a good reference book for. I will post back as soon as I get a chance to try this out.
 

Crutch

Well-known member
The Macintosh Programming Primer by Dave Mark & Cartwright Reed was sort of the standard for a few years and covers Pascal. I would personally recommend using C (in part because it has modern uses too!), in which cased the Macintosh C Programming Primer by the same authors would be a good choice.
 

HippieMac

Active member
Thanks Crutch and that is one of the books I am using now. I tried using the code from both sources but could not get it to work last night.
is this how I’m suppose to write it? Do I need to put anything in the parenthesis by NewRgn?

procedure mBarHeight

Var
MBarHeight = 0

begin
RgnHandle mBarRgn = NewRgn();
SetRectRgn(mBarRgn, 0, 0, screenBits.bounds.right, MBarHeight);
UnionRgn(mBarRgn, GrayRgn, GrayRgn);
DisposeRgn(mBarRgn);
MBarHeight = 0;
end;
 

Crutch

Well-known member
Ah, not quite. Definitely keep reading up on Pascal coding.

MBarHeight and GrayRgn are low-memory global variables. I don’t recall if they are build into THINK Pascal, but I think so? In which case this should work.

var
mBarRgn : RgnHandle;
begin
mBarRgn = NewRgn; { no parens here in Pascal }
SetRectRgn(mBarRgn, 0, 0, screenBits.bounds.right, MBarHeight);
UnionRgn(mBarRgn, GrayRgn, GrayRgn);
DisposeRgn(mBarRgn);
MBarHeight = 0;
end
 

HippieMac

Active member
Thanks Crutch, I just tried this but it’s telling me that mBarRgn = NewRgn; does not make sense as a statement. Here is what I have if I did something wrong Please let me know. Thanks again for your help, I don’t have anyone close to ask about this stuff.
 

Attachments

  • 8F4FF4FF-34E7-4852-9DE1-6AF4E047F336.jpeg
    8F4FF4FF-34E7-4852-9DE1-6AF4E047F336.jpeg
    2.2 MB · Views: 4

Crutch

Well-known member
Sorry. I obviously haven’t used Pascal in decades … my two assignments above should use := not =

Corrected below but definitely I would advise getting to a good base level of Pascal syntax and Toolbox comfort before really trying to build off of this. The book you are using is a good place to start!

var
mBarRgn : RgnHandle;
begin
mBarRgn := NewRgn; { no parens here in Pascal }
SetRectRgn(mBarRgn, 0, 0, screenBits.bounds.right, MBarHeight);
UnionRgn(mBarRgn, GrayRgn, GrayRgn);
DisposeRgn(mBarRgn);
MBarHeight := 0;
end
 

Mu0n

Well-known member
Ah, Pascal, just outside the scope of my direct help. Here's the code I used in C ages ago, probably lifted from a MacTech article as well:


I suppose one could port C to Pascal by using the same addresses and ROM trap names.

/* Hides the menu bar by changing the content of memory location 0x0BAA, which
contains the height of the menu bar. NOTE: it cannot be done on 64k ROM macs (the
really early ones. This program has been tested under System 6.0.8 (Mac plus) and
System 7.5 (Performa class mac). There is no guarantee it would work on OSX...yet */


#include <Quickdraw.h>
#include <Events.h>
#include <Windows.h>

static short gs_dyMBar = 0;
static RgnHandle gs_hrgnMBar = NULL;

void HideMenuBar(void)
{
Rect rcMBar;
short *setMBarHeight;

setMBarHeight=(short *)0x0BAA;

if ( gs_hrgnMBar == 0L) {

gs_dyMBar = GetMBarHeight();

*setMBarHeight=0;

rcMBar = qd.screenBits.bounds;
rcMBar.bottom = rcMBar.top + gs_dyMBar;

gs_hrgnMBar = NewRgn();
RectRgn( gs_hrgnMBar, &rcMBar );
UnionRgn( GetGrayRgn(), gs_hrgnMBar, GetGrayRgn() );
PaintOne(nil,gs_hrgnMBar);
}
}

void ShowMenuBar(void)
{
short *setMBarHeight;
setMBarHeight=(short *)0x0BAA;

if( gs_hrgnMBar) {

*setMBarHeight=gs_dyMBar;
DiffRgn(GetGrayRgn(), gs_hrgnMBar, GetGrayRgn());
DisposeRgn(gs_hrgnMBar);
gs_hrgnMBar=0L;
}
}

void main()
{
EventRecord wutup;
InitGraf(&qd.thePort);
InitWindows();

SysBeep(120);
HideMenuBar();
DrawMenuBar(); /* Has no effect, as it should! */
FlushEvents(everyEvent,0);
while(wutup.what!=keyDown) GetNextEvent(keyDownMask,&wutup);

SysBeep(120);
ShowMenuBar();
DrawMenuBar();
while(!Button());

}
 

HippieMac

Active member
This is what I’ve got to so far, I tried the updated code with the help from crutch but it said that mBarHeight and gray region was not declared. I tried to correct this by doing this in the picture below but now it says I’m out of memory. Does this look right?
 

Attachments

  • image.jpg
    image.jpg
    4 MB · Views: 4

Crutch

Well-known member
MBarHeight and GrayRgn are so-called “low memory globals”. Check the THINK Pascal docs on how to access low-memory globals. I am pretty certain there is a way.

If not, to set (for example) MBarHeight you just need to write 0 to the Integer located at $BAA. (Inside Macintosh volume III gives the addresses of all the low-memory globals.)

In Pascal you could do this with something like …… (again syntax errors likely, I don’t use Pascal)

type
IntPtr = ^Integer;
var
mBarHeightPtr:IntPtr;
begin
mBarHeightPtr := IntPtr($BAA);
mBarHeight^ := 0;
end

And likewise with GrayRgn
 
Top