home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / zfamily.zip / zfamily / ZNLFUNCS / SAMPLE / TSTCUR.INC < prev    next >
Text File  |  1993-09-21  |  5KB  |  142 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. ** Header   : TSTCUR.INC
  18. ** Author   : Valerio Tavazzi (TAVAZZI at ROMEPPC)
  19. ** Reviewer : Dario de Judicibus (DEJUDICI at ROMEPPC)
  20. ** Created  : 16 Jul 1992
  21. ** Updated  : 21 Sep 1993
  22. ** Version  : 3.22
  23. ** Content  : Called by CURFMTMsgProc in WM_INITDLG case statement
  24. **
  25. */
  26.  {
  27.    char pszCurSample [znlLONGBUFFER] , // Formatted currency string
  28.         pszCurin     [znlLONGBUFFER] , // Currency string in inner format
  29.         pszTempCur   [znlLONGBUFFER] ; // Temporary currency string
  30.  
  31.   /*
  32.   **  Format the currency string for country  
  33.   */
  34.    if (! znlMakeCtryPrice(&Country, tstCURSAMPLE, pszTempCur)) return(FALSE) ;                                                              
  35.  
  36.   /*
  37.   **  Get currency string in inner format     
  38.   */
  39.    if(!znlMakeInnerPrice(&Country, pszTempCur, pszCurin)) return(FALSE) ;                                                           
  40.  
  41.    Curfmt = (CURFMTStruct *)WinQueryWindowULong(hWndClient, OFFSET_CURFMT) ;
  42.  
  43.    Curfmt->CurFmtLeadZeros = Country.LeadZero ;
  44.    Curfmt->CurFmtDecDigits = Country.CtryInfo.cDecimalPlace ;
  45.    strcpy(Curfmt->CurFmtSymbol , Country.CtryInfo.szCurrency) ;
  46.  
  47.   /*
  48.   **  Create output string pszCurSample containing the formatted currency string
  49.   */
  50.    if (! znlMakeCtryPrice(&Country, pszCurin, pszCurSample)) break ;
  51.  
  52.    switch (Country.CtryInfo.fsCurrencyFmt)
  53.    {
  54.      case 0 :   // Prefix, no Interspace
  55.      {
  56.        Curfmt->CurFmtInterSpace = 0 ; // There's no intervening character
  57.  
  58.       /*
  59.       **  Set radio buttons 
  60.       */
  61.        cwCheckDlgItem(hWndDlg, CURFMTPFXRDB, TRUE) ;                        
  62.        cwCheckDlgItem(hWndDlg, CURFMTSFXRDB, FALSE) ;
  63.      }
  64.      break ;
  65.  
  66.      case 1 :   // Suffix, no Interspace
  67.      {
  68.        Curfmt->CurFmtInterSpace = 0 ; // There's no intervening character
  69.  
  70.       /*
  71.       **  Set radio buttons 
  72.       */
  73.        cwCheckDlgItem(hWndDlg, CURFMTPFXRDB, FALSE) ;   
  74.        cwCheckDlgItem(hWndDlg, CURFMTSFXRDB, TRUE) ;
  75.      }
  76.      break ;
  77.  
  78.      case 2 :   // Prefix, Interspace
  79.      {
  80.        Curfmt->CurFmtInterSpace = 1 ; // There is intervening character
  81.  
  82.       /*
  83.       **  Set radio buttons 
  84.       */
  85.        cwCheckDlgItem(hWndDlg, CURFMTPFXRDB, TRUE) ;  
  86.        cwCheckDlgItem(hWndDlg, CURFMTSFXRDB, FALSE) ;
  87.      }
  88.      break ;
  89.  
  90.      case 3 :   // Suffix, Interspace
  91.      {
  92.        Curfmt->CurFmtInterSpace = 1 ; // There is intervening character
  93.  
  94.       /*
  95.       **  Set radio buttons 
  96.       */
  97.        cwCheckDlgItem(hWndDlg, CURFMTPFXRDB, FALSE) ;   // set radio buttons
  98.        cwCheckDlgItem(hWndDlg, CURFMTSFXRDB, TRUE) ;
  99.      }
  100.      break ;
  101.    }
  102.  
  103.   /*
  104.   **  Initialize entry field control: CurFmtSymbol
  105.   */
  106.    WinSendDlgItemMsg(hWndDlg, CURFMTSYMFLD, EM_SETTEXTLIMIT, MPFROMSHORT(8), 0L) ;
  107.    if (Curfmt->CurFmtSymbol[0])
  108.      WinSetDlgItemText(hWndDlg, CURFMTSYMFLD, Curfmt->CurFmtSymbol) ;
  109.  
  110.   /*
  111.   **  Initialize check box control: CurFmtInterSpace
  112.   */
  113.    WinSendDlgItemMsg(hWndDlg, CURFMTISPCHK, BM_SETCHECK,
  114.             MPFROMSHORT(Curfmt->CurFmtInterSpace), 0L) ;
  115.  
  116.   /*
  117.   **  Initialize check box control: CurFmtLeadZeros
  118.   */
  119.    WinSendDlgItemMsg(hWndDlg, CURFMTLZRCHK, BM_SETCHECK,
  120.             MPFROMSHORT(Curfmt->CurFmtLeadZeros), 0L) ;
  121.  
  122.   /*
  123.   **  Initialize entry field control: CurFmtDecDigits
  124.   */
  125.    {
  126.      CHAR szWorkBuf[50] ; // local scratch memory
  127.  
  128.      if(Curfmt->CurFmtDecDigits != 0)
  129.      {
  130.        _itoa(Curfmt->CurFmtDecDigits, szWorkBuf, 10) ;
  131.        WinSetDlgItemText(hWndDlg, CURFMTDGTFLD, szWorkBuf) ;
  132.      }
  133.    }
  134.  
  135.   /*
  136.   **  Initialize entry field control: CurFmtSample
  137.   */
  138.    WinSendDlgItemMsg(hWndDlg, CURFMTSMPFLD, EM_SETTEXTLIMIT, MPFROMSHORT(16), 0L) ;
  139.    if (pszCurSample[0])
  140.      WinSetDlgItemText(hWndDlg, CURFMTSMPFLD, pszCurSample) ;
  141.  }
  142.