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 / GetVolume.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.0 KB  |  113 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    GetVolume                                                                    */
  4. /*                                                                                                */
  5. /*    File Name:        GetVolume.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-13    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    rGetANumberDLOG        10000
  32. #define    kNumber                3
  33.  
  34. /****************************************** PROTOTYPES ******************************************/
  35.  
  36. short    GetANumber (short * number);
  37. void     DoTest (CHRSPtr paramPtr);
  38.  
  39. /************************************************************************************************/
  40. /************************************************************************************************/
  41.  
  42.  
  43. pascal short TestModule (CHRSPtr paramPtr)
  44. {
  45.     short    returnValue = noErr;
  46.     
  47.     if (paramPtr->version <= kTestModuleVersion) {
  48.         
  49.         DoTest (paramPtr);
  50.         
  51.     }
  52.     else
  53.         returnValue = kWrongVersion;
  54.         
  55.     return (returnValue);
  56. }
  57.  
  58.  
  59. short    GetANumber (short * number)
  60. {
  61.     short        itemKind;
  62.     Handle        itemHand;
  63.     Rect        itemRect;
  64.     short        itemHit;
  65.     DialogPtr    theDialog;
  66.     Str255        itemStr;
  67.     long        tlong;
  68.     
  69.     if ((theDialog = GetNewDialog (rGetANumberDLOG, nil, (WindowPtr)(-1L))) != nil) {
  70.         GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
  71.         SelIText (theDialog, kNumber, 0, 32767);
  72.         
  73.         ShowWindow (theDialog);
  74.         
  75.         ModalDialog (nil, &itemHit);
  76.         
  77.         if (itemHit == ok) {
  78.             GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
  79.             GetIText (itemHand, itemStr);
  80.             StringToNum (itemStr, &tlong);
  81.             *number = tlong;
  82.         }
  83.         
  84.         DisposeDialog (theDialog);
  85.     }
  86.     else
  87.         itemHit = -1;
  88.     
  89.     return (itemHit);
  90. }
  91.  
  92.  
  93. void DoTest (CHRSPtr paramPtr)
  94. {
  95.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  96.     short        itemHit, vtype;
  97.     OSErr        errCode;
  98.     short        level, vstate;
  99.     
  100.     if ((itemHit = GetANumber (&vtype)) == ok) {
  101.         
  102.         if ((errCode = TELGetVolume (termHand, vtype, &level, &vstate)) == noErr)
  103.             Print (paramPtr, "TELGetVolume --> level = %d, vstate = %d", level, vstate);
  104.         else
  105.             Print (paramPtr, "### TELGetVolume failed : %d", errCode);
  106.     }
  107.     else
  108.         if (itemHit == -1)
  109.             Print (paramPtr, "### Unable to get a DLOG resource");
  110. }
  111.  
  112.  
  113.