Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending myself an AppleEvent

Posted on 2000-04-16
2
Medium Priority
?
275 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

705 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