Solved

Sending myself an AppleEvent

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
move a line in eclipse 3 109
Hibernate methods 2 83
My project did see openJDK that I installed. What could be the problem 7 160
wordmultiple challenge 12 154
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…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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