home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Snippets / CustomDialog Demo / Source / Setup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-31  |  2.5 KB  |  108 lines  |  [TEXT/MMCC]

  1. /**********************************************************************
  2.  *
  3.  *                        CustomGetFile Dialog Demo
  4.  *
  5.  *    Setup.c
  6.  *
  7.  *    Written in CodeWarrior Gold 5.5
  8.  *    August 31, 1995
  9.  *
  10.  *    Copyright © 1995 Carl B. Constantine
  11.  *    Some portions Copyright © 1995 MetroWerks, Inc.
  12.  *    Some portions Copyright © 1995 Apple Computer, Inc.
  13.  *
  14.  **********************************************************************/
  15.  
  16.  /*------------------------------------------------------------------
  17.   #
  18.   #                            File History
  19.   #
  20.   #        Date                Description of Change
  21.   #        ----                ---------------------
  22.   #        Aug 31/93            — Original creation of file
  23.   #
  24.   #
  25.   -------------------------------------------------------------------*/
  26.  
  27. #include <Traps.h>
  28.  
  29. #include "AppConstants.h"
  30. #include "AppGlobals.h"
  31. #include "ErrUtils.h"
  32. #include "Setup.h"
  33. #include "TrapUtils.h"
  34.  
  35. /*======================== Procedures & Functions =======================*/
  36.  
  37. void Initialize( void )
  38. {
  39.     short            count;
  40.     Handle            menuBar;
  41.     EventRecord        event;
  42.     
  43.     gInBackground = FALSE;
  44.     gQuitting = FALSE;
  45.     
  46.     /*    Allocate more master pointers for the application early in the heap
  47.         to reduce fragmentation of the heap. */
  48.         
  49.     for ( count = 1; count <= 10; count++ )
  50.         MoreMasters();
  51.         
  52.     FlushEvents( everyEvent, 0);    /* get rid of extra Finder Events */
  53.     
  54.     InitGraf( &qd.thePort );
  55.     InitFonts();
  56.     InitWindows();
  57.     InitMenus();
  58.     TEInit();
  59.     InitDialogs( NIL );
  60.     InitCursor();
  61.     
  62.     /*    This next bit of code waits until MultiFinder brings the application
  63.         to the front.  This gives a better effect if a window is opened at
  64.         startup. */
  65.         
  66.     for (count = 1; count <= 5; count++ )
  67.         EventAvail( everyEvent, &event );
  68.         
  69.     SystemCheck();
  70.     
  71.     TEFromScrap();        /* Collect anything on the clipboard */
  72.     
  73.     menuBar = GetNewMBar( rMenuBar );
  74.     if ( menuBar )
  75.     {
  76.         SetMenuBar( menuBar );
  77.         DisposeHandle( menuBar );
  78.         AddResMenu( GetMHandle( mApple), 'DRVR' );    /* Add Apple Menu Items */
  79.         DrawMenuBar();
  80.     } 
  81.     else
  82.         ExitToShell();
  83.     
  84.                         
  85. }
  86.  
  87. /*----------------------------------------------------------------------------*/
  88.  
  89. /*    I use this routine to do the extra system checking.  Things like what system
  90.     version we are running, what type of Mac we are running on, etc.  I am not
  91.     allowing any System less than System 7.    
  92. */
  93.     
  94. void SystemCheck( void )
  95. {
  96.     long        machineType, qdVersion;
  97.  
  98.  
  99.     if ( !GestaltAvailable() || !System7Available() )
  100.         DeathAlert( errWimpySystem );
  101.     
  102.     if ( !TrapAvailable( _WaitNextEvent ) )
  103.         DeathAlert( errWeirdSystem );
  104.         
  105. }
  106.  
  107.  
  108. /*============================= End of File ==============================*/