home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / zfamily.zip / zfamily / ZDTFUNCS / SAMPLE / TSTFIELD.INC < prev    next >
Text File  |  1993-09-21  |  4KB  |  111 lines

  1. /*
  2. ** /----------------------------------------------------------------------\
  3. ** |             IBM Z Family Reusable Libraries/2 (5641-504)             |
  4. ** |----------------------------------------------------------------------|
  5. ** | (C) Copyright International Business Machines Corporation 1993, 1994 |
  6. ** |----------------------------------------------------------------------|
  7. ** |                       DISCLAIMER OF WARRANTIES                       |
  8. ** |                       ------------------------                       |
  9. ** | The following code is sample code created by IBM Corporation.        |
  10. ** | Such a code is provided to you solely for the purpose of assisting   |
  11. ** | you in the development of your applications. The code is provided    |
  12. ** | "AS IS", without warranty of any kind.  IBM shall not be liable for  |
  13. ** | any damages arising out of your use of the following code, even if   |
  14. ** | they have been advised of the possibility of such damages.           |                                                                         *
  15. ** \----------------------------------------------------------------------/
  16. **
  17. **  Include : TSTFIELD.INC
  18. **  Author  : Dario de Judicibus (DEJUDICI at ROMEPPC)
  19. **  Created : 21 Sep 1992
  20. **  Updated : 20 Sep 1993
  21. **  Version : 4.12
  22. **  Content : Called in WM_CONTROL (case TMEZONOFFFLD)
  23. **
  24. */
  25.  {
  26.    switch(SHORT2FROMMP(mp1)) // Switch on Notification Code
  27.    {
  28.     case EN_CHANGE :    // Entry field is changed
  29.          {
  30.            CHAR   *cursor       ; // Cursor for field validation
  31.            USHORT  result       ; // Result from number validation
  32.            LONG    offset       ;
  33.            CHAR    szWorkBuf[5] ; // Local scratch memory
  34.  
  35.            Tmezon = (TMEZONStruct *)WinQueryWindowULong(hWndClient, OFFSET_TMEZON) ;
  36.  
  37.           /*
  38.           **  Avoid looping between slider TMEZONOFFSLD and field TMEZONOFFFLD
  39.           */
  40.            if (! Tmezon->fromSlider)
  41.            {
  42.              WinQueryDlgItemText(hWndDlg, TMEZONOFFFLD, 5, szWorkBuf) ;
  43.  
  44.             /*
  45.             **  Check field. There are three possible results:
  46.             **
  47.             **  tstVALID       Valid number
  48.             **  tstPARTIAL     Partial number (space, sign only)
  49.             **  tstOUTOFRANGE  Number is out of range
  50.             **  tstNOTANUMBER  String is not a number
  51.             */
  52.              result = tstCheckNumber(szWorkBuf, &offset, -12, 12) ;
  53.  
  54.              switch (result)
  55.              {
  56.                case tstVALID:
  57.                {
  58.                  Tmezon->TmeZonOffset = offset ;
  59.  
  60.                  Tmezon->fromField = TRUE ;  // Message to SLIDER from FIELD
  61.  
  62.                  WinSendDlgItemMsg(hWndDlg, TMEZONOFFSLD,
  63.                                    SLM_SETSLIDERINFO,
  64.                                    MPFROM2SHORT(SMA_SLIDERARMPOSITION,
  65.                                    SMA_INCREMENTVALUE),
  66.                                    MPFROMSHORT(Tmezon->TmeZonOffset+12)) ;
  67.  
  68.                  Tmezon->fromField = FALSE ; // Reset flag
  69.                }
  70.                break;
  71.  
  72.                case tstOUTOFRANGE:
  73.                {
  74.                  char szMsgBuffer[80] ;
  75.  
  76.                  WinLoadString(hAB, 0, tstERR_INVALIDZONE, 80, szMsgBuffer) ;
  77.                  WinMessageBox(HWND_DESKTOP, hWndParent, szMsgBuffer,
  78.                                0, 0, MB_OK|MB_ICONEXCLAMATION) ;
  79.                }
  80.                break;
  81.  
  82.                case tstNOTANUMBER:
  83.                {
  84.                  char szMsgBuffer[80] ;
  85.  
  86.                  WinLoadString(hAB, 0, tstERR_NOTANUMBER, 80, szMsgBuffer) ;
  87.                  WinMessageBox(HWND_DESKTOP, hWndParent, szMsgBuffer,
  88.                                0, 0, MB_OK|MB_ICONEXCLAMATION) ;
  89.                }
  90.                break;
  91.  
  92.                default: // tstPARTIAL
  93.                {
  94.                  return(WinDefDlgProc(hWndDlg, message, mp1, mp2)) ;
  95.                }
  96.                break;
  97.              }
  98.            }
  99.            else
  100.            {
  101.              return(WinDefDlgProc(hWndDlg, message, mp1, mp2)) ;
  102.            }
  103.          }
  104.          break ;
  105.  
  106.     default :           // Default other messages
  107.          return(WinDefDlgProc(hWndDlg, message, mp1, mp2)) ;
  108.          break ;
  109.    }
  110.  }
  111.