Solved

Sending myself an AppleEvent

Posted on 2000-04-16
2
232 Views
Last Modified: 2013-12-26
I have DragReceiveHandler() that I would like to extract the items from and add them to a AppleEvent and send the event to myself. I am unsure of how add to AEDesc list after I retrieve the info with GetFlavorData()

static pascal OSErr MyDragReceiveHandler(WindowPtr theWindow, void *refcon, DragReference theDragRef) {

      ItemReference                   theItem;
      HFSFlavor                         targetFile;
      Size                               theSize;
      OSErr                               err;
      DragAttributes                  dragAttrs;
      short                              itemCount, i;
      
      ProcessSerialNumber            process;
      AEDesc                              myAddressDesc;
      AEDesc                              dataDesc = { typeNull, NULL };
      AppleEvent                        myAppleEvent;
      AEDesc                              itemDesc = { typeNull, NULL };
      SInt32                              numItems = 0;      
      AppleEvent                        myReply = { typeNull, NULL };
      
      if ( ! (gApprovedSplashDrag && gInIconSplashBox) ) { err = userCanceledErr; goto bail; };

      if ((err = CountDragItems(theDragRef, &itemCount)) != noErr) goto bail;
      
      err = GetCurrentProcess(&process);
      if(err = noErr)
            err = AECreateDesc( typeProcessSerialNumber, (Ptr)&process, sizeof(process), &myAddressDesc);
      
      if(err = noErr)
            err = AECreateAppleEvent( kCoreEventClass, kAEOpenDocuments, &myAddressDesc, kAutoGenerateReturnID, kAnyTransactionID, &myAppleEvent );
      
      if (err = noErr)
            err = AECreateList( NULL, 0, false, &dataDesc );

      for(i=1; i<=itemCount; i++) {
            if ((err = GetDragItemReferenceNumber(theDragRef, i, &theItem)) == noErr) {
                  if( (GetDragAttributes(theDragRef, &dragAttrs)) == noErr)
                  {
                        theSize = sizeof(HFSFlavor);
                        err = GetFlavorData(theDragRef, theItem, flavorTypeHFS, &targetFile, &theSize, 0);
                        //( FSSpec * )*( itemDesc.dataHandle)  = &targetFile.fileSpec;
                        err = AEPutDesc( &dataDesc, i, &itemDesc );
                  
                        AEDisposeDesc( &itemDesc );
                  }
            }
      }
      
      if ( !err )
            err = AEPutParamDesc( &myAppleEvent, keyDirectObject, &dataDesc );
      
      if ( !err )
            err = AESend( &myAppleEvent, &myReply, kAENoReply + kAEAlwaysInteract + kAECanSwitchLayer, kAENormalPriority, kAEDefaultTimeout, NULL, NULL );
                  
      AEDisposeDesc( &dataDesc );
      AEDisposeDesc( &myAppleEvent );
      AEDisposeDesc( &myReply );
      
      gInIconSplashBox = (ShowDragHiliteBox(theDragRef, &gSplashDragBox) == noErr);
      
bail:
      return err;
}
0
Comment
Question by:dwp090598
2 Comments
 
LVL 2

Accepted Solution

by:
roov earned 200 total points
ID: 2721658
dwp,

to add to the list, try code like the following (this adds to a list FSSpec for odoc events):

AEDescList docList;

err = AECreateList(nil,0,false,&docList);
if (!err)
{
      err = AEPutPtr(&docList,1,typeFSS,fssP,sizeof(*fssP));
      if (!err)
      {
            err = AEPutParamDesc (ae,keyDirectObject,&docList);
      }
}


Enjoy,
Reuven
0
 

Author Comment

by:dwp090598
ID: 2728352
The AEPutPtr( ) did the trick, thanks again.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now