using carbon for portability

jmullman

Registered
Hello all, I'm writing an application(it's simple... just some text and a button to quit the app). I would like for it to be able to run in OS 8.6/9.x I used Project Builder and Interface Builder to create the nib based carbon app. I've changed the target in PB to production and have removed all the debugging symbols to make a small executable. Under OSX it runs without a hitch. Under OS 8.6/9.x(different machines in a lab) it complains that it wasn't written for that version of MacOS. I have CarbonLib1.6 installed on the 'classic' machines. Any ideas or pointers to documentation? Thanks!
 
Originally posted by jmullman
Doah! Well, do you know of any docs/tutorials that don't involve using nibs? Thanks
I'm a Cocoa guy, so no... But I know that using straight Carbon calls to create an interface is rather painful. If you want classic compatiblilty (and I really don't see it being that great of an issue, with the death of Mac OS 9 and all) I suggest you take a look at some of the third-party frameworks such as PowerPlant for C++. I think the best bet is to stick with nibs and OS X.
 
As far as developing goes, I'm going to stick with OS X as much as possible. However, I have a lab of OS 9'ers that won't be upgraded any day soon. I'm just trying to make a diaglog that warns the user of the computer that they are using university property and that they may not alter the software or hardware as per the university computer use policy. Since this is just a StaticText area and a Button, I wouldn't immagine that it would be too much to do. I just can't find the docs I need to get me there on apple's web site. Thanks
 
Originally posted by jmullman
As far as developing goes, I'm going to stick with OS X as much as possible. However, I have a lab of OS 9'ers that won't be upgraded any day soon. I'm just trying to make a diaglog that warns the user of the computer that they are using university property and that they may not alter the software or hardware as per the university computer use policy. Since this is just a StaticText area and a Button, I wouldn't immagine that it would be too much to do. I just can't find the docs I need to get me there on apple's web site. Thanks
Why not take advantage of AppleScript? Like this:

display dialog "The computer you are using is University property. As per the University Computer Use Policy, you may not alter the software or hardware. If you violate the Policy, we will track you down and put you in a microwave. And set it for 10 minutes on high. You've been warned." buttons {"OK"} default button 1 with icon caution

Then save it as a run-only application.
 
Not a bad idea, but I was thinking about disabling applescript on the machines. The problem is that it's too easy to use applescript to get around security measures ie: move the security measures to the trash and reboot. I've been combating this for a couple of weeks and I'm quite ready to throttle whomsoever is doing it.
 
Originally posted by jmullman
Not a bad idea, but I was thinking about disabling applescript on the machines. The problem is that it's too easy to use applescript to get around security measures ie: move the security measures to the trash and reboot. I've been combating this for a couple of weeks and I'm quite ready to throttle whomsoever is doing it.
Have a look at StandardAlert() in Dialogs.h. It displays a standard dialog (and is avaliable in the Classic Mac OS).
 
One problem... I just looked in /Developer/Headers/FlatCarbon/Dialogs.h and all it had in it was an include for Carbon/Carbon.h. I guess what I'm trying to say is... where are the headers? Thanks again, I promise if I can find a good source of documentaion I'll stop bugging ya. ;)
 
Originally posted by jmullman
One problem... I just looked in /Developer/Headers/FlatCarbon/Dialogs.h and all it had in it was an include for Carbon/Carbon.h. I guess what I'm trying to say is... where are the headers? Thanks again, I promise if I can find a good source of documentaion I'll stop bugging ya. ;)
Don't look in the flat headers, look in /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbook.framework/Headers/Dialogs.h
 
Do you know where I can find a good referece for using this other than the header? Although it is a good reference, I really don't know the first thing about writing an apple application. I'm only a little adept at writing command line stuff on Linux.
 
Here's a simple application that should do what you want:

Code:
#include < Dialogs.h >

int main(int argc, char *argv[])
{
    InitCursor();

    StandardAlert(kAlertStopAlert, 
        "\pThis is main heading of the alert.", 
        "\pThis is the explanation of the alert.", 
        NULL,
        NULL);

    return 0;
}
 
Note that this application will need to be complied on a compilier that produces CFM binaries. Project Builder doesn't do this.
 
One thing... You can use NIB files under OS 9. I have done so myself by bundling the app as a package under MacOS 9. Of course, this still means you have to have 9.0 or later to run it as a package, but it works.

If you want more information on how to create Application packages under OS 9, Apple should have some documentation floating around, or I can post my method here. (These packages also seem to work under OS X somewhat, but not completely)
 
Okay, I checked my old project getting Nibs working with a MacOS 9 project and here is how to create a dual-use 9/X package (that should work):

- First, compile your Mach-O project in PB under OS X. This will form the basis for your package. This will run without modification under OS X.

- Then, compile the CFM module using CodeWarrior. (You should be able to compile the Mach-O binary here too if you want... but I haven't done it)

- So you should have a CFM app (may show up as a Classic app) and a Mach-O packaged app now.

- Open the package and open the Contents folder. Create a new folder inside this called 'MacOSClassic'.

- Copy the CFM app into the MacOSClassic folder (make sure it has the same name as the Mach-O binary).

- Here is the tricky part... make an alias of the CFM app now in the MacOSClassic folder in the package's root folder. Usually Command-Option-Dragging the CFM app from the MacOSClassic folder to the root package folder will do it.

So your package should now look like this if your app is called 'Shtuff' for example:

Shtuff.app/
/Contents/
/MacOS/Shtuff
/MacOSClassic/Shtuff/
/PkgInfo
/Info.plist
/Resources/ShtuffRez.nib
/Shtuff.app -> /Contents/MacOSClassic/Shtuff

Now... I am not sure if the alias needs to be named 'Shtuff.app' or 'Shtuff' in this example... I haven't exactly tried to create a dual X/9 package before now. ;)

If you want just a 9 Package... you can rid yourself of the /MacOS/ folder, but everything else still needs to be there (to be properly recognized and seen by X as a good package)... Plus you need to set the 'bundle' bit if you boot into 9 and it looks like a folder. There are 9 apps out there to package folders.

Good luck.
 
It seems that Project Builder is incapable of making any targets for OS 9. I tried to do this myself, but then I found a reference in the help section saying that it is for OS X only.

If you have the cash, try Codewarrior. If not, you can use MPW (Macintosh programmer's toolkit) which is freely available somewhere on Apple's site.

Hope this helps,
Konan
 
I should have put that label myself at the top of my post. If you want Carbon, NIBs, and OS 9 support, then my method using Codewarrior/MPW and PB will work.

For an example of a real, live, product that uses it... VPC5 is a Dual Mach-O/CFM package that will run under 9 and X without any changes.... SWEET! :)
 
Back
Top