home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / cdef.sit / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.3 KB  |  57 lines

  1. #include <Quickdraw.h>
  2. #include <WindowMgr.h>
  3. #include <EventMgr.h>
  4. #include <OSUtil.h>
  5. #include <ToolboxUtil.h>
  6. #include <ControlMgr.h>
  7.  
  8. /* teeny sheel to test a control
  9.  * Steve Hawley 8/88
  10.  * Portions are copyright Think Technologies
  11.  */
  12.  
  13. #define RSRC_ID 294  /* resource ID as defined in the project */
  14.  
  15. WindowRecord    wRecord;
  16. WindowPtr    myWindow;
  17. EventRecord myEvent;
  18.  
  19. main ()
  20. {
  21.     Rect screen, r;
  22.     ControlHandle myctrl, thectrl;
  23.     
  24.     InitGraf(&thePort);    /* do inits */
  25.     InitWindows();
  26.     FlushEvents(everyEvent,0);
  27.     SetCursor(&arrow);
  28.     ShowCursor();
  29.     SetRect(&screen, 4, 40, 508, 340); /*set up window */
  30.     myWindow = NewWindow(&wRecord, &screen, "\Pstuff",
  31.             1,0,(char*)-1,1,(long)0);
  32.     SetPort(myWindow);
  33.     ShowWindow(myWindow);
  34.     SetOrigin(0,0);
  35.     TextSize(9);
  36.     
  37.     SetRect(&r, 10, 10, 90, 90);
  38.     
  39.     /* The visible is TRUE ( (char)1 ), initial setting is off (0),
  40.      * range is 0-1, and there is no action procedure.
  41.      */
  42.     myctrl = NewControl(myWindow, &r, "\PA Button", (char)1, 0,  0, 1,
  43.         16 * RSRC_ID, 0L);
  44.  
  45.     while(1) {
  46.         if (GetNextEvent(everyEvent, &myEvent)) {
  47.             /* exit on keypress */
  48.             if (myEvent.what == keyDown) ExitToShell();
  49.             if (myEvent.what == mouseDown) {
  50.                 GlobalToLocal(&myEvent.where);
  51.                 if (FindControl(myEvent.where, myWindow, &thectrl))
  52.                     TrackControl(thectrl, myEvent.where, 0L);
  53.             }
  54.         }
  55.     }    
  56. }
  57.