From: mgraf@sydvm1.VNET.IBM.COM (Michael Graf)
Date: Thu, 1 Oct 92 08:32:28 EST
Newsgroups: comp.sys.mac.programmer
Subject: Re: GetMenu & 32-bit Conflict Mystery
Organization: Australian Programming Centre (IBMA)
Disclaimer: This posting represents the poster's view only.
News-Software: UReply 3.0
            <1992Sep30.205349.11374@lonex.rl.af.mil>

In <1992Sep30.205349.11374@lonex.rl.af.mil> Jim Wintermyre writes:
>In article <19920923.155254.376@almaden.ibm.com>, mgraf@sydvm1.VNET.IBM.COM (Michael Graf) writes:
>>  All my programs use menus, defined by ResEdit, as MENU (and MBAR) resources,
>> and are loaded in a standard (as per many books) way. However, the following
>> will cause the compiler (THINK Pascal v4.01) to crash (with an Application
>> Zone error) UNDER 32-BIT MEMEORY ONLY !! In non-32-bit, it functions normally;
>> an application built and run (ex-THINK Pascal) functions fine under 32-bit.
>> The error appears on the line, marked <===:
>>
>>          :
>>        CONST
>>           APPLE_MENU_ID = 128;   /* have tried other resource IDs as well */
>>          :
>>        VAR
>>           aMenu : MenuHandle;
>>          :
>>         /* Get MenuBar from resource file */
>>          :
>>         aMenu := GetMenu(APPLE_MENUI_ID);        <=== /* Error at this line*/
>>         AddResMenu(aMenu,'DRVR');
>>          :
>>
>> The call to get the APPLE MENU fails under 32-bit and causes HUGE compiler
>> problems afterwards. It works fine under non-32-bit; removing that line
>> (and corresponding Apple Menu build up calls) means I get a perfectly,
>> functioning program (no Desk Accessories, of course).
>>
>>   Environment: System 7.01 (tuned v1.1.1), //ci, 20Mb memory
>>                Extensions not causing problem
>>
>>  Can anyone shed any light as to WHY this might occur under 32-bit;
>>   OR WHAT is wrong with the above means of loading the Apple menu (defined
>>   in ResEdit by selecting the Apple Menu radio button);
>>   OR WHAT in ResEdit (perhaps) is causing THINK Pascal so much grief ?
>
>Weird, I just ran into this very same problem today, and it was driving me
>absolutely nuts!  I thought maybe it was the fact that I was running on a
>Quadra, or the menu IDs were wrong or something.  In my case, it turns out
>that changing the GetMenu call to GetMHandle fixes it!  Are you reading in
>the menu bar with GetNewMBar?  If so, I think that problem has to do with
>the fact that GetNewMBar automatically reads the menus into memory.  This is
>the same thing that GetMenu does, so maybe GetNewMBar screws it up.  Anyway,
>if you try to do GetMenu BEFORE GetNewMBar, the GetMenu works, but the
>GetNewMBar crashes.  Anyway, GetMHandle works fine, and at least according
>to the THINK reference, this is the way you're supposed to get menus handles
>when you've used GetNewMBar.
>
>But then, if Rich Siegel says it's a bug in THINK Pascal, maybe I'm just
>full of it!  (But hey, it works)
>
>Jim Wintermyre
>winter@ra.rl.af.mil
>

 Jim,
  I doubt that you are 'full of it', but thanx for the suggestion. I think
that there is a problem in THINK Pascal v4.01 (hoping the update is NOT
long in coming ?), since the same code works fine for applications under
32-bit and the compiler under non-32-bit.
  Still, will give your suggestion a try.....

  Thanx, again, to all who made suggestions !!

**********************************************************************
Regards,
  Michael Graf                INTERNET:    (mgraf@sydvm1.vnet.ibm.com)
                              BITNET:      (mgraf@vnet)
**********************************************************************
Newsgroups: comp.sys.mac.programmer