home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / SetVolume.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-03  |  3.4 KB  |  125 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    SetVolume                                                                    */
  4. /*                                                                                                */
  5. /*    File Name:        SetVolume.c                                                                    */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-14    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "TextUtils.h"
  26.  
  27. #include "TestModule.h"
  28.  
  29. /****************************************** DEFINITIONS *****************************************/
  30.  
  31. #define    rGetThreeNumbersDLOG    10000
  32. #define    kNumber1                3
  33. #define    kNumber2                5
  34. #define    kNumber3                7
  35.  
  36. /****************************************** PROTOTYPES ******************************************/
  37.  
  38. short    GetThreeNumbers (short * , short *, short *);
  39. void     DoTest (CHRSPtr paramPtr);
  40.  
  41. /************************************************************************************************/
  42. /************************************************************************************************/
  43.  
  44.  
  45. pascal short TestModule (CHRSPtr paramPtr)
  46. {
  47.     short    returnValue = noErr;
  48.     
  49.     if (paramPtr->version <= kTestModuleVersion) {
  50.         
  51.         DoTest (paramPtr);
  52.         
  53.     }
  54.     else
  55.         returnValue = kWrongVersion;
  56.         
  57.     return (returnValue);
  58. }
  59.  
  60.  
  61. short    GetThreeNumbers (short * number1, short * number2, short * number3)
  62. {
  63.     short        itemKind;
  64.     Handle        itemHand;
  65.     Rect        itemRect;
  66.     short        itemHit;
  67.     DialogPtr    theDialog;
  68.     Str255        itemStr;
  69.     long        tlong;
  70.     
  71.     if ((theDialog = GetNewDialog (rGetThreeNumbersDLOG, nil, (WindowPtr)(-1L))) != nil) {
  72.         GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
  73.         SelIText (theDialog, kNumber1, 0, 32767);
  74.         
  75.         ShowWindow (theDialog);
  76.         
  77.         ModalDialog (nil, &itemHit);
  78.         
  79.         if (itemHit == ok) {
  80.             GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
  81.             GetIText (itemHand, itemStr);
  82.             StringToNum (itemStr, &tlong);
  83.             *number1 = tlong;
  84.  
  85.             GetDItem (theDialog, kNumber2, &itemKind, &itemHand, &itemRect);
  86.             GetIText (itemHand, itemStr);
  87.             StringToNum (itemStr, &tlong);
  88.             *number2 = tlong;
  89.  
  90.             GetDItem (theDialog, kNumber3, &itemKind, &itemHand, &itemRect);
  91.             GetIText (itemHand, itemStr);
  92.             StringToNum (itemStr, &tlong);
  93.             *number3 = tlong;
  94.         }
  95.         
  96.         DisposeDialog (theDialog);
  97.     }
  98.     else
  99.         itemHit = -1;
  100.     
  101.     return (itemHit);
  102. }
  103.  
  104.  
  105. void DoTest (CHRSPtr paramPtr)
  106. {
  107.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  108.     short        itemHit, vtype;
  109.     OSErr        errCode;
  110.     short        level, vstate;
  111.     
  112.     if ((itemHit = GetThreeNumbers (&vtype, &vstate, &level)) == ok) {
  113.         
  114.         if ((errCode = TELSetVolume (termHand, vtype, &level, vstate)) == noErr)
  115.             Print (paramPtr, "TELSetVolume --> level = %d", level);
  116.         else
  117.             Print (paramPtr, "### TELSetVolume failed : %d", errCode);
  118.     }
  119.     else
  120.         if (itemHit == -1)
  121.             Print (paramPtr, "### Unable to get a DLOG resource");
  122. }
  123.  
  124.  
  125.