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

  1. /* Example1                                                            */
  2. /* This program will open a normal window which is connected to the    */
  3. /* Workbench Screen. It will display it for 30 seconds, and then close */
  4. /* it.                                                                 */
  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 a Window structure: */ 
  18. struct Window *my_window;
  19.  
  20. /* Declare and initialize your NewWindow structure: */
  21. struct NewWindow my_new_window=
  22. {
  23.   50,            /* LeftEdge    x position of the window. */
  24.   25,            /* TopEdge     y positio of the window. */
  25.   150,           /* Width       150 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.   NULL,          /* FirstGadget No Custom Gadgets. */
  32.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  33.   "MY WINDOW",   /* Title       Title of the window. */
  34.   NULL,          /* Screen      Connected to the Workbench Screen. */
  35.   NULL,          /* BitMap      No Custom BitMap. */
  36.   0,             /* MinWidth    We do not need to care about these */
  37.   0,             /* MinHeight   since we havent supplied the window with */
  38.   0,             /* MaxWidth    a Sizing Gadget. */
  39.   0,             /* MaxHeight */
  40.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  41. };
  42.  
  43.  
  44.  
  45. main()
  46. {
  47.   /* Open the Intuition Library: */
  48.   IntuitionBase = (struct IntuitionBase *)
  49.     OpenLibrary( "intuition.library", 0 );
  50.   
  51.   if( IntuitionBase == NULL )
  52.     exit(); /* Could NOT open the Intuition Library! */
  53.  
  54.  
  55.  
  56.   /* We will now try to open the window: */
  57.   my_window = (struct Window *) OpenWindow( &my_new_window );
  58.   
  59.   /* The "(struct Window *)" is not necessary but it tells the compiler */
  60.   /* that the function OpenWindow() returns a pointer to a Window       */
  61.   /* structure. (See chapter 0 INTRODUCTION for more information about  */
  62.   /* "casting".)                                                        */
  63.  
  64.   /* Have we opened the window succesfully? */
  65.   if(my_window == NULL)
  66.   {
  67.     /* Could NOT open the Window! */
  68.     
  69.     /* Close the Intuition Library since we have opened it: */
  70.     CloseLibrary( IntuitionBase );
  71.  
  72.     exit();  
  73.   }
  74.  
  75.  
  76.  
  77.   /* We have opened the window, and everything seems to be OK. */
  78.   /* Wait for 30 seconds: */
  79.   Delay( 50 * 30);
  80.  
  81.  
  82.  
  83.   /* We should always close the windows we have opened before we leave: */
  84.   CloseWindow( my_window );
  85.  
  86.  
  87.   
  88.   /* Close the Intuition Library since we have opened it: */
  89.   CloseLibrary( IntuitionBase );
  90.   
  91.   /* THE END */
  92. }