💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › MiscInfo › C › deskto… captured on 2023-06-14 at 18:41:15.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Newsgroups: comp.sys.apple2.programmer
Path: blue.weeg.uiowa.edu!news.uiowa.edu!uunet!news.mathworks.com!hookup!ames!waikato!comp.vuw.ac.nz!actrix.gen.nz!dempson
From: dempson@atlantis.actrix.gen.nz (David Empson)
Subject: Re: How to use resource?
Message-ID: <D129Az.54v@actrix.gen.nz>
Nntp-Posting-Host: atlantis.actrix.gen.nz
Sender: news@actrix.gen.nz (News Administrator)
Organization: Actrix - New Zealand Internet Service Providers
Date: Mon, 19 Dec 1994 13:54:34 GMT
References: <3ctg73$9pi@nuscc.nus.sg>
Lines: 179

In article <3ctg73$9pi@nuscc.nus.sg>,
Lim Thye Chean <ltchean@iss.nus.sg> wrote:
> 
> Learning to program using Orca/C 2.0. I started up with the Frame.cc program.
> Works great. But it does not use the resources. Looking up and down, finally
> found one resource using program called Frame2.pas (for Orca/Pascal 2.0) and
> Frame2.rez. Since rez should be language independent, I decided to steal
> the Frame2.rez over and used it in Frame.cc.

[snip]

> I am not sure what happens. I used GNO 2.0.4, stevie editor and Orca/C 2.0,
> 4MB GS with a harddisk. Thanks.

ORCA/C 2.0 is one possible reason for any problem.  I did similar
changes to yours (I also removed the DoAlert function, and changed
MenuAbout to use AlertWindow, as in the Pascal version), and ended up
with a working version.  I'm using ORCA/C 2.0.3, and I ran it from
ORCA/Shell.

It also works fine when I run it from GNO.

Another possible problem is that the resource fork hasn't been set up
correctly.  The frame2.make command file included with the Pascal
source does a cmpl (compile and link) to create the data fork, then
uses REZ to compile the frame2.rez file, adding a resource fork to the
file.

I prefer to compile the resources to a separate file, then use a
utility which copies just the resource fork to attach it to the
application.  (I'm using Apple's DUPLICATE program to do this; it is
one of the now vanished APW 1.1 utilities.)


With apologies to Mike, here is the source code I used to compile a
working version of frame.cc with resources.

The commands to compile, link, etc. were as follows (from ORCA):

compile frame.cc keep=frame
link frame keep=frame
compile frame2.rez keep=frame2.r
duplicate -r frame2.r frame

Here is the source code:

/****************************************************************


#pragma keep "Frame"
#pragma lint -1

#include <orca.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

#include <types.h>
#include <quickdraw.h>
#include <misctool.h>
#include <event.h>
#include <control.h>
#include <window.h>
#include <menu.h>
#include <desk.h>
#include <lineedit.h>
#include <dialog.h>

#define apple_About 257         /* Menu ID numbers */
#define file_Quit   256

typedef   int BOOL;         /* simulate boolean types */
BOOL      done;             /* tells if the program should stop */
WmTaskRec lastEvent;            /* last event returned in event loop */


/****************************************************************


#define alertID 1

void MenuAbout (void)

{
AlertWindow(5, NULL, alertID);
}


/****************************************************************


void HandleMenu (int menuNum)

{
switch (menuNum) {
   case apple_About:   MenuAbout ();
               break;

   case file_Quit:     done = TRUE;
               break;

   default:        break;
   }
HiliteMenu (FALSE, (int) (lastEvent.wmTaskData >> 16));
}


/****************************************************************


#define menuID  1

void InitMenus (void)

{
SetSysBar(NewMenuBar2(2, menuID, NULL));    /* create the menu bar */
SetMenuBar(NULL);
FixAppleMenu (1);           /* add desk accessories */
FixMenuBar ();              /* draw the completed menu bar */
DrawMenuBar ();
}

 
/****************************************************************


int main (void)

{
int event;              /* event # returned by TaskMaster */

startdesk (640);
InitMenus ();               /* set up the menu bar */
lastEvent.wmTaskMask = 0x1FFFL;     /* let Task Master do most stuff */
ShowCursor ();              /* show the cursor */

done = FALSE;               /* main event loop */
do {
   event = TaskMaster (0x076E, &lastEvent);
   switch (event) {         /* handle the events we need to */
       case wInSpecial:
       case wInMenuBar:    HandleMenu ((int) lastEvent.wmTaskData);
       default:        break;
       }
   }
while (!done);
enddesk ();
}