home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / intuition / windows / example2.c < prev    next >
C/C++ Source or Header  |  1995-02-27  |  5KB  |  158 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Windows                     Tulevagen 22       */
  8. /* File:    Example2.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This program will open a high resolution 16 colour Custom Screen */
  21. /* and a normal window which is connected to it. It will display it */
  22. /* for 30 seconds, and then close the Custom Screen and the window. */
  23.  
  24.  
  25.  
  26. /* If your program is using Intuition you should include intuition.h: */
  27. #include <intuition/intuition.h>
  28.  
  29.  
  30.  
  31. struct IntuitionBase *IntuitionBase;
  32.  
  33.  
  34.  
  35. /* Declare a pointer to a Screen structure: */ 
  36. struct Screen *my_screen;
  37.  
  38. /* Declare and initialize your NewScreen structure: */
  39. struct NewScreen my_new_screen=
  40. {
  41.   0,            /* LeftEdge  Should always be 0. */
  42.   0,            /* TopEdge   Top of the display.*/
  43.   640,          /* Width     We are using a high-resolution screen. */
  44.   200,          /* Height    Non-Interlaced NTSC (American) display. */
  45.   4,            /* Depth     16 colours. */
  46.   0,            /* DetailPen Text should be drawn with colour reg. 0 */
  47.   1,            /* BlockPen  Blocks should be drawn with colour reg. 1 */
  48.   HIRES,        /* ViewModes High-resolution. (Non-Interlaced) */
  49.   CUSTOMSCREEN, /* Type      Your own customized screen. */
  50.   NULL,         /* Font      Default font. */
  51.   "MY SCREEN",  /* Title     The screen' title. */
  52.   NULL,         /* Gadget    Must for the moment be NULL. */
  53.   NULL          /* BitMap    No special CustomBitMap. */
  54. };
  55.  
  56.  
  57.  
  58.  
  59. /* Declare a pointer to a Window structure: */ 
  60. struct Window *my_window;
  61.  
  62. /* Declare and initialize your NewWindow structure: */
  63. struct NewWindow my_new_window=
  64. {
  65.   50,            /* LeftEdge    x position of the window. */
  66.   25,            /* TopEdge     y positio of the window. */
  67.   150,           /* Width       150 pixels wide. */
  68.   100,           /* Height      100 lines high. */
  69.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  70.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  71.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  72.   SMART_REFRESH, /* Flags       Intuition should refresh the window. */
  73.   NULL,          /* FirstGadget No Custom Gadgets. */
  74.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  75.   "MY WINDOW",   /* Title       Title of the window. */
  76.   NULL,          /* Screen      We will later connect it to the screen. */
  77.   NULL,          /* BitMap      No Custom BitMap. */
  78.   0,             /* MinWidth    We do not need to care about these */
  79.   0,             /* MinHeight   since we havent supplied the window with */
  80.   0,             /* MaxWidth    a Sizing Gadget. */
  81.   0,             /* MaxHeight */
  82.   CUSTOMSCREEN   /* Type        Connected to a Custom Screen. */
  83. };
  84.  
  85.  
  86.  
  87. main()
  88. {
  89.   /* Open the Intuition Library: */
  90.   IntuitionBase = (struct IntuitionBase *)
  91.     OpenLibrary( "intuition.library", 0 );
  92.   
  93.   if( IntuitionBase == NULL )
  94.     exit(); /* Could NOT open the Intuition Library! */
  95.  
  96.  
  97.  
  98.   /* We will now try to open the screen: */
  99.   my_screen = (struct Screen *) OpenScreen( &my_new_screen );
  100.   
  101.   /* Have we opened the screen succesfully? */
  102.   if(my_screen == NULL)
  103.   {
  104.     /* Could NOT open the Screen! */
  105.     
  106.     /* Close the Intuition Library since we have opened it: */
  107.     CloseLibrary( IntuitionBase );
  108.  
  109.     exit();  
  110.   }
  111.  
  112.  
  113.  
  114.   /* Before we can open the window we need to give the NewWindow */
  115.   /* structure a pointer to the opened Custom Screen: */
  116.   my_new_window.Screen = my_screen;
  117.  
  118.  
  119.  
  120.   /* We will now try to open the window: */
  121.   my_window = (struct Window *) OpenWindow( &my_new_window );
  122.   
  123.   /* Have we opened the window succesfully? */
  124.   if(my_window == NULL)
  125.   {
  126.     /* Could NOT open the Window! */
  127.  
  128.     /* Close the screen since we have opened it: */
  129.     CloseScreen( my_screen );
  130.  
  131.     /* Close the Intuition Library since we have opened it: */
  132.     CloseLibrary( IntuitionBase );
  133.  
  134.     exit();  
  135.   }
  136.  
  137.  
  138.  
  139.   /* We have opened the window, and everything seems to be OK. */
  140.   /* Wait for 30 seconds: */
  141.   Delay( 50 * 30);
  142.  
  143.  
  144.  
  145.   /* We should always close what we have opened: */
  146.   CloseWindow( my_window );
  147.  
  148.   /* Remember that all windows connected to a screen must be closed */
  149.   /* before you may close the screen! */
  150.   CloseScreen( my_screen );
  151.  
  152.  
  153.  
  154.   /* Close the Intuition Library since we have opened it: */
  155.   CloseLibrary( IntuitionBase );
  156.   
  157.   /* THE END */
  158. }