home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games 1996 October / Amiga_Games_Extra_CD_10-96.bin / userbox / publicdomain / grabkey / source / gk_grab.c < prev    next >
C/C++ Source or Header  |  1996-07-15  |  1KB  |  121 lines

  1. /*
  2. **    GrabKEY
  3. **
  4. **        © 1996 by Timo C. Nentwig
  5. **        All Rights Reserved !
  6. **
  7. **        Tcn@techbase.in-berlin.de
  8. **
  9. **
  10. */
  11.  
  12. /// #include
  13.  
  14. #include "gk_GST.h"
  15. #include "gk_Protos.h"
  16.  
  17. ///
  18. /// proto
  19.  
  20. proto  BOOL    Grab    (const ULONG What, const ULONG Where);
  21.  
  22. ///
  23.  
  24. /// Grab ()
  25.  
  26.     /*
  27.      *    FUNCTION    Grab something to somewhere.
  28.      *
  29.      *    NOTE        Values for <What>/<Where> in gk_GST.h
  30.      *
  31.      *    EXAMPLE     Grab (WINDOW, DEF_FILE);
  32.      *
  33.      */
  34.  
  35.  
  36. BOOL
  37. Grab (const ULONG What, const ULONG Where)
  38. {
  39.  
  40.     Object   *Image = NULL;                // NULL is very important !
  41.  
  42.         // Load notification sound
  43.  
  44.     PlaySound (Set -> Sound . Start);
  45.  
  46.         // Get image
  47.  
  48.     if (GetImage (&Image, What))
  49.     {
  50.  
  51.         switch (Where)
  52.         {
  53.  
  54.                 // Save to file
  55.  
  56.             case TO_FILE:
  57.  
  58.                     // No output specified, open Requester
  59.  
  60.                 if (StrEmpty (Set -> File . Path))
  61.                 {
  62.  
  63.                     UBYTE    File [256];
  64.  
  65.                     STRCPY (File, GetFile());
  66.  
  67.                     if ( ! (StrEmpty (File)))
  68.                     {
  69.  
  70.                         SaveImage (Image, File);
  71.  
  72.                     }
  73.  
  74.                 }
  75.                 else
  76.                 {
  77.  
  78.                     SaveImage (Image, Set -> File . Path);
  79.  
  80.                 }
  81.                 break;
  82.  
  83.                 // Save to printer
  84.  
  85.             case TO_PRINTER:
  86.  
  87.                 PrintImage (Image);
  88.                 break;
  89.  
  90.                 // Save to clipboard
  91.  
  92.             case TO_CLIPBOARD:
  93.  
  94.                 SaveClipboard (Image);
  95.                 break;
  96.  
  97.         }
  98.  
  99.             // Alright, dispose DT object
  100.  
  101.         DisposeDTObject (Image);
  102.  
  103.     }
  104.     else
  105.     {
  106.  
  107.         ErrorRequest ("OK", LocaleString (MSG_ERR_GETIMAGE));
  108.  
  109.     }
  110.  
  111.         // Load notification sound
  112.  
  113.     PlaySound (Set -> Sound . Done);
  114.  
  115.     return (FALSE);
  116.  
  117. }
  118.  
  119. ///
  120.  
  121.