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

  1. /* Example7                                                              */
  2. /* This program will open three windows, two are normal and the third is */
  3. /* a Backdrop window. The windows will use all System Gadgets, except    */
  4. /* the Backdrop window, which only can use the close-window gadget.      */
  5. /* After 30 seconds the program quits.                                   */
  6.  
  7.  
  8.  
  9. /* If your program is using Intuition you should include intuition.h: */
  10. #include <intuition/intuition.h>
  11.  
  12.  
  13.  
  14. struct IntuitionBase *IntuitionBase;
  15.  
  16.  
  17.  
  18. /* Declare a pointer to Window structure number one: */ 
  19. struct Window *my_window1;
  20.  
  21. /* Declare and initialize your NewWindow structure number one: */
  22. struct NewWindow my_new_window1=
  23. {
  24.   50,            /* LeftEdge    x position of the window. */
  25.   25,            /* TopEdge     y positio of the window. */
  26.   200,           /* Width       200 pixels wide. */
  27.   100,           /* Height      100 lines high. */
  28.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  29.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  30.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  31.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  32.   WINDOWCLOSE|   /*             Close Gadget. */
  33.   WINDOWDRAG|    /*             Drag gadget. */
  34.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  35.   WINDOWSIZING,  /*             Sizing Gadget. */
  36.   NULL,          /* FirstGadget No Custom Gadgets. */
  37.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  38.   "MY WINDOW 1", /* Title       Title of the window. */
  39.   NULL,          /* Screen      Connected to the Workbench Screen. */
  40.   NULL,          /* BitMap      No Custom BitMap. */
  41.   80,            /* MinWidth    We will not allow the window to become */
  42.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  43.   300,           /* MaxWidth    than 300 x 200. */
  44.   200,           /* MaxHeight */
  45.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  46. };
  47.  
  48.  
  49.  
  50. /* Declare a pointer to Window structure number two: */
  51. struct Window *my_window2;
  52.  
  53. /* Declare and initialize your NewWindow structure number two: */
  54. struct NewWindow my_new_window2=
  55. {
  56.   300,           /* LeftEdge    x position of the window. */
  57.   50,            /* TopEdge     y positio of the window. */
  58.   200,           /* Width       200 pixels wide. */
  59.   100,           /* Height      100 lines high. */
  60.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  61.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  62.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  63.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  64.   WINDOWCLOSE|   /*             Close Gadget. */
  65.   WINDOWDRAG|    /*             Drag gadget. */
  66.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  67.   WINDOWSIZING|  /*             Sizing Gadget. */
  68.   ACTIVATE,      /*             The window should be Active when opened. */
  69.   NULL,          /* FirstGadget No Custom Gadgets. */
  70.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  71.   "MY WINDOW 2", /* Title       Title of the window. */
  72.   NULL,          /* Screen      Connected to the Workbench Screen. */
  73.   NULL,          /* BitMap      No Custom BitMap. */
  74.   80,            /* MinWidth    We will not allow the window to become */
  75.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  76.   0,             /* MaxWidth    than the default sixe (200x100). */
  77.   0,             /* MaxHeight */
  78.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  79. };
  80.  
  81.  
  82.  
  83. /* Declare a pointer to Window structure number three: */ 
  84. struct Window *my_window3;
  85.  
  86. /* Declare and initialize your NewWindow structure number three: */
  87. struct NewWindow my_new_window3=
  88. {
  89.   10,            /* LeftEdge    x position of the window. */
  90.   10,            /* TopEdge     y positio of the window. */
  91.   400,           /* Width       400 pixels wide. */
  92.   150,           /* Height      150 lines high. */
  93.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  94.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  95.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  96.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  97.   BACKDROP|      /*             Backdrop window. */
  98.   WINDOWCLOSE|   /*             Close Gadget. */
  99.   ACTIVATE,      /*             The window should be Active when opened. */
  100.   NULL,          /* FirstGadget No Custom Gadgets. */
  101.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  102.   "BACKDROP",    /* Title       Title of the window. */
  103.   NULL,          /* Screen      Connected to the Workbench Screen. */
  104.   NULL,          /* BitMap      No Custom BitMap. */
  105.   0,             /* MinWidth    We do not need to care about these */
  106.   0,             /* MinHeight   since we havent supplied the window with */
  107.   0,             /* MaxWidth    a Sizing Gadget. */
  108.   0,             /* MaxHeight */
  109.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  110. };
  111.  
  112.  
  113.  
  114. main()
  115. {
  116.   /* Open the Intuition Library: */
  117.   IntuitionBase = (struct IntuitionBase *)
  118.     OpenLibrary( "intuition.library", 0 );
  119.   
  120.   if( IntuitionBase == NULL )
  121.     exit(); /* Could NOT open the Intuition Library! */
  122.  
  123.  
  124.  
  125.   /* We will now try to open the first window: */
  126.   my_window1 = (struct Window *) OpenWindow( &my_new_window1 );
  127.   
  128.   /* Have we opened the first window succesfully? */
  129.   if(my_window1 == NULL)
  130.   {
  131.     /* Could NOT open the first Window! */
  132.     
  133.     /* Close the Intuition Library since we have opened it: */
  134.     CloseLibrary( IntuitionBase );
  135.  
  136.     exit();  
  137.   }
  138.  
  139.  
  140.  
  141.   /* We will now try to open the second window: */
  142.   my_window2 = (struct Window *) OpenWindow( &my_new_window2 );
  143.   
  144.   /* Have we opened the second window succesfully? */
  145.   if(my_window2 == NULL)
  146.   {
  147.     /* Could NOT open the second Window! */
  148.     
  149.     /* We must close the first window since we have opened it: */
  150.     CloseWindow( my_window1 );
  151.  
  152.     /* Close the Intuition Library since we have opened it: */
  153.     CloseLibrary( IntuitionBase );
  154.  
  155.     exit();  
  156.   }
  157.  
  158.  
  159.  
  160.   /* We will now try to open the third window: (The Backdrop window) */
  161.   my_window3 = (struct Window *) OpenWindow( &my_new_window3 );
  162.   
  163.   /* Have we opened the third window succesfully? */
  164.   if(my_window3 == NULL)
  165.   {
  166.     /* Could NOT open the third Window! */
  167.     
  168.     /* We must close the window one and two since we have opened them: */
  169.     CloseWindow( my_window2 );
  170.     CloseWindow( my_window1 );
  171.  
  172.     /* Close the Intuition Library since we have opened it: */
  173.     CloseLibrary( IntuitionBase );
  174.  
  175.     exit();  
  176.   }
  177.  
  178.  
  179.  
  180.   /* We have opened the windows, and everything seems to be OK. */
  181.   /* Wait for 30 seconds: */
  182.   Delay( 50 * 30);
  183.  
  184.  
  185.  
  186.   /* We should always close the windows we have opened before we leave: */
  187.   /* (It does not matter in which order we close the windows.) */
  188.   CloseWindow( my_window1 );
  189.   CloseWindow( my_window2 );
  190.   CloseWindow( my_window3 );
  191.  
  192.  
  193.  
  194.   /* Close the Intuition Library since we have opened it: */
  195.   CloseLibrary( IntuitionBase );
  196.   
  197.   /* THE END */
  198. }