Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending myself an AppleEvent

Posted on 2000-04-16
2
Medium Priority
?
282 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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

927 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