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

  1. /* Example2                                                         */
  2. /* This program will open a high resolution 16 colour Custom Screen */
  3. /* and a normal window which is connected to it. It will display it */
  4. /* for 30 seconds, and then close the Custom Screen and the window. */
  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 Screen structure: */ 
  18. struct Screen *my_screen;
  19.  
  20. /* Declare and initialize your NewScreen structure: */
  21. struct NewScreen my_new_screen=
  22. {
  23.   0,            /* LeftEdge  Should always be 0. */
  24.   0,            /* TopEdge   Top of the display.*/
  25.   640,          /* Width     We are using a high-resolution screen. */
  26.   200,          /* Height    Non-Interlaced NTSC (American) display. */
  27.   4,            /* Depth     16 colours. */
  28.   0,            /* DetailPen Text should be drawn with colour reg. 0 */
  29.   1,            /* BlockPen  Blocks should be drawn with colour reg. 1 */
  30.   HIRES,        /* ViewModes High-resolution. (Non-Interlaced) */
  31.   CUSTOMSCREEN, /* Type      Your own customized screen. */
  32.   NULL,         /* Font      Default font. */
  33.   "MY SCREEN",  /* Title     The screen' title. */
  34.   NULL,         /* Gadget    Must for the moment be NULL. */
  35.   NULL          /* BitMap    No special CustomBitMap. */
  36. };
  37.  
  38.  
  39.  
  40.  
  41. /* Declare a pointer to a Window structure: */ 
  42. struct Window *my_window;
  43.  
  44. /* Declare and initialize your NewWindow structure: */
  45. struct NewWindow my_new_window=
  46. {
  47.   50,            /* LeftEdge    x position of the window. */
  48.   25,            /* TopEdge     y positio of the window. */
  49.   150,           /* Width       150 pixels wide. */
  50.   100,           /* Height      100 lines high. */
  51.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  52.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  53.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  54.   SMART_REFRESH, /* Flags       Intuition should refresh the window. */
  55.   NULL,          /* FirstGadget No Custom Gadgets. */
  56.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  57.   "MY WINDOW",   /* Title       Title of the window. */
  58.   NULL,          /* Screen      We will later connect it to the screen. */
  59.   NULL,          /* BitMap      No Custom BitMap. */
  60.   0,             /* MinWidth    We do not need to care about these */
  61.   0,             /* MinHeight   since we havent supplied the window with */
  62.   0,             /* MaxWidth    a Sizing Gadget. */
  63.   0,             /* MaxHeight */
  64.   CUSTOMSCREEN   /* Type        Connected to the Workbench Screen. */
  65. };
  66.  
  67.  
  68.  
  69. main()
  70. {
  71.   /* Open the Intuition Library: */
  72.   IntuitionBase = (struct IntuitionBase *)
  73.     OpenLibrary( "intuition.library", 0 );
  74.   
  75.   if( IntuitionBase == NULL )
  76.     exit(); /* Could NOT open the Intuition Library! */
  77.  
  78.  
  79.  
  80.   /* We will now try to open the screen: */
  81.   my_screen = (struct Screen *) OpenScreen( &my_new_screen );
  82.   
  83.   /* Have we opened the screen succesfully? */
  84.   if(my_screen == NULL)
  85.   {
  86.     /* Could NOT open the Screen! */
  87.     
  88.     /* Close the Intuition Library since we have opened it: */
  89.     CloseLibrary( IntuitionBase );
  90.  
  91.     exit();  
  92.   }
  93.  
  94.  
  95.  
  96.   /* Before we can open the window we need to give the NewWindow */
  97.   /* structure a pointer to the opened Custom Screen: */
  98.   my_new_window.Screen = my_screen;
  99.  
  100.  
  101.  
  102.   /* We will now try to open the window: */
  103.   my_window = (struct Window *) OpenWindow( &my_new_window );
  104.   
  105.   /* Have we opened the window succesfully? */
  106.   if(my_window == NULL)
  107.   {
  108.     /* Could NOT open the Window! */
  109.  
  110.     /* Close the screen since we have opened it: */
  111.     CloseScreen( my_screen );
  112.  
  113.     /* Close the Intuition Library since we have opened it: */
  114.     CloseLibrary( IntuitionBase );
  115.  
  116.     exit();  
  117.   }
  118.  
  119.  
  120.  
  121.   /* We have opened the window, and everything seems to be OK. */
  122.   /* Wait for 30 seconds: */
  123.   Delay( 50 * 30);
  124.  
  125.  
  126.  
  127.   /* We should always close what we have opened: */
  128.   CloseWindow( my_window );
  129.  
  130.   /* Remember that all windows connected to a screen must be closed */
  131.   /* before you may close the screen! */
  132.   CloseScreen( my_screen );
  133.  
  134.  
  135.  
  136.   /* Close the Intuition Library since we have opened it: */
  137.   CloseLibrary( IntuitionBase );
  138.   
  139.   /* THE END */
  140. }