From: owner-csmp@ugrad.ece.mcgill.ca Subject: csmp digest Vol 4 No 054 C.S.M.P. Digest Tue, 02 Jun 98 Volume 4 : Issue 54 Today's Topics: AESend() question ANSI C binary file access Communicating with ADB device Get Graphics Device PixMap without cursor on it? HiliteControl'ing a textEdit How do I print hairlines?? Pixels in PixMap? Tcl-Tk for mac? [Q] Detecting shut down [Q] Quicktime: How to create, then play, a movie in RAM? [Q] Sending an 'odoc' event to an application. The Comp.Sys.Mac.Programmer Digest is moderated by Mark Aiken (marka@ee.mcgill.ca). The digest is a collection of article threads from the internet newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and csmp.games. It is designed for people who read news semi-regularly and want an archive of the discussions. If you don't know what a newsgroup is, you probably don't have access to it. Ask your systems administrator(s) for details. If you don't have access to news, you may still be able to post messages to the group by using a mail server like anon.penet.fi (mail help@anon.penet.fi for more information). Each issue of the digest contains one or more sets of articles (called threads), with each set corresponding to a 'discussion' of a particular subject. The articles are not edited; all articles included in this digest are in their original posted form (as received by our news server at ee.mcgill.ca). Article threads are not added to the digest until the last article added to the thread is at least two weeks old (this is to ensure that the thread is dead before adding it to the digest). Article threads that consist of only one message are generally not included in the digest. The digests can be obtained by email, ftp or through the World Wide Web. If you want to receive the digest by mail, send email to majordomo@ee.mcgill.ca with no subject and one of the following commands as body: help Sends you a summary of commands subscribe csmp Adds you to the mailing list unsubscribe csmp Removes you from the list Once you have subscribed, you will automatically receive each new issue as it is created. Back issues are available by ftp from Info-Mac mirror sites in the per/csmp subdirectory, e.g. ftp://sumex-aim.stanford.edu/info-mac/per/csmp/ The contents of all back issues can be searched by accessing the following URL, courtesy of Andrew Barry (ajbarry@ozemail.com.au): http://marvin.stattech.com.au/search.html They can also be searched through the following URLs, thanks to Tim Tuck (Tim.Tuck@sensei.com.au): http://wais.sensei.com.au/searchform.html wais://wais.sensei.com.au:210/csmp? ------------------------------------------------------- >From Julian Hsiao Subject: AESend() question Date: Sat, 09 May 1998 12:42:16 -0400 Organization: Home I have a program which uses the AESend() function to ask finder to open a specific document. The call works, but when it loads the document's creator, the application quits with type 2 error. I tried changing the sendMode from kAENoReply to kAEWaitReply, then it works if I only open one document, else the same thing happenes. Am I missing something? Julian Hsiao +++++++++++++++++++++++++++ >From ALX@Ravenware.com (Alex Kinnison) Date: Sat, 09 May 1998 12:58:15 -0700 Organization: Ravenware Software In article <35548766.768B0813@ix.netcom.com>, ayukawa@ix.netcom.com wrote: Julian, What do this.... > The call works, but when it loads the document's creator, > the application quits with type 2 error. exactly mean? When what the Finder, your app, the new app? "loads the documents creator " Do you mean when the Finder launches the application that created the document? Do you mean when you get the creator type from the file info passed in as an FSSpec? Love to help, but more specifics would be best. +++++++++++++++++++++++++++ >From hiking1@magicpubs.com (Michael) Date: Sun, 10 May 1998 12:36:10 -0700 Organization: Magic Publications > I have a program which uses the AESend() function to ask finder to open a > specific document. The call works, but when it loads the document's creator, > the application quits with type 2 error. I tried changing the sendMode from > kAENoReply to kAEWaitReply, then it works if I only open one document, else > the same thing happenes. Am I missing something? The difference between kAENoReply and kAEWaitReply only affects whether your app waits for the Apple Event to finish before moving on (basically, whether the AE call is synchronous or asynchronous). If things appear different, i'm willing to bet it's because the kAEWaitReply is delaying reporting the error (because your app will now wait until the AE times out), and that nothing else is different. Have you tried prototyping this in AppleScript? I usually prototype all my AE stuff in AppleScript. You can then use something like AETracker or CaptureAE to figure out which Apple Events to use, or even faster and easier still, you could just embed the AppleScript in your app using Embedded AppleScript Widgets: http://www.magicpubs.com/mac/aswidgets/ This is quick and easy and, for most applications, executes almost as fast as Apple Events coded directly in C. -- In all matters of opinion, our adversaries are insane. -- Mark Twain +++++++++++++++++++++++++++ >From Julian Hsiao Date: Mon, 11 May 1998 17:14:14 -0400 Organization: Home Alex Kinnison wrote: > When what the Finder, your app, the new app? > "loads the documents creator " Do you mean when the Finder launches the > application that created the document? Do you mean when you get the > creator type from the file info passed in as an FSSpec? > Love to help, but more specifics would be best. I pass the FSSpec to NewAliasMinimal() and get an alias handle to the file I want to open, then I pass the alias handle to AESend() which tells finder to open the file pointed by the alias handle. Suppose the file is created by BBEdit, BBEdit will be launched, but it will immideately quit with type 2 error. Then I experiment with the sendMode parameter of AESend(), and found that if I change kAENoReply (which I originally use) to kAEWaitReply, then BBEdit won't quit and the document will get opened. However, if I repeat the operation right afterwards, BBEdit would again quit with type 2 error. I trie with different apps, and the only program that didn't crash is SimpleText; it shows a weird error instead. Thanks. Julian Hsiao +++++++++++++++++++++++++++ >From correia@barebones.com (Jim Correia) Date: Mon, 11 May 1998 20:11:40 -0400 Organization: Bare Bones Software, Inc. In article <35576A21.D666B763@ix.netcom.com>, ayukawa@ix.netcom.com wrote: > Alex Kinnison wrote: > > > When what the Finder, your app, the new app? > > "loads the documents creator " Do you mean when the Finder launches the > > application that created the document? Do you mean when you get the > > creator type from the file info passed in as an FSSpec? > > Love to help, but more specifics would be best. > > I pass the FSSpec to NewAliasMinimal() and get an alias handle to the file I > want to open, then I pass the alias handle to AESend() which tells finder to > open the file pointed by the alias handle. Suppose the file is created by > BBEdit, BBEdit will be launched, but it will immideately quit with type 2 > error. The send mode should have little to do with it. What does your code look like. Post the snippet. -- Jim Correia Bare Bones Software, Inc. correia@barebones.com +++++++++++++++++++++++++++ >From Julian Hsiao Date: Tue, 12 May 1998 12:15:55 -0400 Organization: Home Jim Correia wrote: > The send mode should have little to do with it. What does your code look > like. Post the snippet. void EditTemplate() { FSSpec file; Str255 filename; const OSType signature = 'MACS'; AppleEvent theEvent, reply; AEAddressDesc appID; AliasHandle alias; // Decide what to put into filename AECreateDesc(typeApplSignature, &signature, sizeof(signature), &appID); AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, &appID, kAutoGenerateReturnID, kAnyTransactionID, &theEvent); AEDisposeDesc(&appID); FSMakeFSSpec(vRefNum, parID, filename, &file); NewAliasMinimal(&file, &alias); HLock((char **)alias); AEPutParamPtr(&theEvent, keyDirectObject, typeAlias, StripAddress(*alias), (**alias).aliasSize); DisposeHandle((char **)alias); AESend(&theEvent, &reply, kAEWaitReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL); } vRefNum and parID are global variables. The original code come from a source sample in info-mac, and I modified it a bit to fit my need. Thanks. Julian Hsiao --------------------------- >From dtisdall@mv.igs.net (Dylan Tisdall) Subject: ANSI C binary file access Date: Wed, 29 Apr 1998 12:40:24 -0400 Organization: IGS - Information Gateway Services Hi, I'm writing a simple program in ANSI C which is supposed to read in a file using the standard fread() function. This works fine on the PCs and UNIX systems I've tested it on, but on my Macs, it misses the entire resource fork. Since the program is supposed to recreate the files at the other end (i.e. fwrite() the data into a new file), I need to read the resources, otherwise the mac files are useless. If anyone knows how I can get the resource fork read in with ANSI C (or with as few Toolbox calls as possible), I'd appreciate hearing from you. I can be emailed at mdtisdal@undergrad.math.uwaterloo.ca. If it helps, I'm using the latest version of CodeWarrior (although I can't find a compiler setting). Dylan. +++++++++++++++++++++++++++ >From MWRon@metrowerks.com (MW Ron) Date: Wed, 29 Apr 1998 20:46:33 -0400 Organization: Metrowerks Corporation In article , dtisdall@mv.igs.net (Dylan Tisdall) wrote: >Hi, > >I'm writing a simple program in ANSI C which is supposed to read in a file >using the standard fread() function. This works fine on the PCs and UNIX >systems I've tested it on, but on my Macs, it misses the entire resource >fork. Since the program is supposed to recreate the files at the other end >(i.e. fwrite() the data into a new file), I need to read the resources, >otherwise the mac files are useless. I don't understand this, if you read and write using fread and fwrite the data file should be OK. Ron -- What's new in Pro 3 http://www.metrowerks.com/desktop/pro/ METROWERKS Ron Liechty "Software at Work" MWRon@metrowerks.com +++++++++++++++++++++++++++ >From William Edward Woody Date: Wed, 29 Apr 1998 20:37:15 -0700 Organization: In Phase Consulting MW Ron wrote: > In article , > dtisdall@mv.igs.net (Dylan Tisdall) wrote: > >Hi, > > > >I'm writing a simple program in ANSI C which is supposed to read in a file > >using the standard fread() function. This works fine on the PCs and UNIX > >systems I've tested it on, but on my Macs, it misses the entire resource ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > >fork. Since the program is supposed to recreate the files at the other end ^^^^ > >(i.e. fwrite() the data into a new file), I need to read the resources, > >otherwise the mac files are useless. > > I don't understand this, if you read and write using fread and fwrite the > data file should be OK. On the Macintosh, the resource fork is separate from the data fork. ANSI routines fopen(), etc., only operate on the data fork. (Think of the resource fork and the data fork as two separate files under the same file name. The resource fork contains a collection of objects (resources), while the data fork is the traditional PC/UNIX byte stream.) If you wish to copy a Macintosh file, resources and all, you must use the OS routines FSpOpenRF(), FSRead(), etc., to open, manipulate, and copy the resource fork. Of course this means that if you are transfering files across a network stream you will have to come up with some sort of protocol specifying where the data fork ends and the resource fork begins; MacBinary is one such (standard) protocol. If you wish to completely recreate the file completely, including all of the finder attributes (such as the creator/type, finder bits, etc), you will have to use other MacOS routines to get this data. (The equivalent to 'finder bits' does not exist on the PC or UNIX; these are invisible data fields that are maintained in the directory along with the file name that specifies things like who owns the file, and what color it is under the Finder.) Hope this helps. - Bill -- William Edward Woody | In Phase Consulting woody@alumni.caltech.edu | Macintosh & MS Windows Development http://www.alumni.caltech.edu/~woody | http://www.pandawave.com/ +++++++++++++++++++++++++++ >From trumbull@cs.yale.edu (Ben Trumbull) Date: Thu, 30 Apr 1998 01:45:25 -0400 Organization: Yale University In article , MWRon@metrowerks.com (MW Ron) wrote: > In article , > dtisdall@mv.igs.net (Dylan Tisdall) wrote: > > >Hi, > > > >I'm writing a simple program in ANSI C which is supposed to read in a file > >using the standard fread() function. This works fine on the PCs and UNIX > >systems I've tested it on, but on my Macs, it misses the entire resource > >fork. Since the program is supposed to recreate the files at the other end > >(i.e. fwrite() the data into a new file), I need to read the resources, > >otherwise the mac files are useless. > > I don't understand this, if you read and write using fread and fwrite the > data file should be OK. Ron, time to grab some coffee :) You'll need to open and copy the resource fork separately. fread and fwrite won't work with resource forks. Probably the easiest way for you to adjust a program using fread is to #include (in MSL C:MSL Mac folder). Then call OSErr __path2fss(const char * pathName, FSSpecPtr spec); Take the FSSpecPtr and pass it to FSpOpenRF (a file manager call). Then call FSRead, FSWrite, and FSClose, as appropriate. Alternatively, you could just download the free "MoreFiles" package and build that source. Then call its FSpFileCopy function with the FSSpecPtr and you're all done. MoreFiles has all the source, so you can see how they copy the resource fork. It also has its own path2fss function. terminally curious, Ben ___________________________________________________________________ Benjamin Trumbull trumbull@cs.yale.edu Yale University You can't be in hell; you can still read your e-mail +++++++++++++++++++++++++++ >From MWRon@metrowerks.com (MW Ron) Date: Thu, 30 Apr 1998 09:23:26 -0400 Organization: Metrowerks Corporation In article <3547F1EB.20D7ADA8@alumni.caltech.edu>, William Edward Woody wrote: >MW Ron wrote: >> I don't understand this, if you read and write using fread and fwrite the >> data file should be OK. >If you wish to copy a Macintosh file, resources and all, you must use >the OS routines FSpOpenRF(), FSRead(), etc., to open, manipulate, and >copy the resource fork. Oh, I misunderstood the question. Thanks Ben and Woody Ron -- What's new in Pro 3 http://www.metrowerks.com/desktop/pro/ METROWERKS Ron Liechty "Software at Work" MWRon@metrowerks.com +++++++++++++++++++++++++++ >From William Edward Woody Date: Thu, 30 Apr 1998 22:35:58 -0700 Organization: In Phase Consulting MW Ron wrote: > Oh, I misunderstood the question. > > Thanks Ben and Woody No prob. Thing is, I misunderstood the question the first couple of times around as well... -- William Edward Woody | In Phase Consulting woody@alumni.caltech.edu | Macintosh & MS Windows Development http://www.alumni.caltech.edu/~woody | http://www.pandawave.com/ +++++++++++++++++++++++++++ >From "John Daniel" Date: 04 May 1998 23:06:37 EDT Organization: Concentric Internet Services On Wed, Apr 29, 1998 10:40 AM, Dylan Tisdall wrote: >I'm writing a simple program in ANSI C which is supposed to read in a file >using the standard fread() function. This works fine on the PCs and UNIX >systems I've tested it on, but on my Macs, it misses the entire resource >fork. Since the program is supposed to recreate the files at the other end >(i.e. fwrite() the data into a new file), I need to read the resources, >otherwise the mac files are useless. > >If anyone knows how I can get the resource fork read in with ANSI C (or >with as few Toolbox calls as possible), I'd appreciate hearing from you. I >can be emailed at mdtisdal@undergrad.math.uwaterloo.ca. If it helps, I'm >using the latest version of CodeWarrior (although I can't find a compiler >setting). > By now I assume you know the reason why you are having problems. However, I have a better idea that no one has posted yet. Go into the Mac specific parts of MSL and find file fopen.c (or it could be open.c) and make a copy of it. Call it fopen_rsrc.c or something like that. You should be able to make a few modifications and have it open the resource fork instead of the data fork. Also, there is a segment about truncating that needs to be commented out. You don't want to truncate the data fork when you open the resource fork. Then, you can do something like this: FILE * in = fopen_rsrc("myfile.dat"); I have done this before and it did work. However, I have since gone to a better, OO method of my own design (that puts MSL to shame BTW). But I probably have it on backup. Still, I don't know if I could legally post the code or give it away since it is based on MSL. But any halfway decent Mac programmer should be able to make these changes. Just change the FSpOpenDF to FSpOpenRF, yada, yada, yada. If I get an OK from MW Ron, I might dig up my old code and post it. John Daniel Harmony Software info@harmonysoftware.com www.harmonysoftware.com "Just because you're paranoid doesn't mean they aren't out to get you." +++++++++++++++++++++++++++ >From MWRon@metrowerks.com (MW Ron) Date: Tue, 05 May 1998 10:17:43 -0400 Organization: Metrowerks Corporation In article , "John Daniel" wrote: >If I get an OK from MW Ron, I might dig up my old code and post it. You will not get an OK from me, the MSL Sources and headers are copyrighted and can only be distributed with CodeWarrior. If you can do a diff that would be the way to go. Ron -- What's new in Pro 3 http://www.metrowerks.com/desktop/pro/ METROWERKS Ron Liechty "Software at Work" MWRon@metrowerks.com +++++++++++++++++++++++++++ >From MWRon@metrowerks.com (MW Ron) Date: Tue, 05 May 1998 12:15:17 -0400 Organization: Metrowerks Corporation In article , trumbull@cs.yale.edu (Ben Trumbull) wrote: >Download "MoreFiles" from your favorite mac file archive. No need to do that, just look in the Tools CD : Cool Demos, SDKs, & Tools : SDKs & Libraries : MoreFiles_1.4.8.sit I think the point was to make the standard library file functions do Mac features it is not designed for but may be available on other systems. Ron -- Temporary mail address rliechty@ameritech.net METROWERKS Ron Liechty "Software at Work" MWRon@metrowerks.com +++++++++++++++++++++++++++ >From trumbull@cs.yale.edu (Ben Trumbull) Date: Tue, 05 May 1998 11:51:58 -0400 Organization: Unspecified Services In article , MWRon@metrowerks.com (MW Ron) wrote: > In article , "John Daniel" > wrote: > > > >If I get an OK from MW Ron, I might dig up my old code and post it. > > You will not get an OK from me, the MSL Sources and headers are copyrighted > and can only be distributed with CodeWarrior. If you can do a diff that > would be the way to go. Guys, Download "MoreFiles" from your favorite mac file archive. It's Apple DTS sample code and it gives you express permission to do anything you want to it except modify it and still claim it's from Apple. MoreFiles is great. It does everything you want, and ten thousand things you never knew you needed. It's source code and a metrowerks project. terminally curious, Ben ___________________________________________________________________ Benjamin Trumbull trumbull@cs.yale.edu Yale University You can't be in hell; you can still read your e-mail --------------------------- >From polygon@hotmail.com (PaiChan) Subject: Communicating with ADB device Date: Wed, 13 May 1998 08:02:52 GMT Organization: TWC Road Runner, San Diego, CA Hello, I am wondering what command I send to a ADB device such as the keyboard to toggle the LEDs. Wouldn't it be in this order: short CountADBs(void); GetIndADB(ADBDataBlock *info,short devTableIndex); OSErr ADBOp(Ptr data,ProcPtr compRout,Ptr buffer,short commandNum); I am just not sure on which command to send the keyboard... Is it documented somehwhere in IM? >From Robert Hoopes polygon@hotmail.com +++++++++++++++++++++++++++ >From pbaxter@nospam.assistivetech.com (me) Date: Wed, 13 May 1998 09:02:13 -0400 Organization: (none) In article , polygon@hotmail.com (PaiChan) wrote: > Hello, > > > I am wondering what command I send to a ADB device such as the > keyboard to toggle the LEDs. > > Wouldn't it be in this order: > > short CountADBs(void); > GetIndADB(ADBDataBlock *info,short devTableIndex); > OSErr ADBOp(Ptr data,ProcPtr compRout,Ptr buffer,short commandNum); > > > I am just not sure on which command to send the keyboard... > Is it documented somehwhere in IM? > > > From Robert Hoopes > polygon@hotmail.com Hi, Here is a small PPC program I wrote to make an extended keyboard blink its leds. IMPORTANT: This is PPC only.... 68K would require writting glue for the ADBCompletion routine. If you want the 68K glue email me. Paul pbaxter@assistivetech.com #include #include #include #define kKeyBoardAddr 2 #define kExtendedKeyBoardType 2 #define kListenMask 0x08 #define kTalkMask 0x0C #define kFlushMask 0x01 #define kLEDRegister 2 #define kLEDValueMask 0x07 #define kTimesToTest 5 #define kBlinkDelay 10 #define kDataSize 9 /* Prototypes */ void Initialize(void); void DoADBTest(void); void BlinkLEDs(ADBAddress adbaddr); OSErr ReadLEDs(char* value, char* buffer, ADBAddress adbaddr); OSErr SetLEDs(char value, char* buffer, ADBAddress adbaddr); OSErr SendADBCommand(Ptr buffer, short command, ADBCompletionUPP complete); void WaitForCompletion(void); pascal void ADBCompletion(Ptr buffer, long refCon, long command); Boolean gABDCompleteCalled = false; ADBCompletionUPP gADBComplete = nil; int main(void) { Initialize(); DoADBTest(); return 0; } //MW specified argument and return type. void Initialize(void) { /* Initialize all the needed managers. */ InitGraf(&qd.thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(nil); InitCursor(); } void DoADBTest(void) { ADBAddress adbaddr; ADBDataBlock adbinfo; short adbcount, adbindex; gADBComplete = NewADBCompletionProc(ADBCompletion); if (gADBComplete) { adbcount = CountADBs(); for (adbindex = 1; adbindex <= adbcount; adbindex++) { adbaddr = GetIndADB(&adbinfo,adbindex); if (adbinfo.origADBAddr == kKeyBoardAddr && adbinfo.devType == kExtendedKeyBoardType) BlinkLEDs(adbaddr); } DisposeRoutineDescriptor(gADBComplete); gADBComplete = nil; } } void BlinkLEDs(ADBAddress adbaddr) { unsigned long finalTicks; short count; char buffer[kDataSize], setvalues[] = { // bits 0 1 2 -- set means OFF 6, 5, 3, 5, 6, 5, 3, 5, 2, 5, 2, 5 }; char LEDValue; char setLEDValue; OSErr err; #define kNumSetValues sizeof(setvalues) / sizeof(char) err = ReadLEDs(&LEDValue, buffer, adbaddr); if (!err) { for (count = 0; (!err) && (count < kTimesToTest); count++) { for (setLEDValue = 0; (!err) && (setLEDValue < kNumSetValues); setLEDValue++) { err = SetLEDs(setvalues[setLEDValue], buffer, adbaddr); Delay(kBlinkDelay, &finalTicks); } } err = SetLEDs(LEDValue, buffer, adbaddr); } WaitForCompletion(); } OSErr ReadLEDs(char* value, char* buffer, ADBAddress adbaddr) { short command; OSErr err; memset(buffer,0, kDataSize); command = adbaddr * 16 + kTalkMask + kLEDRegister; *value = 0; err = SendADBCommand(buffer, command, gADBComplete); if (!err) { WaitForCompletion(); *value = buffer[2] & kLEDValueMask; } else { printf("\t\t\tError Reading LEDs\n"); } return err; } OSErr SetLEDs(char value, char* buffer, ADBAddress adbaddr) { short command; char LEDvalue; OSErr err; err = ReadLEDs(&LEDvalue, buffer, adbaddr); if (!err) { command = adbaddr * 16 + kListenMask + kLEDRegister; buffer[2] &= ~kLEDValueMask; buffer[2] |= value; err = SendADBCommand(buffer, command, gADBComplete); if (!err) { WaitForCompletion(); } else { printf("\t\t\tError Setting LEDs\n"); } } return err; } OSErr SendADBCommand(Ptr buffer, short command, ADBCompletionUPP complete) { short done; OSErr err; gABDCompleteCalled = false; err = ADBOp((Ptr)&done, complete, buffer, command); return err; } void WaitForCompletion(void) { unsigned long finalTicks; while (!gABDCompleteCalled) { // Delay(1, &finalTicks); } } pascal void ADBCompletion(Ptr buffer, long refCon, long command) { gABDCompleteCalled = true; } +++++++++++++++++++++++++++ >From Jens Bauer Date: Thu, 14 May 1998 01:52:07 +0200 Organization: Faster Software PaiChan wrote: > > Hello, > > I am wondering what command I send to a ADB device such as the > keyboard to toggle the LEDs. > > Wouldn't it be in this order: > > short CountADBs(void); > GetIndADB(ADBDataBlock *info,short devTableIndex); > OSErr ADBOp(Ptr data,ProcPtr compRout,Ptr buffer,short commandNum); > > I am just not sure on which command to send the keyboard... > Is it documented somehwhere in IM? Yep. There's a sample Pascal-source. BUT! Since my keyboard is not an extended keyboard, it did not work on my computer. I rewrote the thing in 68xxx assembler to support my own keyboard. BEWARE!! The ADB is VERY slow, so don't count on having it in speedy programs. You should only identify the ADB when REALLY needed, for instance once, when your application/driver starts up. Asking every time is VEEERY slow. I hope it helps... -WoF- - ---8<-----8<-----8<--- ;This works now. The routine is very slow, and takes up alot of CPU time. A way to get more CPU time, is to count ADBs once, ;to find the keyboard once, and then only change the LEDs with the ADBop the rest of the time. CASE OBJ STRING ASIS include 'Quickdraw.a' include 'Fonts.a' include 'Dialogs.a' include 'Windows.a' include 'Menus.a' include 'Events.a' include 'DeskBus.a' include 'LowMemEqu.a' Globals: RECORD qd: ds QDGlobals theEvent: ds EventRecord ENDR MAIN WITH Globals pea qd.thePort(a5) _InitGraf _InitFonts _InitWindows _InitMenus _TEInit clr.l -(sp) _InitDialogs _InitCursor ; _Debugger moveq #0,d7 loop: and.w #7,d7 move.w d7,-(sp) bsr.s DoSetLeds addq.w #2,sp addq.w #1,d7 moveq #20,d6 OS_time: _SystemTask clr.w -(sp) move.w #everyEvent,-(sp) pea theEvent(a5) _GetNextEvent tst.b (sp)+ bne.s test_event dbf d6,OS_time bra.s loop test_event: ; move.w theEvent.what(a5),d0 ; cmp.w #keyDown,d0 ; beq.s done ; cmp.w #mouseDown,d0 ; beq.s done ; bra.s loop done: clr.w -(sp) bsr.s DoSetLeds addq.w #2,sp rts ;reg w: retcode ;reg w: i ;-$c6 w: numADBs ;-$c3 b: completionFlag ;-$c0 ADBregBuffType: regBuff ;PACKED ARRAY[0..8] of BYTE ;-$b7 -$b6 ADBAddress: anADBadd[1..16] (array of bytes) ;-$b0 -$a6 ADBDataBlock: anADBDB[1..16] (16 times 10 bytes) ;reg b: oldReg DoSetLeds: link a6,#-$c6 movem.l d7/a2-a4,-(sp) lea -$b0(a6),a3 ;devType? lea -$b7(a6),a4 _CountADBs ;get number of ADBs move.w d0,-$c6(a6) ;save in numADBs for later moveq #1,d7 ;1..numADBs bra.s next for: moveq #16,d1 cmp.l d1,d7 bhi.s DoneSetLeds moveq #10,d2 muls.w d7,d2 lea (a3,d2.l),a0 ;info (ADBDataBlock) move.w d7,d0 ;devTableIndex _GetIndADB ;GetIndADB(anADBDB[i], i) ext.w d0 move.b d0,(a4,d7.w) ;anADBadd[i] = muls.w d7,d2 ;i*10 for indexing moveq #2,d1 ;constant '2' lea -$af(a6),a1 ;origADBAddr? cmp.b (a1,d2.w),d1 seq.b d0 cmp.b (a3,d2.w),d1 ;this has been corrected! (2 is the standard extended keyboard!) beq.s found_kbd2 cmp.b #5,(a3,d2.w) ;can also be type 5! found_kbd2: seq.b d1 and.b d1,d0 beq.s next_ADB ;if (anADBDB[i].origADBAddr = 2) AND (anADBDB[i].devType = 2) ;extended keyboard: move.b #2,-$c0(a6) ;regBuff[0] = 2 clr.b -$c3(a6) ;completionFlag = FALSE moveq #14,d0 bsr.s DoADBOp bne.s DoneSetLeds ;exit if error wait1: move.b -$c3(a6),d0 ;completionFlag beq.s wait1 ;if still FALSE, go round loop moveq #-8,d0 and.b -$be(a6),d0 ;get mask of register, but exclude the LEDs moveq #7,d2 ;mask for the LEDs (a set bit means that the LED is turned off) sub.w 8(a6),d2 or.b d2,d0 move.b d0,-$be(a6) ;regBuff[2] = BOR(BAND(regBuff[2],255-7), 7 - LedPat) clr.b -$c3(a6) ;completionFlag = FALSE moveq #10,d0 bsr.s DoADBOp bne.s next_ADB wait2: moveq #1,d0 and.b -$c3(a6),d0 beq.s wait2 next_ADB: addq.w #1,d7 bvs.s DoneSetLeds next: cmp.w -$c6(a6),d7 ble.s for DoneSetLeds: movem.l (sp)+,d7/a2-a4 unlk a6 rts DoADBOp: pea -$c3(a6) pea compADBop(pc) pea -$c0(a6) lea -$b7(a6),a0 move.b (a0,d7.w),d1 ext.w d1 asl.w #4,d1 add.w d1,d0 ;commandNum lea (sp),a0 ;list of pointers _ADBOp ;ADBOp(@completionFlag, @CompADBOp, @regBuff, kTalkCommand + kLEDRegister + 16*anADBadd[i]) lea 12(sp),sp rts ; pascal OSErr ADBOp(Ptr data, ADBCompletionUPP compRout, Ptr buffer, short commandNum) compADBop: move.b #TRUE,(a2) rts ENDWITH ENDMAIN END - ->8----->8----->8----- --------------------------- >From Brad Soe Subject: Get Graphics Device PixMap without cursor on it? Date: Thu, 30 Apr 1998 18:26:33 -0700 Organization: (none) I am getting screen images, but I want to get them without the cursor on them. I am just calling GetMainDevice() and then getting the pixel data from the PixMapHandle. I am not using CopyBits and cannot use it. I tried to call LBSetCrsrBusy(1), but the cursor still appears. How can I loose the cursor from the pix map. Thanks Brad +++++++++++++++++++++++++++ >From jbrasure@dallas.net (James Brasure) Date: Sat, 02 May 1998 01:23:33 -0500 Organization: Mac and Windows Programming Consultant In article <354924C9.74C4A157@tsoft.com>, bsoe@tsoft.com wrote: > I am getting screen images, but I want to get them without the cursor on > them. I am just calling GetMainDevice() and then getting the pixel data > from the PixMapHandle. I am not using CopyBits and cannot use it. I > tried to call LBSetCrsrBusy(1), but the cursor still appears. How can I > loose the cursor from the pix map. > > Thanks > Brad Call HideCursor() before you copy from the Pixmap. I think that should do it. James Brasure Mac and Windows Programming Consultant "Let me port your software to the Mac!" jbrasure@dallas.net +++++++++++++++++++++++++++ >From derobert@erols.com (Anthony DeRobertis) Date: Sat, 02 May 1998 02:37:18 -0400 Organization: Erol's Internet Services In article <354924C9.74C4A157@tsoft.com>, bsoe@tsoft.com wrote: >I am getting screen images, but I want to get them without the cursor on >them. I am just calling GetMainDevice() and then getting the pixel data >from the PixMapHandle. I am not using CopyBits and cannot use it. I >tried to call LBSetCrsrBusy(1), but the cursor still appears. How can I >loose the cursor from the pix map. Hide it? Or is this at interrupt time? -- Windows 95 (win-DOH-z), n. A thirty-two bit extension and graphical shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor which was written by a two bit company that can't stand one bit of competition. +++++++++++++++++++++++++++ >From kluev@stalker.gamma.-deIete-.ru (Michael Kluev) Date: Thu, 07 May 1998 14:38:14 +0400 Organization: _ In article , derobert@erols.com (Anthony DeRobertis) wrote: > In article <354924C9.74C4A157@tsoft.com>, bsoe@tsoft.com wrote: > > >I am getting screen images, but I want to get them without the cursor on > >them. I am just calling GetMainDevice() and then getting the pixel data > >from the PixMapHandle. I am not using CopyBits and cannot use it. I > >tried to call LBSetCrsrBusy(1), but the cursor still appears. How can I > >loose the cursor from the pix map. > > Hide it? Or is this at interrupt time? Interrupt time? You could show/hide cursor at interrupt time provided that cursor is not busy (CrsrBusy). -- Michael Kluev. PS. Remove "-delete-." part from my address to reply. --------------------------- >From pdumais@phy.ulaval.ca Subject: HiliteControl'ing a textEdit Date: Thu, 07 May 1998 15:35:43 GMT Organization: Deja News - The Leader in Internet Discussion Any reason why HiliteControl'ing a textEdit item in a dialog should crash my machine ? Are 0 and 255 still legal values for this type of control ? I'm using a G3, system 8.1, and Codewarrior pro 3. thanks Patrick Dumais. - ---== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading +++++++++++++++++++++++++++ >From jbrasure@NOSPAM.dallas.net (James Brasure) Date: Thu, 07 May 1998 11:04:24 -0500 Organization: Mac and Windows Programming Consultant In article <6iskcg$u9m$1@nnrp1.dejanews.com>, pdumais@phy.ulaval.ca wrote: > Any reason why HiliteControl'ing a textEdit item in a dialog should > crash my machine ? Are 0 and 255 still legal values for this type of control ? > > I'm using a G3, system 8.1, and Codewarrior pro 3. > > thanks > > Patrick Dumais. Dialog boxes contain a mixture of items, some of which are controls, and some of which are not. For example, push buttons, radio buttons, popup menus, and check boxes are all controls. However, static text items and edit text items are not controls. Static text is drawn by the dialog manager, and edit text items are drawn by TextEdit. You can only use the Control Manager functions on items that are really controls. Otherwise you will crash. I hope that helps. James Brasure Mac and Windows Programming Consultant "Let me port your software to the Mac!" (Please remove "NOSPAM." from my address before responding.) +++++++++++++++++++++++++++ >From David.Walton.10@nd.edu (David Walton) Date: Thu, 07 May 1998 13:06:20 -0500 Organization: University of Notre Dame In article <6iskcg$u9m$1@nnrp1.dejanews.com>, pdumais@phy.ulaval.ca wrote: > Any reason why HiliteControl'ing a textEdit item in a dialog should > crash my machine ? Yes. You can only call control manager routines on dialog items that are really controls: buttons, popup menus, and any item whose type is ctrlItem (i.e., whose data contains the resource ID of a CNTL resource). Text items--editText and statText--are not controls; they're drawn by the TextEdit and the Dialog Manager. Trying to use Control Manager routines on them will therefore crash your machine. I presume you're trying to draw a static text item in greyed text. I believe the only way to do that is to install a userItem that draws the text, using the appropriate pen pattern (black & white port) or foreground color (color port) to draw the text in grey. Send me e-mail if you need more information. David Walton -- David Walton | Graduate Student and Macintosh pundit Mailto:David.Walton.10@nd.edu | Dept. History & Philosophy of Science http://www.nd.edu/~dwalton1 | University of Notre Dame "Beware the advice of successful people; they do not seek company." +++++++++++++++++++++++++++ >From michael.baron@deletethis.bbsrc.ac.uk Date: Fri, 08 May 1998 09:48:16 +0100 Organization: BBSRC Biotechnology and Biological Sciences Research Council David Walton wrote: > > I presume you're trying to draw a static text item in greyed text. I > believe the only way to do that is to install a userItem that draws the > text, using the appropriate pen pattern (black & white port) or foreground > color (color port) to draw the text in grey. Another way is to modify the QDTextProc for the dialog window. I found the code to do this, including setting up and keeping a list of text items and which ones are to be grayed (both static text and TE) in a package called 'John's CDEFs' (obtained from info-mac). This works very nicely and has the advantage that you don't have to write new code for every single dialog and item. It also 'hides' TE items in the dialog when they are gray, so that they are not seen as TE items by the dialog manager, even though they appear in the window. hope it helps, Michael --------------------------- >From zegelin@actonline.com.au (Peter Zegelin) Subject: How do I print hairlines?? Date: 1 May 1998 04:09:10 GMT Organization: Totally Disorganized I know this has been brought up before but I cant seem to print hairlines. Quite a while back somebody said to draw into a Picture and then when it was time to print, draw the Picture back using a smaller rectangle (ie scale it down). Ive tried this and sure enough everything scales down, up to a point. If I draw some lines with a PenSize of (2,2) and scale down by 50% I get one pixel wide lines when I print, but if I use a PenSize of (1,1) I still get one pixel wide lines. Here is my code (experimental so very basic): Rect gRect; PicHandle gPicH; SetUp() { SetRect(&gRect,0,0,1000,1000); PenSize(1,1); ClipRect(&thePort ->portRect); // ThinkRef 1.0 says do this? gPicH = OpenPicture(&gRect); //now draw 3 horizontal lines 20 pixels apart MoveTo (0,20); Line (400,0); MoveTo (0,40); Line (400,0); MoveTo (0,60); Line (400,0); ClosePicture(); } Draw() { // now reduce the rectangle to scale picture gRect.right = 500; gRect.bottom = 500; DrawPicture(gPicH,&gRect); } Note: My printer prints hairlines from Clarisdraw etc. just fine. Rather than waste any more paper can someone tell me what Im doing wrong? A TechNote URL would be great as well. Thanks in advance, Peter +++++++++++++++++++++++++++ >From johns@sonic.net (John Selhorst) Date: Fri, 01 May 1998 02:26:21 +0100 Organization: John Selhorst In article , zegelin@actonline.com.au (Peter Zegelin) wrote: > I know this has been brought up before but I cant seem to print hairlines. Check out PrGeneral(), in the print manager documentation. PrGeneral allows you to fiddle with the resolution of the printer, among other things. You can draw into a grafport the size of the full resolution of the printer. Play around with it until you get what you want. Johnny +++++++++++++++++++++++++++ >From jbrasure@dallas.net (James Brasure) Date: Sat, 02 May 1998 01:25:58 -0500 Organization: Mac and Windows Programming Consultant In article , johns@sonic.net (John Selhorst) wrote: > In article , > zegelin@actonline.com.au (Peter Zegelin) wrote: > > > I know this has been brought up before but I cant seem to print hairlines. > > Check out PrGeneral(), in the print manager documentation. PrGeneral > allows you to fiddle with the resolution of the printer, among other > things. You can draw into a grafport the size of the full resolution of > the printer. Play around with it until you get what you want. > > Johnny Go to the address below, and search for "resolution". It tells you exactly how to do it. http://developer.apple.com/techpubs/mac/QuickDraw/QuickDraw-407.html#HEADING407-57 James Brasure Mac and Windows Programming Consultant "Let me port your software to the Mac!" jbrasure@dallas.net --------------------------- >From jcondit@login4.fas.harvard.edu (Jeremy Condit) Subject: Pixels in PixMap? Date: 25 Apr 1998 00:35:07 GMT Organization: Harvard University, Cambridge, Massachusetts I'm trying to draw a number of pixels to a window, one pixel at a time. SetCPixel() works, but is very slow. So, I'd like to avoid the Toolbox altogether and write directly to a PixMap's pixels. How exactly is this data stored within the PixMap's baseAddr pointer? Is it an array of RGB values, indices into a color table, or something else? Also, if you have better ideas for how to color a window pixel by pixel, they'd be greatly appreciated! Thanks, Jeremy o-----------------------o Jeremy Condit o------------------------o | jcondit@fas.harvard.edu - http://www.fas.harvard.edu/~jcondit/ | | "Imagination is more important than knowledge." -Albert Einstein | o------------------------------------------------------------------o +++++++++++++++++++++++++++ >From Clark Cox Date: Sat, 25 Apr 1998 15:24:29 GMT Organization: Coxware Software Jeremy Condit wrote: > > I'm trying to draw a number of pixels to a window, one pixel at a time. > SetCPixel() works, but is very slow. So, I'd like to avoid the Toolbox > altogether and write directly to a PixMap's pixels. How exactly is this > data stored within the PixMap's baseAddr pointer? Is it an array of RGB > values, indices into a color table, or something else? That depends on what the depth of the PixMap is. If the depth is 8-bits or less, then the values are ColorTable indices. If the depth is greater, the values stored at the baseAddr are stored as RGB components: pixelSize is the bits per pixel, cmpCount is the number of components per pixel and cmpSize is the size of each component. -- Clark S. Cox, III | ClarkCox3@hotmail.com Coxware Software | Coxware@hotmail.com "The only stupid question is the one not asked" --Unknown e-mail harvester traps: Chairman Reed Hundt: rhundt@fcc.gov Commissioner James Quello: jquello@fcc.gov Commissioner Susan Ness: sness@fcc.gov Commissioner Rachelle Chong: rchong@fcc.gov president@whitehouse.gov mwa234@hotmail.com bestrealtor@marketingmaster.com bstar@sssnet.com info@herbchew.com yyyr4t7@biblioteca.com clickthru@timefreedom.com nantragod@earthlink.net invite@onlinenow.net hdn94-018.hil.compuserve.com zippydj@nevwest.com haniophile@ntr.net Offer@shire.com inetmktg@usa.net empower@empowerlabs.com info@dproducts.be dynamarket@vaprnet.com promotions@the-bookstore.com root@mail.icongrp.com healthy181@aol.com cashrewards@hotmail.com Success@paper.com tei@websecure.net bb77@wyoma.com removeadultinf +++++++++++++++++++++++++++ >From dtp@pluto.njcc.com (David T. Pierson) Date: Sat, 25 Apr 1998 17:46:27 -0400 Organization: New Jersey Computer Connection, Lawrenceville, NJ Jeremy Condit wrote: > > I'm trying to draw a number of pixels to a window, one pixel at a time. > SetCPixel() works, but is very slow. So, I'd like to avoid the Toolbox > altogether and write directly to a PixMap's pixels. How exactly is this > data stored within the PixMap's baseAddr pointer? Is it an array of RGB > values, indices into a color table, or something else? I don't know much about this, but Adam Coates seems to cover this as sort of a sidebar to his 3D programming tutorial. http://www.neteze.com/hawking/3DProg/chapter6.htm HTH, David +++++++++++++++++++++++++++ >From javajitter@aol.com Date: Sat, 02 May 1998 21:40:33 -0400 Organization: (none) David T. Pierson wrote: > > Jeremy Condit wrote: > > > > I'm trying to draw a number of pixels to a window, one pixel at a time. > > SetCPixel() works, but is very slow. So, I'd like to avoid the Toolbox > > altogether and write directly to a PixMap's pixels. How exactly is this > > data stored within the PixMap's baseAddr pointer? Is it an array of RGB > > values, indices into a color table, or something else? > > I don't know much about this, but Adam Coates seems to cover this as sort > of a sidebar to his 3D programming tutorial. > > http://www.neteze.com/hawking/3DProg/chapter6.htm > > HTH, > David It depends on the PixMap you're looking at. 32 bit Pix Maps are arranges (I think) as an array of ARGB (Alpha, Red, Green, Blue) values. With each value bering a BYTE. If you're in 16 bit color, the values are stored as ARGB, in which the alpha channel is the first bit. The following RGB values taking up 5 bits each. In anything lower, the PixMap is always index based based on the CTabHandle that is attached to it. You can index into the CTabHandle to find the appropriate RGB values for a particular pixel. In these cases, the pixel is 1 BYTE for 8 bit color, 4 bits (Nibble) for 16 color, 2 bits for 4 color, and 1 bit each for Black & White Bit Maps. I know most modern PowerMacs don't let you go into these lower bit depths for the screen anymore, but that doesn't stop you from having these types of bitmaps in memory, and wanting to blast them to the screen... :) I hope this answered your question. BTW: make sure you do a LockPixels() BEFORE you access the PixMap directly... Scott Tury --------------------------- >From yennie@aol.com (Yennie) Subject: Tcl-Tk for mac? Date: 06 May 1998 23:23:55 GMT Organization: AOL http://www.aol.com Can anyone suggest a Tcl/Tk environment for Macintosh which is OS 8 compliant? I downloaded one from AOL only to have it say nasty things, such as that it requires OS 7 or greater (apparently 8 is not greater than 7). Any suggestions? Are there, better yet, and reliable visual editors? TIA, Brian (a copy via e-mail is very much appreciated) +++++++++++++++++++++++++++ >From online@mactech.com (Jeff at MacTech) Date: Wed, 13 May 1998 00:59:27 -0700 Organization: MacTech Magazine In article <1998050623235500.TAA27850@ladder03.news.aol.com>, yennie@aol.com (Yennie) wrote: >Can anyone suggest a Tcl/Tk environment for Macintosh which is OS 8 compliant? >I downloaded one from AOL only to have it say nasty things, such as that it >requires OS 7 or greater (apparently 8 is not greater than 7). Any suggestions? Have you looked on Sun's web site? They are sort of the official force behind development of Tcl/Tk, and they do have a Mac version (I think I tried it under OS 8). If you can't find it, email me and I will look up the exact URL. Also, check out the MacTech Online column in the current (May) issue of MacTech Magazine--it points out a whole bunch of resources for Tcl/Tk, Perl, and Python on the Mac, including the above-mentioned URL. (I'm not sure if it has hit the newstands yet--if not, it should soon.) I hope this helps. -- __________________________________________________________________________ Jeff Clites Online Editor http://www.MacTech.com/ online@MacTech.com MacTech Magazine __________________________________________________________________________ +++++++++++++++++++++++++++ >From O'NEEL Bruce Date: 13 May 1998 11:37:15 +0200 Organization: University of Geneva Hi, The current best release for the Mac is 8.0p2, which you can get from: 1. http://www.scriptics.com/download/8.0.html 2. http://sunscript.sun.com/TclTkCore/8.0.html The first location is probably faster for most people. Scriptics is the company spun out of Sun run by John Ousterhout, the creator of Tcl/Tk. The sunscript.sun.com site is frozen and won't be updated anymore. Tcl/Tk 8.0p2 is quite MacOS 8.0 compatible and I use it daily on 8.1 with great success. What it sounds like you downloaded was a version of Tcl 7.6/Tk 4.2 which was done before 8.x was released. 8.0 is much better on the mac and is really worth using. cheers bruce online@mactech.com (Jeff at MacTech) writes: > In article <1998050623235500.TAA27850@ladder03.news.aol.com>, > yennie@aol.com (Yennie) wrote: > > >Can anyone suggest a Tcl/Tk environment for Macintosh which is OS 8 compliant? > >I downloaded one from AOL only to have it say nasty things, such as that it > >requires OS 7 or greater (apparently 8 is not greater than 7). Any suggestions? > > Have you looked on Sun's web site? They are sort of the official force > behind development of Tcl/Tk, and they do have a Mac version (I think I > tried it under OS 8). If you can't find it, email me and I will look up > the exact URL. Also, check out the MacTech Online column in the current > (May) issue of MacTech Magazine--it points out a whole bunch of resources > for Tcl/Tk, Perl, and Python on the Mac, including the above-mentioned > URL. (I'm not sure if it has hit the newstands yet--if not, it should > soon.) > > I hope this helps. > -- > __________________________________________________________________________ > > Jeff Clites Online Editor http://www.MacTech.com/ > online@MacTech.com MacTech Magazine > __________________________________________________________________________ -- Bruce O'Neel phone: +41 22 950 91 22 (direct) INTEGRAL Science Data Centre +41 22 950 91 00 (switchb.) Chemin d'Ecogia 16 fax: +41 22 950 91 33 CH-1290 VERSOIX e-mail: Bruce.Oneel@obs.unige.ch Switzerland WWW: http://obswww.unige.ch/isdc/ --------------------------- >From "Mark Krenek" Subject: [Q] Detecting shut down Date: 29 Apr 98 10:22:37 -0500 Organization: Metrowerks, Corp. Does any one know how my running application can detect that the user has chosen shut down? Installing a shut down proc doesn't work because those get invoked too late in the process. What I'm trying to determine is if I receive a Quit apple event, is it because the system is trying to shut down or has something else has triggered my quit. Examples of getting quit apple events when the user has NOT chosen shut down are: - from installers who shut down all running apps - from task bars Thanks +++++++++++++++++++++++++++ >From derobert@erols.com (Anthony DeRobertis) Date: Thu, 30 Apr 1998 00:35:24 -0400 Organization: Erol's Internet Services In article , "Mark Krenek" wrote: >Does any one know how my running application can detect that the user >has chosen shut down? Installing a shut down proc doesn't work because >those get invoked too late in the process. > > >What I'm trying to determine is if I receive a Quit apple event, is it >because the system is trying to shut down or has something else has >triggered my quit. You might want to try testing if the Finder sent it or not. The Finder sends shutdown AppleEvents (except under At Ease, perhaps) -- Windows 95 (win-DOH-z), n. A thirty-two bit extension and graphical shell to a sixteen bit patch to an eight bit operating system originally coded for a four bit microprocessor which was written by a two bit company that can't stand one bit of competition. +++++++++++++++++++++++++++ >From "Mark Krenek" Date: 30 Apr 98 00:09:55 -0500 Organization: Illuminati Online > You might want to try testing if the Finder sent it or not. The Finder > sends shutdown AppleEvents (except under At Ease, perhaps) > That's sort of what I'm trying right now. When I receive my quit event, I check to see if the sender is 'MACS'. If so, my assumption is that a shut down is occurring. That should be the only time the Finder tries to shut me down. --------------------------- >From oster@netcom.com (David Phillip Oster) Subject: [Q] Quicktime: How to create, then play, a movie in RAM? Date: Sat, 25 Apr 1998 11:51:48 -0700 Organization: Digital Arts & Sciences I've been trying to create, then play a sound-only movie, entirely in RAM, without using a disk file, and having a lot of trouble. 1.) The example code in Inside Mac:Quicktime runs for many pages on analyzing 'snd ' resources just so you can put them in a movie. It never mentions that you can just call PutHandleInMovie(movie, h, 'snd '...); 2.) If I just create the movie with NewMovie(), and try it following the example code from Inside Mac:Quicktime, I get a "BadDataRef" error code when I call BeginMediaEdits() (or PutHandleInMovie()) 3.) If I create the move with NewMovieFromFile(), I can create the movie without error, create a controller for it, and show the controller. But when the movie is played, it is silent. Unless, I close the movie file and reopen it. Then the movie plays just fine. What I want to do is: play an arbitrary 'snd ' file with a QuickTime controller, as if it were an AIFF file. I don't know how to make QuickTime automatically open an 'snd ' file as a movie, and I don't want to copy and convert an 'snd ' file to a movie file, as the above code (3) does. What am I missing? What don't I know in order to do what I want? Should what I am trying just work? Do you need to see sample code so you can see what I am doing wrong? +++++++++++++++++++++++++++ >From dave@XpablomediaX.com (Dave Howell) Date: Tue, 28 Apr 1998 12:21:32 -0800 Organization: Pablo Media In article , oster@netcom.com (David Phillip Oster) wrote: > [ some stuff snipped ] > > What I want to do is: play an arbitrary 'snd ' file with > a QuickTime controller, as if it were an AIFF file. > I don't know how to make QuickTime automatically open an 'snd ' > file as a movie, and I don't want to copy and convert an 'snd ' > file to a movie file, as the above code (3) does. > > What am I missing? What don't I know in order to do what I want? > Should what I am trying just work? Do you need to see sample > code so you can see what I am doing wrong? All you need is QuickTime 3.0. It will play your snd files. Dave +++++++++++++++++++++++++++ >From oster@netcom.com (David Phillip Oster) Date: Thu, 30 Apr 1998 17:57:39 -0700 Organization: Digital Arts & Sciences In article , dave@XpablomediaX.com (Dave Howell) wrote: > All you need is QuickTime 3.0. It will play your snd files. Nope. QuickTime 3.0 looks at the file, notices it has no 'moov' resource in it, and returns an error code. You are thinking of a file of type 'AIFF' not a file that has an 'snd ' resource in it. Also, all of the problems I listed in my original posting on creating a movie entirely in RAM were problmes that I've experienced with both Quicktime v 3.0 and earlier versions. +++++++++++++++++++++++++++ >From XdaveX@pablomedia.com (Dave Howell) Date: Mon, 04 May 1998 00:28:35 -0800 Organization: Pablo Media In article , oster@netcom.com (David Phillip Oster) wrote: > > All you need is QuickTime 3.0. It will play your snd files. > > Nope. QuickTime 3.0 looks at the file, notices it has no 'moov' > resource in it, and returns an error code. You are thinking of > a file of type 'AIFF' not a file that has an 'snd ' resource > in it. Oops, my bad. Rather than actually trying this, I just assumed that when Apple set out to support a wide variety of media types, they would support their own. By the way, it's not because it doesn't have a 'moov' resource--QT3 will open lots of different media files that don't contain 'moov' resources--it's because QT3's Movie Data Import ('eat ') component for Sound ('snd ') files doesn't convert in place; it always creates a file. For the same reason, if you drag-drop a Sound file onto MoviePlayer it will say that the Sound is not a movie file. So anyway, back to your original question (maybe I can regain some lost cool points if this helps any)... > I've been trying to create, then play a sound-only movie, > entirely in RAM, without using a disk file, and having a > lot of trouble. > > 1.) The example code in Inside Mac:Quicktime runs for many > pages on analyzing 'snd ' resources just so you can > put them in a movie. It never mentions that you can just > call PutHandleInMovie(movie, h, 'snd '...); I don't think there was a PutHandleInMovie function in QT 1.0. > 2.) If I just create the movie with NewMovie(), and try it > following the example code from Inside Mac:Quicktime, > I get a "BadDataRef" error code when I call BeginMediaEdits() > (or PutHandleInMovie()) It sounds like your Media has not been created correctly. Do you create it something like this? - ------------------- OSErr err; Movie movie; Track track; Media media; Handle dataRef; // Create the new movie. movie = NewMovie(newMovieActive); if (!movie) barf(); // Create a Handle data reference, telling QuickTime to build the movie // in memory. Make the handle data reference the default for the movie. dataRef = NewHandleClear(sizeof(Handle)); SetMovieDefaultDataRef(movie, dataRef, HandleDataHandlerSubType); // create a track & media to contain the tiles track = NewMovieTrack(movie, width << 16, height << 16, kFullVolume); if (!track) barf(); media = NewTrackMedia(track, AudioMediaType, 600, nil, 0); if (!media) barf(); err = BeginMediaEdits(media); if (err) barf(); - ------------------- > 3.) If I create the move with NewMovieFromFile(), I can > create the movie without error, create a controller for it, > and show the controller. But when the movie is played, > it is silent. Unless, I close the movie file and reopen it. > Then the movie plays just fine. What value do you pass to NewMovieTrack for trackVolume? Remember that kFullVolume (0x0100) is full volume. Not 1<<16, which will get passed as zero. > What I want to do is: play an arbitrary 'snd ' file with > a QuickTime controller, as if it were an AIFF file. > I don't know how to make QuickTime automatically open an 'snd ' > file as a movie, and I don't want to copy and convert an 'snd ' > file to a movie file, as the above code (3) does. Because the Sound import component doesn't convert in place, you can't simply open a sound as a movie file without writing some special code, like a custom import component. You best bet is to create a movie. > What am I missing? What don't I know in order to do what I want? > Should what I am trying just work? Do you need to see sample > code so you can see what I am doing wrong? Let me know if the above comments helped. If not, try posting some source cod. A tip: the best resource for getting QuickTime code questions answered is the QuickTime developers mail-list. Try this: Dave __________________________________________________________________ Dave Howell | Custom Software Design and Development, applications, Pablo Media | utilities, games, components, Xtras, modifiers, and Belmont, CA | plug-ins for MacOS, Windows, and PalmOS | | [Remove X's from return address before replying] --------------------------- >From qhill@bigfoot.com (Quentin Hill) Subject: [Q] Sending an 'odoc' event to an application. Date: Sat, 02 May 1998 14:03:36 -0600 Organization: More Human Software Hello, I was wondering if somebody could point me to some code for sending an 'odoc' event to an application. The application should never be running at the same time as my app, so do I need to send an 'oapp' event first? The app only communicates through Apple Events, and that application controls a control panel. Any help would be greately appreciated. Quentin -- Quentin Hill +++++++++++++++++++++++++++ >From dtp@pluto.njcc.com (David T. Pierson) Date: Sat, 02 May 1998 17:51:57 -0400 Organization: New Jersey Computer Connection, Lawrenceville, NJ qhill@bigfoot.com (Quentin Hill) wrote: >I was wondering if somebody could point me to some code for sending an >'odoc' event to an application. The application should never be running at >the same time as my app, so do I need to send an 'oapp' event first? http://developer.apple.com/technotes/tn/tn1002.html http://devworld.apple.com/dev/techsupport/source/SProcesses.html HTH, David +++++++++++++++++++++++++++ >From kevin@vailstar.com (Kevin Michael Vail) Date: Sat, 02 May 1998 18:04:06 -0400 Organization: Vailstar LLC In article , qhill@bigfoot.com (Quentin Hill) wrote: >Hello, > >I was wondering if somebody could point me to some code for sending an >'odoc' event to an application. The application should never be running at >the same time as my app, so do I need to send an 'oapp' event first? The >app only communicates through Apple Events, and that application controls >a control panel. Any help would be greately appreciated. Well, an application that isn't running gets either an 'oapp' or an 'odoc', not both, so I imagine you only need the 'odoc'. It might be easier though just to ask the Finder to open the document, assuming that the creator code on the document targets the application you want to open it. Then you don't have to worry about whether the app is running or not. -- Kevin Michael Vail | I would rather have a mind opened by wonder kevin@vailstar.com | than one closed by belief. -- Gerry Spence --------------------------- End of C.S.M.P. Digest **********************