home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / technical documentation / macintosh technotes and q&as / technotes / tn / rd_1077.hqx / Routine Descriptors in lib / DemoLib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-09  |  1.2 KB  |  54 lines

  1. #include "DemoLib.h"
  2.  
  3. long    gDemoLong;
  4.  
  5. #pragma export on
  6.  
  7. RoutineDescriptor    Do_DemoRD = BUILD_ROUTINE_DESCRIPTOR(kDo_DemoProcInfo,Do_Demo);
  8. RoutineDescriptor    Set_DemoValueRD = BUILD_ROUTINE_DESCRIPTOR(kSet_DemoValueProcInfo,Set_DemoValue);
  9. RoutineDescriptor    Get_DemoValueRD = BUILD_ROUTINE_DESCRIPTOR(kGet_DemoValueProcInfo,Get_DemoValue);
  10.  
  11. pascal void Do_Demo(void)
  12. {
  13.     Rect tRect = {0,0,200,200};
  14.     WindowPtr tWindowPtr = FrontWindow();
  15.     unsigned char*    strPtr;
  16.     Point tPoint;
  17.  
  18.     if (tWindowPtr)
  19.         tRect = tWindowPtr->portRect;
  20.     tPoint.h = (tRect.right + tRect.left) >> 1;
  21.     tPoint.v = (tRect.top + tRect.bottom) >> 1;
  22.     MoveTo(tPoint.h,tPoint.v + (24 * gDemoLong));
  23.  
  24.     switch (gDemoLong)
  25.     {
  26.         case 0:
  27.             strPtr = (unsigned char*) &"\pThis is the Library! gDemoLong is zero.";
  28.             break;
  29.         case 1:
  30.             strPtr = (unsigned char*) &"\pThis is the Library! gDemoLong is one.";
  31.             break;
  32.         case 2:
  33.             strPtr = (unsigned char*) &"\pThis is the Library! gDemoLong is two.";
  34.             break;
  35.         default:
  36.             strPtr = (unsigned char*) &"\pThis is the Library! gDemoLong is many.";
  37.             gDemoLong = 0;
  38.             break;
  39.     }
  40.     DrawString(strPtr);
  41. }
  42.  
  43. pascal void Set_DemoValue(long pLong)
  44. {
  45.     gDemoLong = pLong;
  46. }
  47.  
  48. pascal long Get_DemoValue(void)
  49. {
  50.     return gDemoLong;
  51. }
  52.  
  53. #pragma export off
  54.