home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 January / Chip_Special_Best_Web_Sites_01-96.iso / pc / zugang / maz / mazprocs.sa_ / mazprocs.sa
Text File  |  1994-11-23  |  9KB  |  222 lines

  1. /***************************************************************************/
  2. /*********************  CLS Dialog Procedures     **************************/
  3. /***************************************************************************/
  4.  
  5.  
  6. /*
  7. **      Purpose:
  8. **              Radio Button Group Dialog procedure for templates with one group
  9. **              of one to ten radio button controls.
  10. **
  11. **      Controls Recognized:
  12. **              Radio      - IDC_B1 to IDC_B10 (sequential)
  13. **              Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  14. **
  15. **      Initialization Symbols:
  16. **              "RadioDefault" - index (one-based) of radio button to be
  17. **                      initialized as selected (default is "1").
  18. **              "OptionsGreyed" - list of (one-based) indexes of radio buttons
  19. **                      to be initialized as disabled.  Indexes not in the list will
  20. **                      be left enabled.
  21. **
  22. **      Termination Symbols:
  23. **              "ButtonChecked" - index of currently selected radio button.
  24. **              "DLGEVENT"      - one of the following, depending on event:
  25. **                              event                value
  26. **                              ----------           ----------
  27. **                              IDC_B                "BACK"
  28. **                              IDC_C                "CONTINUE"
  29. **                              IDC_X                "EXIT"
  30. **                              IDCANCEL             "CANCEL"
  31. **                              STF_ACTIVATEAPP      "REACTIVATE"
  32. **
  33. **      Note:
  34. **              Pushbutton IDC_H will open the related Help dialog, if any.
  35. **
  36. *****************************************************************************/
  37. BOOL FAR PASCAL FModemConfDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  38. {
  39.         char rgchNum[10];
  40.         int  iButtonChecked;
  41.         char szSymBuf[cbSymBuf];
  42.         static WORD wSelStart = 0;
  43.         static WORD wSelEnd   = 0;
  44.         char  rgchText[cbFullPathMax + 1];
  45.         WORD i, cb, cItems, idc;
  46.         WORD  cbLen;
  47.  
  48.         switch (wMsg)
  49.                 {
  50.         case STF_ACTIVATEAPP:
  51.                 if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  52.                         {
  53.                         DestroyWindow(GetParent(hdlg));
  54.                         return(fTrue);
  55.                         }
  56.                 ReactivateSetupScript();
  57.                 return(fTrue);
  58.  
  59.         case WM_INITDIALOG:
  60.                 cb = CbGetSymbolValue("RadioDefault", szSymBuf, cbSymBuf);
  61.                 Assert(cb < cbSymBuf);
  62.                 if (*szSymBuf != '\0')
  63.                         {
  64.                         iButtonChecked = AsciiToInt((LPSTR)szSymBuf);
  65.                         if (iButtonChecked < 1)
  66.                                 iButtonChecked = 0;
  67.                         if (iButtonChecked > 10)
  68.                                 iButtonChecked = 10;
  69.                         }
  70.                 else
  71.                         iButtonChecked = 1;
  72.  
  73.                 if (iButtonChecked != 0)
  74.                         SendDlgItemMessage(hdlg, IDC_B0 + iButtonChecked, BM_SETCHECK,1,0L);
  75.  
  76.                 cItems = UsGetListLength("OptionsGreyed");
  77.                 idc = IDC_B1;
  78.                 for (i = 1; i <= cItems; ++i)
  79.                         {
  80.                         int iOpt;
  81.  
  82.                         cb = CbGetListItem("OptionsGreyed", i, szSymBuf, cbSymBuf);
  83.                         Assert(cb < cbSymBuf);
  84.                         iOpt  = AsciiToInt((LPSTR)szSymBuf);
  85.                         if (iOpt > 0
  86.                                         && iOpt <= 10
  87.                                         && iOpt != iButtonChecked)
  88.                                 EnableWindow(GetDlgItem(hdlg, IDC_B0 + iOpt), 0);
  89.                         else if (*szSymBuf != '\0')
  90.                                 Assert(fFalse);
  91.                         }
  92.  
  93.                 cb = CbGetSymbolValue("Modem_InitIn", szSymBuf, cbFullPathMax + 1);
  94.                 Assert(cb < cbFullPathMax + 1);
  95.                 SendDlgItemMessage(hdlg, Modem_Init, EM_LIMITTEXT, cbFullPathMax, 0L);
  96.                 SetDlgItemText(hdlg, Modem_Init, (LPSTR)szSymBuf);
  97.  
  98.                 cb = CbGetSymbolValue("Modem_DialIn", szSymBuf, cbFullPathMax + 1);
  99.                 Assert(cb < cbFullPathMax + 1);
  100.                 SendDlgItemMessage(hdlg, Modem_Dial, EM_LIMITTEXT, cbFullPathMax, 0L);
  101.                 SetDlgItemText(hdlg, Modem_Dial, (LPSTR)szSymBuf);
  102.  
  103.                 cbLen = lstrlen(szSymBuf);
  104.                 cb = CbGetSymbolValue("EditFocus", szSymBuf, cbFullPathMax + 1);
  105.                 Assert(cb < cbFullPathMax + 1);
  106.  
  107.                 if (lstrcmp(szSymBuf, "ALL") == 0)
  108.                         {
  109.                         wSelStart = 0;
  110.                         wSelEnd   = INT_MAX;
  111.                         }
  112.                 else if (lstrcmp(szSymBuf, "START") == 0)
  113.                         {
  114.                         wSelStart = 0;
  115.                         wSelEnd   = 0;
  116.                         }
  117.                 else       /* default == END */
  118.                         {
  119.                         wSelStart = (WORD)cbLen;
  120.                         wSelEnd   = (WORD)cbLen;
  121.                         }
  122.  
  123.                 return(fTrue);
  124.  
  125.         case STF_REINITDIALOG:
  126.                 return(fTrue);
  127.  
  128.         case WM_COMMAND:
  129.                 switch (wParam)
  130.                         {
  131.                 case IDC_H:
  132.                         HdlgShowHelp();
  133.                         return(fTrue);
  134.  
  135.                 case IDC_B1:
  136.                 case IDC_B2:
  137.                 case IDC_B3:
  138.                 case IDC_B4:
  139.                         CheckRadioButton(hdlg, IDC_B1, IDC_B4, wParam);
  140.                         if (HIWORD(lParam) != BN_DOUBLECLICKED)
  141.                                 break;
  142.                         wParam = IDC_C;
  143.  
  144.                 case Modem_Init:
  145.                         if (HIWORD(lParam) == EN_SETFOCUS)
  146.                                 SendDlgItemMessage(hdlg, Modem_Init, EM_SETSEL, 0,
  147.                                                 MAKELONG(wSelStart, wSelEnd));
  148.                         else if (HIWORD(lParam) == EN_KILLFOCUS)
  149.                                 {
  150.                                 LONG  l = SendDlgItemMessage(hdlg, Modem_Init, EM_GETSEL, 0, 0L);
  151.  
  152.                                 wSelStart = LOWORD(l);
  153.                                 wSelEnd   = HIWORD(l);
  154.                                 }
  155.                         break;
  156.  
  157.                 case Modem_Dial:
  158.                         if (HIWORD(lParam) == EN_SETFOCUS)
  159.                                 SendDlgItemMessage(hdlg, Modem_Dial, EM_SETSEL, 0,
  160.                                                 MAKELONG(wSelStart, wSelEnd));
  161.                         else if (HIWORD(lParam) == EN_KILLFOCUS)
  162.                                 {
  163.                                 LONG  l = SendDlgItemMessage(hdlg, Modem_Dial, EM_GETSEL, 0, 0L);
  164.  
  165.                                 wSelStart = LOWORD(l);
  166.                                 wSelEnd   = HIWORD(l);
  167.                                 }
  168.                         break;
  169.  
  170.                 case IDC_B:
  171.                 case IDC_C:
  172.                 case IDC_X:
  173.                 case IDCANCEL:
  174.                         if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  175.                                 {
  176.                                 DestroyWindow(GetParent(hdlg));
  177.                                 return(fTrue);
  178.                                 }
  179.  
  180.                         iButtonChecked = 0;
  181.                         for (i = 1; i <= 10; i++)
  182.                                 if (SendDlgItemMessage(hdlg, IDC_B0 + i, BM_GETCHECK, 0, 0L))
  183.                                         {
  184.                                         iButtonChecked = i;
  185.                                         break;
  186.                                         }
  187.  
  188.                         IntToAscii((int)iButtonChecked, (LPSTR)rgchNum);
  189.                         if (!FSetSymbolValue("ButtonChecked", rgchNum))
  190.                                 {
  191.                                 DestroyWindow(GetParent(hdlg));
  192.                                 return(fTrue);
  193.                                 }
  194.  
  195.                         SendDlgItemMessage(hdlg, Modem_Init, (WORD)WM_GETTEXT,
  196.                                         cbFullPathMax + 1, (LONG)((LPSTR)rgchText));
  197.                         if (!FSetSymbolValue("Modem_InitOut", rgchText))
  198.                                 {
  199.                                 DestroyWindow(GetParent(hdlg));
  200.                                 return(fTrue);
  201.                                 }
  202.  
  203.                         SendDlgItemMessage(hdlg, Modem_Dial, (WORD)WM_GETTEXT,
  204.                                         cbFullPathMax + 1, (LONG)((LPSTR)rgchText));
  205.                         if (!FSetSymbolValue("Modem_DialOut", rgchText))
  206.                                 {
  207.                                 DestroyWindow(GetParent(hdlg));
  208.                                 return(fTrue);
  209.                                 }
  210.  
  211.                         ReactivateSetupScript();
  212.                         break;
  213.                         }
  214.                 break;
  215.                 }
  216.  
  217.         return(fFalse);
  218. }
  219.  
  220.  
  221.  
  222.