home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / code_examples / cmanual_456 / windows / example4.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  5KB  |  144 lines

  1. /* Example4                                                              */
  2. /* This program will open two normal windows which are connected to the  */
  3. /* Workbench Screen. The windows will use all System Gadgets. It will    */
  4. /* display them for 30 seconds, and then close them.                     */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* Declare a pointer to Window structure number one: */ 
  18. struct Window *my_window1;
  19.  
  20. /* Declare and initialize your NewWindow structure number one: */
  21. struct NewWindow my_new_window1=
  22. {
  23.   50,            /* LeftEdge    x position of the window. */
  24.   25,            /* TopEdge     y positio of the window. */
  25.   200,           /* Width       200 pixels wide. */
  26.   100,           /* Height      100 lines high. */
  27.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  28.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  29.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  30.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  31.   WINDOWCLOSE|   /*             Close Gadget. */
  32.   WINDOWDRAG|    /*             Drag gadget. */
  33.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  34.   WINDOWSIZING,  /*             Sizing Gadget. */
  35.   NULL,          /* FirstGadget No Custom Gadgets. */
  36.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  37.   "MY WINDOW 1", /* Title       Title of the window. */
  38.   NULL,          /* Screen      Connected to the Workbench Screen. */
  39.   NULL,          /* BitMap      No Custom BitMap. */
  40.   80,            /* MinWidth    We will not allow the window to become */
  41.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  42.   300,           /* MaxWidth    than 300 x 200. */
  43.   200,           /* MaxHeight */
  44.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  45. };
  46.  
  47.  
  48.  
  49. /* Declare a pointer to Window structure number two: */
  50. struct Window *my_window2;
  51.  
  52. /* Declare and initialize your NewWindow structure number two: */
  53. struct NewWindow my_new_window2=
  54. {
  55.   300,           /* LeftEdge    x position of the window. */
  56.   50,            /* TopEdge     y positio of the window. */
  57.   200,           /* Width       200 pixels wide. */
  58.   100,           /* Height      100 lines high. */
  59.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  60.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  61.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  62.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  63.   WINDOWCLOSE|   /*             Close Gadget. */
  64.   WINDOWDRAG|    /*             Drag gadget. */
  65.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  66.   WINDOWSIZING|  /*             Sizing Gadget. */
  67.   ACTIVATE,      /*             The window should be Active when opened. */
  68.   NULL,          /* FirstGadget No Custom Gadgets. */
  69.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  70.   "MY WINDOW 2", /* Title       Title of the window. */
  71.   NULL,          /* Screen      Connected to the Workbench Screen. */
  72.   NULL,          /* BitMap      No Custom BitMap. */
  73.   80,            /* MinWidth    We will not allow the window to become */
  74.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  75.   0,             /* MaxWidth    than the default sixe (200x100). */
  76.   0,             /* MaxHeight */
  77.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  78. };
  79.  
  80.  
  81.  
  82. main()
  83. {
  84.   /* Open the Intuition Library: */
  85.   IntuitionBase = (struct IntuitionBase *)
  86.     OpenLibrary( "intuition.library", 0 );
  87.   
  88.   if( IntuitionBase == NULL )
  89.     exit(); /* Could NOT open the Intuition Library! */
  90.  
  91.  
  92.  
  93.   /* We will now try to open the first window: */
  94.   my_window1 = (struct Window *) OpenWindow( &my_new_window1 );
  95.   
  96.   /* Have we opened the first window succesfully? */
  97.   if(my_window1 == NULL)
  98.   {
  99.     /* Could NOT open the first Window! */
  100.     
  101.     /* Close the Intuition Library since we have opened it: */
  102.     CloseLibrary( IntuitionBase );
  103.  
  104.     exit();  
  105.   }
  106.  
  107.  
  108.  
  109.   /* We will now try to open the second window: */
  110.   my_window2 = (struct Window *) OpenWindow( &my_new_window2 );
  111.   
  112.   /* Have we opened the second window succesfully? */
  113.   if(my_window2 == NULL)
  114.   {
  115.     /* Could NOT open the second Window! */
  116.     
  117.     /* We must close the first window since we have opened it: */
  118.     CloseWindow( my_window1 );
  119.  
  120.     /* Close the Intuition Library since we have opened it: */
  121.     CloseLibrary( IntuitionBase );
  122.  
  123.     exit();  
  124.   }
  125.  
  126.  
  127.  
  128.   /* We have opened the windows, and everything seems to be OK. */
  129.   /* Wait for 30 seconds: */
  130.   Delay( 50 * 30);
  131.  
  132.  
  133.  
  134.   /* We should always close the windows we have opened before we leave: */
  135.   CloseWindow( my_window1 );
  136.   CloseWindow( my_window2 );
  137.  
  138.  
  139.  
  140.   /* Close the Intuition Library since we have opened it: */
  141.   CloseLibrary( IntuitionBase );
  142.   
  143.   /* THE END */
  144. }