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

  1. /* Example3                                                              */
  2. /* This program will open a normal window which is connected to the      */
  3. /* Workbench Screen. The window will use all System Gadgets, and will    */
  4. /* automatically Activate the window. It will display it for 30 seconds, */
  5. /* and then close it. (Remember that the Close Gadget does NOT close the */
  6. /* window by itself, it will only inform you that the user wants to      */
  7. /* close it. But in this example we will not listen to what the user     */
  8. /* wants.)                                                               */
  9.  
  10.  
  11.  
  12. /* If your program is using Intuition you should include intuition.h: */
  13. #include <intuition/intuition.h>
  14.  
  15.  
  16.  
  17. struct IntuitionBase *IntuitionBase;
  18.  
  19.  
  20.  
  21. /* Declare a pointer to a Window structure: */ 
  22. struct Window *my_window;
  23.  
  24. /* Declare and initialize your NewWindow structure: */
  25. struct NewWindow my_new_window=
  26. {
  27.   50,            /* LeftEdge    x position of the window. */
  28.   25,            /* TopEdge     y positio of the window. */
  29.   200,           /* Width       200 pixels wide. */
  30.   100,           /* Height      100 lines high. */
  31.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  32.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  33.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  34.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  35.   WINDOWCLOSE|   /*             Close Gadget. */
  36.   WINDOWDRAG|    /*             Drag gadget. */
  37.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  38.   WINDOWSIZING|  /*             Sizing Gadget. */
  39.   ACTIVATE,      /*             The window should be Active when opened. */
  40.   NULL,          /* FirstGadget No Custom Gadgets. */
  41.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  42.   "MY WINDOW",   /* Title       Title of the window. */
  43.   NULL,          /* Screen      Connected to the Workbench Screen. */
  44.   NULL,          /* BitMap      No Custom BitMap. */
  45.   80,            /* MinWidth    We will not allow the window to become */
  46.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  47.   300,           /* MaxWidth    than 300 x 200. */
  48.   200,           /* MaxHeight */
  49.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  50. };
  51.  
  52.  
  53.  
  54. main()
  55. {
  56.   /* Open the Intuition Library: */
  57.   IntuitionBase = (struct IntuitionBase *)
  58.     OpenLibrary( "intuition.library", 0 );
  59.   
  60.   if( IntuitionBase == NULL )
  61.     exit(); /* Could NOT open the Intuition Library! */
  62.  
  63.  
  64.  
  65.   /* We will now try to open the window: */
  66.   my_window = (struct Window *) OpenWindow( &my_new_window );
  67.   
  68.   /* Have we opened the window succesfully? */
  69.   if(my_window == NULL)
  70.   {
  71.     /* Could NOT open the Window! */
  72.     
  73.     /* Close the Intuition Library since we have opened it: */
  74.     CloseLibrary( IntuitionBase );
  75.  
  76.     exit();  
  77.   }
  78.  
  79.  
  80.  
  81.   /* We have opened the window, and everything seems to be OK. */
  82.   /* Wait for 30 seconds: */
  83.   Delay( 50 * 30);
  84.  
  85.  
  86.  
  87.   /* We should always close the windows we have opened before we leave: */
  88.   CloseWindow( my_window );
  89.  
  90.  
  91.   
  92.   /* Close the Intuition Library since we have opened it: */
  93.   CloseLibrary( IntuitionBase );
  94.   
  95.   /* THE END */
  96. }