Solved

Sending myself an AppleEvent

Posted on 2000-04-16
2
243 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.

773 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