home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / c / cmanual / intuition / windows / example4.c < prev    next >
C/C++ Source or Header  |  1993-10-12  |  6KB  |  162 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:    Example4.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 two normal windows which are connected to the  */
  21. /* Workbench Screen. The windows will use all System Gadgets. It will    */
  22. /* display them for 30 seconds, and then close them.                     */
  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 Window structure number one: */ 
  36. struct Window *my_window1;
  37.  
  38. /* Declare and initialize your NewWindow structure number one: */
  39. struct NewWindow my_new_window1=
  40. {
  41.   50,            /* LeftEdge    x position of the window. */
  42.   25,            /* TopEdge     y positio of the window. */
  43.   200,           /* Width       200 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.   WINDOWCLOSE|   /*             Close Gadget. */
  50.   WINDOWDRAG|    /*             Drag gadget. */
  51.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  52.   WINDOWSIZING,  /*             Sizing Gadget. */
  53.   NULL,          /* FirstGadget No Custom Gadgets. */
  54.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  55.   "MY WINDOW 1", /* Title       Title of the window. */
  56.   NULL,          /* Screen      Connected to the Workbench Screen. */
  57.   NULL,          /* BitMap      No Custom BitMap. */
  58.   80,            /* MinWidth    We will not allow the window to become */
  59.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  60.   300,           /* MaxWidth    than 300 x 200. */
  61.   200,           /* MaxHeight */
  62.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  63. };
  64.  
  65.  
  66.  
  67. /* Declare a pointer to Window structure number two: */
  68. struct Window *my_window2;
  69.  
  70. /* Declare and initialize your NewWindow structure number two: */
  71. struct NewWindow my_new_window2=
  72. {
  73.   300,           /* LeftEdge    x position of the window. */
  74.   50,            /* TopEdge     y positio of the window. */
  75.   200,           /* Width       200 pixels wide. */
  76.   100,           /* Height      100 lines high. */
  77.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  78.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  79.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  80.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  81.   WINDOWCLOSE|   /*             Close Gadget. */
  82.   WINDOWDRAG|    /*             Drag gadget. */
  83.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  84.   WINDOWSIZING|  /*             Sizing Gadget. */
  85.   ACTIVATE,      /*             The window should be Active when opened. */
  86.   NULL,          /* FirstGadget No Custom Gadgets. */
  87.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  88.   "MY WINDOW 2", /* Title       Title of the window. */
  89.   NULL,          /* Screen      Connected to the Workbench Screen. */
  90.   NULL,          /* BitMap      No Custom BitMap. */
  91.   80,            /* MinWidth    We will not allow the window to become */
  92.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  93.   0,             /* MaxWidth    than the default sixe (200x100). */
  94.   0,             /* MaxHeight */
  95.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  96. };
  97.  
  98.  
  99.  
  100. main()
  101. {
  102.   /* Open the Intuition Library: */
  103.   IntuitionBase = (struct IntuitionBase *)
  104.     OpenLibrary( "intuition.library", 0 );
  105.   
  106.   if( IntuitionBase == NULL )
  107.     exit(); /* Could NOT open the Intuition Library! */
  108.  
  109.  
  110.  
  111.   /* We will now try to open the first window: */
  112.   my_window1 = (struct Window *) OpenWindow( &my_new_window1 );
  113.   
  114.   /* Have we opened the first window succesfully? */
  115.   if(my_window1 == NULL)
  116.   {
  117.     /* Could NOT open the first Window! */
  118.     
  119.     /* Close the Intuition Library since we have opened it: */
  120.     CloseLibrary( IntuitionBase );
  121.  
  122.     exit();  
  123.   }
  124.  
  125.  
  126.  
  127.   /* We will now try to open the second window: */
  128.   my_window2 = (struct Window *) OpenWindow( &my_new_window2 );
  129.   
  130.   /* Have we opened the second window succesfully? */
  131.   if(my_window2 == NULL)
  132.   {
  133.     /* Could NOT open the second Window! */
  134.     
  135.     /* We must close the first window since we have opened it: */
  136.     CloseWindow( my_window1 );
  137.  
  138.     /* Close the Intuition Library since we have opened it: */
  139.     CloseLibrary( IntuitionBase );
  140.  
  141.     exit();  
  142.   }
  143.  
  144.  
  145.  
  146.   /* We have opened the windows, and everything seems to be OK. */
  147.   /* Wait for 30 seconds: */
  148.   Delay( 50 * 30);
  149.  
  150.  
  151.  
  152.   /* We should always close the windows we have opened before we leave: */
  153.   CloseWindow( my_window1 );
  154.   CloseWindow( my_window2 );
  155.  
  156.  
  157.  
  158.   /* Close the Intuition Library since we have opened it: */
  159.   CloseLibrary( IntuitionBase );
  160.   
  161.   /* THE END */
  162. }