home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / intuition / windows / example3.c < prev    next >
C/C++ Source or Header  |  1995-02-27  |  4KB  |  114 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:    Example3.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. The window will use all System Gadgets, and will    */
  22. /* automatically Activate the window. It will display it for 30 seconds, */
  23. /* and then close it. (Remember that the Close Gadget does NOT close the */
  24. /* window by itself, it will only inform you that the user wants to      */
  25. /* close it. But in this example we will not listen to what the user     */
  26. /* wants.)                                                               */
  27.  
  28.  
  29.  
  30. /* If your program is using Intuition you should include intuition.h: */
  31. #include <intuition/intuition.h>
  32.  
  33.  
  34.  
  35. struct IntuitionBase *IntuitionBase;
  36.  
  37.  
  38.  
  39. /* Declare a pointer to a Window structure: */ 
  40. struct Window *my_window;
  41.  
  42. /* Declare and initialize your NewWindow structure: */
  43. struct NewWindow my_new_window=
  44. {
  45.   50,            /* LeftEdge    x position of the window. */
  46.   25,            /* TopEdge     y positio of the window. */
  47.   200,           /* Width       200 pixels wide. */
  48.   100,           /* Height      100 lines high. */
  49.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  50.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  51.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  52.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  53.   WINDOWCLOSE|   /*             Close Gadget. */
  54.   WINDOWDRAG|    /*             Drag gadget. */
  55.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  56.   WINDOWSIZING|  /*             Sizing Gadget. */
  57.   ACTIVATE,      /*             The window should be Active when opened. */
  58.   NULL,          /* FirstGadget No Custom Gadgets. */
  59.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  60.   "MY WINDOW",   /* Title       Title of the window. */
  61.   NULL,          /* Screen      Connected to the Workbench Screen. */
  62.   NULL,          /* BitMap      No Custom BitMap. */
  63.   80,            /* MinWidth    We will not allow the window to become */
  64.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  65.   300,           /* MaxWidth    than 300 x 200. */
  66.   200,           /* MaxHeight */
  67.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  68. };
  69.  
  70.  
  71.  
  72. main()
  73. {
  74.   /* Open the Intuition Library: */
  75.   IntuitionBase = (struct IntuitionBase *)
  76.     OpenLibrary( "intuition.library", 0 );
  77.   
  78.   if( IntuitionBase == NULL )
  79.     exit(); /* Could NOT open the Intuition Library! */
  80.  
  81.  
  82.  
  83.   /* We will now try to open the window: */
  84.   my_window = (struct Window *) OpenWindow( &my_new_window );
  85.   
  86.   /* Have we opened the window succesfully? */
  87.   if(my_window == NULL)
  88.   {
  89.     /* Could NOT open the Window! */
  90.     
  91.     /* Close the Intuition Library since we have opened it: */
  92.     CloseLibrary( IntuitionBase );
  93.  
  94.     exit();  
  95.   }
  96.  
  97.  
  98.  
  99.   /* We have opened the window, and everything seems to be OK. */
  100.   /* Wait for 30 seconds: */
  101.   Delay( 50 * 30);
  102.  
  103.  
  104.  
  105.   /* We should always close the windows we have opened before we leave: */
  106.   CloseWindow( my_window );
  107.  
  108.  
  109.   
  110.   /* Close the Intuition Library since we have opened it: */
  111.   CloseLibrary( IntuitionBase );
  112.   
  113.   /* THE END */
  114. }