home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / c / rkrm / workbench / appwindow.c < prev    next >
C/C++ Source or Header  |  1992-09-03  |  5KB  |  131 lines

  1. ;/* appwindow.c - Compiled under SAS C 5.10 with:
  2. lc -L -j73 appwindow.c
  3. quit
  4. */
  5.  
  6. /* Requires Kickstart version 37 or later.  Works from the Shell (CLI) only */
  7.  
  8. /*
  9. Copyright (c) 1992 Commodore-Amiga, Inc.
  10.  
  11. This example is provided in electronic form by Commodore-Amiga, Inc. for
  12. use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  13. published by Addison-Wesley (ISBN 0-201-56774-1).
  14.  
  15. The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  16. information on the correct usage of the techniques and operating system
  17. functions presented in these examples.  The source and executable code
  18. of these examples may only be distributed in free electronic form, via
  19. bulletin board or as part of a fully non-commercial and freely
  20. redistributable diskette.  Both the source and executable code (including
  21. comments) must be included, without modification, in any copy.  This
  22. example may not be published in printed form or distributed with any
  23. commercial product.  However, the programming techniques and support
  24. routines set forth in these examples may be used in the development
  25. of original executable software products for Commodore Amiga computers.
  26.  
  27. All other rights reserved.
  28.  
  29. This example is provided "as-is" and is subject to change; no
  30. warranties are made.  All use is at your own risk. No liability or
  31. responsibility is assumed.
  32. */
  33.  
  34.  
  35. #include <exec/types.h>          /* Need this for the Amiga variable types  */
  36. #include <workbench/workbench.h> /* This has DiskObject and AppWindow       */
  37. #include <workbench/startup.h>   /* This has WBStartup and WBArg structs    */
  38. #include <exec/libraries.h>      /* Need this to check library versions     */
  39.  
  40. #include <stdio.h>
  41.  
  42. #include <clib/intuition_protos.h>
  43. #include <clib/exec_protos.h>
  44. #include <clib/wb_protos.h>
  45.  
  46. #ifdef LATTICE
  47. int CXBRK(void) { return(0); }   /* Disable SAS Lattice CTRL/C handling */
  48. int chkabort(void) { return(0); }/* really */
  49. #endif
  50.  
  51. struct Library      *IntuitionBase;
  52. struct Library      *WorkbenchBase;
  53.  
  54. void main(int argc, char **argv)
  55. {
  56.   struct MsgPort *awport;
  57.   struct Window  *win;
  58.   struct AppWindow *appwin;
  59.   struct IntuiMessage *imsg;
  60.   struct AppMessage *amsg;
  61.   struct WBArg   *argptr;
  62.  
  63.   ULONG           winsig, appwinsig, signals, id = 1, userdata = 0;
  64.   BOOL            done = FALSE;
  65.   int             i;
  66.  
  67.   if (IntuitionBase = OpenLibrary("intuition.library", 37))
  68.     {
  69.     if (WorkbenchBase = OpenLibrary("workbench.library", 37))
  70.       {
  71.       /* The CreateMsgPort() function is in Exec version 37 and later only */
  72.       if (awport = CreateMsgPort())
  73.          {
  74.          if (win = OpenWindowTags(NULL,
  75.                                   WA_Width, 200,        WA_Height, 50,
  76.                                   WA_IDCMP, CLOSEWINDOW,
  77.                                   WA_Flags, WINDOWCLOSE | WINDOWDRAG,
  78.                                   WA_Title, "AppWindow",
  79.                                   TAG_DONE))
  80.           {
  81.           if (appwin = AddAppWindow(id, userdata, win, awport, NULL))
  82.             {
  83.             printf("AppWindow added... Drag files into AppWindow\n");
  84.             winsig    = 1L << win->UserPort->mp_SigBit;
  85.             appwinsig = 1L << awport->mp_SigBit;
  86.  
  87.             while (! done)
  88.               {
  89.               /* Wait for IDCMP messages and AppMessages */
  90.               signals = Wait( winsig | appwinsig );
  91.  
  92.               if(signals & winsig)      /* Got an IDCMP message */
  93.                 {
  94.                 while (imsg = (struct IntuiMessage *) GetMsg(win->UserPort))
  95.                   {
  96.                   if (imsg->Class = CLOSEWINDOW)   done = TRUE;
  97.                   ReplyMsg((struct Message *) imsg);
  98.                   }
  99.                 }
  100.               if(signals & appwinsig)   /* Got an AppMessage */
  101.                 {
  102.                 while (amsg = (struct AppMessage *) GetMsg(awport))
  103.                   {
  104.                   printf("AppMsg: Type=%ld, ID=%ld, NumArgs=%ld\n",
  105.                            amsg->am_Type, amsg->am_ID, amsg->am_NumArgs);
  106.                   argptr = amsg->am_ArgList;
  107.                   for (i = 0; i < amsg->am_NumArgs; i++)
  108.                     {
  109.                     printf("   arg(%ld): Name='%s', Lock=%lx\n",
  110.                              i, argptr->wa_Name, argptr->wa_Lock);
  111.                     argptr++;
  112.                     }
  113.                   ReplyMsg((struct Message *) amsg);
  114.                   }
  115.                 }
  116.               }     /* done */
  117.             RemoveAppWindow(appwin);
  118.             }
  119.           CloseWindow(win);
  120.           }
  121.         /* Make sure there are no more outstanding messages */
  122.         while(amsg = (struct AppMessage *)GetMsg(awport))
  123.               ReplyMsg((struct Message *)amsg);
  124.         DeleteMsgPort(awport);
  125.         }
  126.       CloseLibrary(WorkbenchBase);
  127.       }
  128.     CloseLibrary(IntuitionBase);
  129.     }
  130. }
  131.