home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / intuition / windows / example1.c < prev    next >
C/C++ Source or Header  |  1995-02-27  |  4KB  |  110 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:    Example1.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 normal window which is connected to the    */
  21. /* Workbench Screen. It will display it for 30 seconds, and then close */
  22. /* it.                                                                 */
  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 Window structure: */ 
  36. struct Window *my_window;
  37.  
  38. /* Declare and initialize your NewWindow structure: */
  39. struct NewWindow my_new_window=
  40. {
  41.   50,            /* LeftEdge    x position of the window. */
  42.   25,            /* TopEdge     y positio of the window. */
  43.   150,           /* Width       150 pixels wide. */
  44.   100,           /* Height      100 lines high. */
  45.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  46.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  47.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  48.   SMART_REFRESH, /* Flags       Intuition should refresh the window. */
  49.   NULL,          /* FirstGadget No Custom Gadgets. */
  50.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  51.   "MY WINDOW",   /* Title       Title of the window. */
  52.   NULL,          /* Screen      Connected to the Workbench Screen. */
  53.   NULL,          /* BitMap      No Custom BitMap. */
  54.   0,             /* MinWidth    We do not need to care about these */
  55.   0,             /* MinHeight   since we havent supplied the window with */
  56.   0,             /* MaxWidth    a Sizing Gadget. */
  57.   0,             /* MaxHeight */
  58.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  59. };
  60.  
  61.  
  62.  
  63. main()
  64. {
  65.   /* Open the Intuition Library: */
  66.   IntuitionBase = (struct IntuitionBase *)
  67.     OpenLibrary( "intuition.library", 0 );
  68.   
  69.   if( IntuitionBase == NULL )
  70.     exit(); /* Could NOT open the Intuition Library! */
  71.  
  72.  
  73.  
  74.   /* We will now try to open the window: */
  75.   my_window = (struct Window *) OpenWindow( &my_new_window );
  76.   
  77.   /* The "(struct Window *)" is not necessary but it tells the compiler */
  78.   /* that the function OpenWindow() returns a pointer to a Window       */
  79.   /* structure. (See chapter 0 INTRODUCTION for more information about  */
  80.   /* "casting".)                                                        */
  81.  
  82.   /* Have we opened the window succesfully? */
  83.   if(my_window == NULL)
  84.   {
  85.     /* Could NOT open the Window! */
  86.     
  87.     /* Close the Intuition Library since we have opened it: */
  88.     CloseLibrary( IntuitionBase );
  89.  
  90.     exit();  
  91.   }
  92.  
  93.  
  94.  
  95.   /* We have opened the window, and everything seems to be OK. */
  96.   /* Wait for 30 seconds: */
  97.   Delay( 50 * 30);
  98.  
  99.  
  100.  
  101.   /* We should always close the windows we have opened before we leave: */
  102.   CloseWindow( my_window );
  103.  
  104.  
  105.   
  106.   /* Close the Intuition Library since we have opened it: */
  107.   CloseLibrary( IntuitionBase );
  108.   
  109.   /* THE END */
  110. }