home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / varia / toolmanager / developer / c / examples / showimage.c < prev   
C/C++ Source or Header  |  1977-12-31  |  2KB  |  77 lines

  1. /*
  2.  * ShowImage.c  V3.0
  3.  *
  4.  * Show an image file in a ToolManager dock
  5.  *
  6.  * Copyright (C) 1990-97 Stefan Becker
  7.  *
  8.  * This source code is for educational purposes only. You may study it
  9.  * and copy ideas or algorithms from it for your own projects. It is
  10.  * not allowed to use any of the source codes (in full or in parts)
  11.  * in other programs. Especially it is not allowed to create variants
  12.  * of ToolManager or ToolManager-like programs from this source code.
  13.  *
  14.  */
  15.  
  16. #include <dos/dos.h>
  17. #include <utility/tagitem.h>
  18. #include <clib/exec_protos.h>
  19. #include <clib/toolmanager_protos.h>
  20. #include <pragmas/exec_pragmas.h>
  21. #include <pragmas/toolmanager_pragmas.h>
  22. #include <stdlib.h>
  23.  
  24. extern struct Library *SysBase;
  25.  
  26. char *Tool[] = {NULL, "Image", NULL};
  27.  
  28. struct TagItem Dock[] = {
  29.  TMOP_Activated, TRUE,
  30.  TMOP_Border,    TRUE,
  31.  TMOP_Centered,  TRUE,
  32.  TMOP_FrontMost, TRUE,
  33.  TMOP_Images,    TRUE,
  34.  TMOP_Columns,   1,
  35.  TMOP_Tool,      (ULONG) Tool,
  36.  TAG_DONE
  37. };
  38.  
  39. /* Main entry point */
  40. int main(int argc, char *argv[])
  41. {
  42.  int rc = RETURN_FAIL;
  43.  
  44.  /* Check argument count */
  45.  if (argc > 1) {
  46.   struct Library *ToolManagerBase;
  47.  
  48.   /* Open toolmanager.library */
  49.   if (ToolManagerBase = OpenLibrary(TMLIBNAME, 0)) {
  50.    void *handle;
  51.  
  52.    /* Create handle */
  53.    if (handle = AllocTMHandle()) {
  54.  
  55.     /* Create image */
  56.     if (CreateTMObjectTags(handle, "Image", TMOBJTYPE_IMAGE,
  57.                                                             TMOP_File, argv[1],
  58.                                                             TAG_DONE)) {
  59.  
  60.      /* Create dock with image */
  61.      if (CreateTMObjectTagList(handle, "ShowImage", TMOBJTYPE_DOCK, Dock)) {
  62.  
  63.       /* Wait for CTRL-C/D/E/F */
  64.       Wait(0xF000);
  65.  
  66.       rc = RETURN_OK;
  67.      }
  68.     }
  69.     FreeTMHandle(handle);
  70.    }
  71.    CloseLibrary(ToolManagerBase);
  72.   }
  73.  }
  74.  
  75.  return(rc);
  76. }
  77.