home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / CSETUP.ZIP / DLGPROCS.C < prev    next >
C/C++ Source or Header  |  1993-12-23  |  37KB  |  1,570 lines

  1. /***************************************************************************/
  2. /*********************  Sample Dialog Procedures  **************************/
  3. /***************************************************************************/
  4.  
  5. // COPYRIGHT:
  6. //
  7. //   (C) Copyright Microsoft Corp. 1993.  All rights reserved.
  8. //
  9. //   You have a royalty-free right to use, modify, reproduce and
  10. //   distribute the Sample Files (and/or any modified version) in
  11. //   any way you find useful, provided that you agree that
  12. //   Microsoft has no warranty obligations or liability for any
  13. //   Sample Application Files which are modified.
  14. //
  15.  
  16. #include "cui.h"
  17. #include "dialogs.h"
  18. #include <stdlib.h>
  19. #include <ctype.h>
  20.  
  21.  
  22. #define iszBMax    11
  23. #define INT_MAX    32767     /* maximum (signed) int value */
  24. #define cbSymBuf   1024
  25. #define cbNameMax  52
  26.  
  27.  
  28. LPSTR  _sz = NULL;
  29.  
  30. #define  FSingleByteCharSz(sz)  ((BOOL)(((_sz = (sz)) != NULL) \
  31.                                     && AnsiNext((LPSTR)(_sz)) == _sz + 1))
  32.  
  33. int   FAR PASCAL LibMain(HANDLE, WORD, WORD, LPSTR);
  34. int   FAR PASCAL WEP (int);
  35. LPSTR FAR PASCAL SzLastChar(LPSTR);
  36. LPSTR FAR PASCAL SzDlgEvent(WORD);
  37. int   FAR PASCAL AsciiToInt(LPSTR);
  38. LPSTR FAR PASCAL IntToAscii(int, LPSTR);
  39.  
  40.  
  41.  
  42. /*
  43. **    Purpose:
  44. **        CheckBox Dialog procedure for templates with one to ten checkbox
  45. **        controls.
  46. **
  47. **    Controls Recognized:
  48. **        Checkbox   - IDC_B1 to IDC_B10 (sequential)
  49. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  50. **
  51. **    Initialization Symbols:
  52. **        "CheckItemsIn" - list of "ON" and "OFF" string items for setting
  53. **            the intial state of the checkbox controls, evaluated in
  54. **            sequence ("ON" for checked, "OFF" for unchecked).  If there
  55. **            are more controls than items, extra controls are left unchecked.
  56. **            If there are fewer items than controls, extra items are ignored.
  57. **        "OptionsGreyed" - list of (one-based) indexes of checkboxes to be
  58. **            initialized as disabled.  Indexes not in the list will be
  59. **            left enabled.
  60. **
  61. **    Termination Symbols:
  62. **        "CheckItemsOut" - list of same format as "CheckItemsIn" representing
  63. **            state of checkbox controls upon return.
  64. **        "DLGEVENT" - one of the following, according to control event:
  65. **                event     value
  66. **                -------   -------
  67. **                IDC_B     "BACK"
  68. **                IDC_C     "CONTINUE"
  69. **                IDC_X     "EXIT"
  70. **                IDCANCEL  "CANCEL"
  71. **
  72. **    Note:
  73. **        Pushbutton IDC_H will open the related Help dialog, if any.
  74. **
  75. *****************************************************************************/
  76. BOOL FAR PASCAL FCheckDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  77. {
  78.     WORD idc, cb, i, cItems;
  79.     char szSymBuf[cbSymBuf];
  80.  
  81.     switch (wMsg)
  82.         {
  83.     case WM_INITDIALOG:
  84.         cItems = UsGetListLength("CheckItemsIn");
  85.         idc = IDC_B1;
  86.         for (i = 1; i <= cItems; ++i)
  87.             {
  88.             WORD wCheck = 0;
  89.  
  90.             cb = CbGetListItem("CheckItemsIn", i, szSymBuf, cbSymBuf);
  91.             Assert(cb < cbSymBuf);
  92.             if (lstrcmp(szSymBuf, "ON") == 0)
  93.                 wCheck = 1;
  94.             CheckDlgButton(hdlg, idc++, wCheck);
  95.             }
  96.  
  97.         cItems = UsGetListLength("OptionsGreyed");
  98.         idc = IDC_B1;
  99.         for (i = 1; i <= cItems; ++i)
  100.             {
  101.             int iOpt;
  102.  
  103.             cb = CbGetListItem("OptionsGreyed", i, szSymBuf, cbSymBuf);
  104.             Assert(cb < cbSymBuf);
  105.             iOpt  = AsciiToInt((LPSTR)szSymBuf);
  106.             if (iOpt > 0
  107.                     && iOpt <= 10)
  108.                 EnableWindow(GetDlgItem(hdlg, IDC_B0 + iOpt), 0);
  109.             else if (*szSymBuf != '\0')
  110.                 Assert(fFalse);
  111.             }
  112.         return(fTrue);
  113.  
  114.     case STF_REINITDIALOG:
  115.     case STF_ACTIVATEAPP:
  116.         return(fTrue);
  117.  
  118.     case WM_COMMAND:
  119.         switch (wParam)
  120.             {
  121.         case IDC_B1:
  122.         case IDC_B2:
  123.         case IDC_B3:
  124.         case IDC_B4:
  125.         case IDC_B5:
  126.         case IDC_B6:
  127.         case IDC_B7:
  128.         case IDC_B8:
  129.         case IDC_B9:
  130.         case IDC_B10:
  131.             CheckDlgButton(hdlg, wParam,
  132.                     (WORD)!IsDlgButtonChecked(hdlg, wParam));
  133.             break;
  134.  
  135.         case IDC_H:
  136.             HdlgShowHelp();
  137.             return(fTrue);
  138.  
  139.         case IDC_B:
  140.         case IDC_C:
  141.         case IDC_X:
  142.         case IDCANCEL:
  143.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  144.                 {
  145.                 DestroyWindow(GetParent(hdlg));
  146.                 return(fTrue);
  147.                 }
  148.  
  149.             FRemoveSymbol("CheckItemsOut");
  150.             for (idc = IDC_B1; GetDlgItem(hdlg, idc); idc++)
  151.                 if (!FAddListItem("CheckItemsOut",
  152.                         IsDlgButtonChecked(hdlg, idc) ? "ON" : "OFF"))
  153.                     {
  154.                     DestroyWindow(GetParent(hdlg));
  155.                     return(fFalse);
  156.                     }
  157.             Assert((unsigned)(idc-IDC_B1+1) <= iszBMax);
  158.  
  159.             ReactivateSetupScript();
  160.             break;
  161.             }
  162.         break;
  163.         }
  164.  
  165.     return(fFalse);
  166. }
  167.  
  168.  
  169.  
  170. /*
  171. **    Purpose:
  172. **        Custom Install Dialog procedure for templates with one to ten custom
  173. **        options each consisting of at least one checkbox with an optional
  174. **        sub-option pushbutton or status string.  The dialog also supports
  175. **        an install path set button, display of the current install path, and
  176. **        display of the current disk space status.
  177. **
  178. **    Controls Recognized:
  179. **        Checkbox   - IDC_B1 to IDC_B10
  180. **            with optionaly assocated buttons or text:
  181. **            Pushbutton - IDC_SP1 to IDC_SP10
  182. **            Text       - IDC_STATUS1 to IDC_STATUS10
  183. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_P, IDC_X
  184. **        Text       - IDC_TEXT1 through IDC_TEXT7
  185. **
  186. **    Initialization Symbols:
  187. **        "CheckItemsState" - list of "ON" and "OFF" string items for setting
  188. **            the intial state of the checkbox controls, evaluated in
  189. **            sequence ("ON" for checked, "OFF" for unchecked).  If there
  190. **            are more controls than items, extra controls are left unchecked.
  191. **            If there are fewer items than controls, extra items are ignored.
  192. **        "StatusItemsText" - list of strings to initialize status text items
  193. **            associated with checkboxes.
  194. **        "DriveStatusText" - list of seven strings to initialize drive status
  195. **            text items (IDC_TEXT1-7) in the following sequence:
  196. **                dst_drive, dst_space_need, dst_space_free,
  197. **                win_drive, win_space_need, win_space_free,
  198. **                dst_path
  199. **            If any of the "win_" items is an empty string, its label
  200. **            text will be made non-visible.
  201. **
  202. **    Termination Symbols:
  203. **        "CheckItemsState" - state of checkbox items (same format as above).
  204. **        "DLGEVENT" - one of the following, depending on event:
  205. **                event                value
  206. **                ----------           ----------
  207. **                IDC_B                "BACK"
  208. **                IDC_C                "CONTINUE"
  209. **                IDC_P                "PATH"
  210. **                IDC_X                "EXIT"
  211. **                IDC_B1  to IDC_B10   "CHK1" to "CHK10"
  212. **                IDC_SP1 to IDC_SP10  "BTN1" to "BTN10"
  213. **                IDCANCEL             "CANCEL"
  214. **                STF_ACTIVATEAPP      "REACTIVATE"
  215. **
  216. **    Note:
  217. **        Pushbutton IDC_H will open the related Help dialog, if any.
  218. **
  219. *****************************************************************************/
  220. BOOL FAR PASCAL FCustInstDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  221. {
  222.     char  rgchChk[10];
  223.     char  rgchBtn[10];
  224.     WORD  idc;
  225.     WORD  cItems;
  226.     WORD  i, cb;
  227.     char  szSymBuf[cbSymBuf];
  228.     LPSTR szEvent;
  229.  
  230.     switch (wMsg)
  231.         {
  232.     case STF_ACTIVATEAPP:
  233.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  234.             {
  235.             DestroyWindow(GetParent(hdlg));
  236.             return(fTrue);
  237.             }
  238.         ReactivateSetupScript();
  239.         return(fTrue);
  240.  
  241.     case STF_REINITDIALOG:
  242.     case WM_INITDIALOG:
  243.         cItems = UsGetListLength("CheckItemsState");
  244.         idc = IDC_B1;
  245.         for (i = 1; i <= cItems; ++i)
  246.             {
  247.             WORD wCheck = 0;
  248.  
  249.             cb = CbGetListItem("CheckItemsState", i, szSymBuf, cbSymBuf);
  250.             Assert(cb < cbSymBuf);
  251.             if (lstrcmp(szSymBuf, "ON") == 0)
  252.                 wCheck = 1;
  253.             CheckDlgButton(hdlg, idc++, wCheck);
  254.             }
  255.  
  256.         cItems = UsGetListLength("StatusItemsText");
  257.         idc = IDC_STATUS1;
  258.         for (i = 1; i <= cItems; ++i)
  259.             {
  260.             WORD wCheck = 0;
  261.  
  262.             cb = CbGetListItem("StatusItemsText", i, szSymBuf, cbSymBuf);
  263.             Assert(cb < cbSymBuf);
  264.             SetDlgItemText(hdlg, idc++, szSymBuf);
  265.             }
  266.  
  267.         cItems = UsGetListLength("DriveStatusText");
  268.         idc = IDC_TEXT1;
  269.         for (i = 1; i <= cItems; ++i)
  270.             {
  271.             WORD wCheck = 0;
  272.  
  273.             cb = CbGetListItem("DriveStatusText", i, szSymBuf, cbSymBuf);
  274.             Assert(cb < cbSymBuf);
  275.             SetDlgItemText(hdlg, idc++, szSymBuf);
  276.             if (i >= 4
  277.                     && i <= 6)
  278.                 {
  279.                 if (*szSymBuf == '\0')
  280.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_HIDE);
  281.                 else
  282.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_SHOWNOACTIVATE);
  283.                 }
  284.             }
  285.  
  286.         return(fTrue);
  287.  
  288.     case WM_COMMAND:
  289.         switch(wParam)
  290.             {
  291.         default:
  292.             szEvent = (LPSTR)NULL;
  293.             break;
  294.  
  295.         case IDC_B1:
  296.         case IDC_B2:
  297.         case IDC_B3:
  298.         case IDC_B4:
  299.         case IDC_B5:
  300.         case IDC_B6:
  301.         case IDC_B7:
  302.         case IDC_B8:
  303.         case IDC_B9:
  304.         case IDC_B10:
  305.             lstrcpy((LPSTR)rgchChk, "CHK");
  306.             IntToAscii((int)(wParam-IDC_B1+1), (LPSTR)(&rgchChk[3]));
  307.             szEvent = (LPSTR)rgchChk;
  308.             break;
  309.  
  310.         case IDC_SP1:
  311.         case IDC_SP2:
  312.         case IDC_SP3:
  313.         case IDC_SP4:
  314.         case IDC_SP5:
  315.         case IDC_SP6:
  316.         case IDC_SP7:
  317.         case IDC_SP8:
  318.         case IDC_SP9:
  319.         case IDC_SP10:
  320.             lstrcpy((LPSTR)rgchBtn, "BTN");
  321.             IntToAscii((int)(wParam-IDC_SP1+1), (LPSTR)(&rgchBtn[3]));
  322.             szEvent = (LPSTR)rgchBtn;
  323.             break;
  324.  
  325.         case IDOK:
  326.             wParam = IDC_C;
  327.         case IDC_B:
  328.         case IDC_C:
  329.         case IDC_X:
  330.         case IDCANCEL:
  331.             szEvent = SzDlgEvent(wParam);
  332.             Assert(szEvent != NULL);
  333.             break;
  334.  
  335.         case IDC_P:
  336.             szEvent = "PATH";
  337.             break;
  338.  
  339.         case IDC_H:
  340.             HdlgShowHelp();
  341.             return(fTrue);
  342.  
  343.             }
  344.  
  345.         if (szEvent == (LPSTR)NULL)
  346.             break;
  347.  
  348.         FRemoveSymbol("CheckItemsState");
  349.         for (idc = IDC_B1; GetDlgItem(hdlg, idc); idc++)
  350.             if (!FAddListItem("CheckItemsState",
  351.                     IsDlgButtonChecked(hdlg, idc) ? "ON" : "OFF"))
  352.                 {
  353.                 DestroyWindow(GetParent(hdlg));
  354.                 return(fFalse);
  355.                 }
  356.         Assert((unsigned)(idc-IDC_B1+1) <= iszBMax);
  357.  
  358.         if (szEvent != (LPSTR)NULL)
  359.             if (!FSetSymbolValue("DLGEVENT", szEvent))
  360.                 {
  361.                 DestroyWindow(GetParent(hdlg));
  362.                 return(fTrue);
  363.                 }
  364.  
  365.         ReactivateSetupScript();
  366.         break;
  367.         }
  368.  
  369.     return(fFalse);
  370. }
  371.  
  372.  
  373.  
  374. /*
  375. **    Purpose:
  376. **        Edit Dialog procedure for templates with one Edit control.
  377. **        (Limits the input string length to cbFullPathMax characters.)
  378. **
  379. **    Controls Recognized:
  380. **        Edit       - IDC_EDIT
  381. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  382. **
  383. **    Initialization Symbols:
  384. **        "EditTextIn" - initial text for IDC_EDIT edit control.
  385. **        "EditFocus"  - position of intial focus for text string:
  386. **                "END" (default), "ALL", or "START"
  387. **
  388. **    Termination Symbols:
  389. **        "EditTextOut" - text in the IDC_EDIT edit control upon termination.
  390. **        "DLGEVENT"    - one of the following, depending on event:
  391. **                event                value
  392. **                ----------           ----------
  393. **                IDC_B                "BACK"
  394. **                IDC_C                "CONTINUE"
  395. **                IDC_X                "EXIT"
  396. **                IDCANCEL             "CANCEL"
  397. **                STF_ACTIVATEAPP      "REACTIVATE"
  398. **
  399. **    Note:
  400. **        Pushbutton IDC_H will open the related Help dialog, if any.
  401. **
  402. *****************************************************************************/
  403. BOOL FAR PASCAL FEditDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  404. {
  405.     static WORD wSelStart = 0;
  406.     static WORD wSelEnd   = 0;
  407.     char  rgchText[cbFullPathMax + 1];
  408.     WORD  cbLen;
  409.     WORD  cb;
  410.     char  szSymBuf[cbFullPathMax + 1];
  411.  
  412.     switch (wMsg)
  413.         {
  414.     case STF_ACTIVATEAPP:
  415.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  416.             {
  417.             DestroyWindow(GetParent(hdlg));
  418.             return(fTrue);
  419.             }
  420.         ReactivateSetupScript();
  421.         return(fTrue);
  422.  
  423.     case WM_INITDIALOG:
  424.         cb = CbGetSymbolValue("EditTextIn", szSymBuf, cbFullPathMax + 1);
  425.         Assert(cb < cbFullPathMax + 1);
  426.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_LIMITTEXT, cbFullPathMax, 0L);
  427.         SetDlgItemText(hdlg, IDC_EDIT, (LPSTR)szSymBuf);
  428.  
  429.         cbLen = lstrlen(szSymBuf);
  430.         cb = CbGetSymbolValue("EditFocus", szSymBuf, cbFullPathMax + 1);
  431.         Assert(cb < cbFullPathMax + 1);
  432.  
  433.         if (lstrcmp(szSymBuf, "ALL") == 0)
  434.             {
  435.             wSelStart = 0;
  436.             wSelEnd   = INT_MAX;
  437.             }
  438.         else if (lstrcmp(szSymBuf, "START") == 0)
  439.             {
  440.             wSelStart = 0;
  441.             wSelEnd   = 0;
  442.             }
  443.         else       /* default == END */
  444.             {
  445.             wSelStart = (WORD)cbLen;
  446.             wSelEnd   = (WORD)cbLen;
  447.             }
  448.         return(fTrue);
  449.  
  450.     case STF_REINITDIALOG:
  451.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0, MAKELONG(256, 256));
  452.         SetFocus(GetDlgItem(hdlg, IDC_EDIT));
  453.         return(fTrue);
  454.  
  455.     case WM_COMMAND:
  456.         switch(wParam)
  457.             {
  458.         case IDC_EDIT:
  459.             if (HIWORD(lParam) == EN_SETFOCUS)
  460.                 SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0,
  461.                         MAKELONG(wSelStart, wSelEnd));
  462.             else if (HIWORD(lParam) == EN_KILLFOCUS)
  463.                 {
  464.                 LONG  l = SendDlgItemMessage(hdlg, IDC_EDIT, EM_GETSEL, 0, 0L);
  465.  
  466.                 wSelStart = LOWORD(l);
  467.                 wSelEnd   = HIWORD(l);
  468.                 }
  469.             break;
  470.  
  471.         case IDC_H:
  472.             HdlgShowHelp();
  473.             return(fTrue);
  474.  
  475.         case IDC_B:
  476.         case IDC_C:
  477.         case IDC_X:
  478.         case IDCANCEL:
  479.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  480.                 {
  481.                 DestroyWindow(GetParent(hdlg));
  482.                 return(fTrue);
  483.                 }
  484.             SendDlgItemMessage(hdlg, IDC_EDIT, (WORD)WM_GETTEXT,
  485.                     cbFullPathMax + 1, (LONG)((LPSTR)rgchText));
  486.             if (!FSetSymbolValue("EditTextOut", rgchText))
  487.                 {
  488.                 DestroyWindow(GetParent(hdlg));
  489.                 return(fTrue);
  490.                 }
  491.             ReactivateSetupScript();
  492.             break;
  493.             }
  494.         break;
  495.         }
  496.  
  497.     return(fFalse);
  498. }
  499.  
  500.  
  501.  
  502. /*
  503. **    Purpose:
  504. **        Help Dialog procedure.
  505. **
  506. **    Controls Recognized:
  507. **        Pushbutton - IDC_X.
  508. **
  509. **    Initialization Symbols:
  510. **        none.
  511. **
  512. **    Termination Symbols:
  513. **        none. (Handles IDC_X and IDCANCEL events by calling FCloseHelp.)
  514. **
  515. **    Note:
  516. **        This dialog proc is for Help dialogs ONLY (szHelpProc$ parameter
  517. **        of UIStartDlg) and CANNOT be used as the szDlgProc$ parameter
  518. **        of the UIStartDlg MSSetup script function.
  519. **
  520. *****************************************************************************/
  521. BOOL FAR PASCAL FHelpDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  522. {
  523.     switch (wMsg)
  524.         {
  525.     case WM_INITDIALOG:
  526.         return(fTrue);
  527.  
  528.     case STF_REINITDIALOG:
  529.         return(fTrue);
  530.  
  531.     case STF_ACTIVATEAPP:
  532.         /* Help dlg should not be on the dlg stack
  533.         ** and should never get this message.
  534.         */
  535.         Assert(fFalse);
  536.         return(fTrue);
  537.  
  538.     case WM_COMMAND:
  539.         if (wParam != IDC_X
  540.             && wParam != IDCANCEL)
  541.             break;
  542.         FCloseHelp();
  543.         return(fTrue);
  544.  
  545.         }
  546.     return(fFalse);
  547. }
  548.  
  549.  
  550.  
  551. /*
  552. **    Purpose:
  553. **        Information Dialog procedure.
  554. **
  555. **    Controls Recognized:
  556. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  557. **
  558. **    Initialization Symbols:
  559. **        none.
  560. **
  561. **    Termination Symbols:
  562. **        "DLGEVENT" - one of the following, according to control event:
  563. **                event     value
  564. **                -------   -------
  565. **                IDC_B     "BACK"
  566. **                IDC_C     "CONTINUE"
  567. **                IDC_X     "EXIT"
  568. **                IDCANCEL  "CANCEL"
  569. **
  570. **    Note:
  571. **        Pushbutton IDC_H will open the related Help dialog, if any.
  572. **
  573. *****************************************************************************/
  574. BOOL FAR PASCAL FInfoDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  575. {
  576.     switch (wMsg)
  577.         {
  578.     case WM_INITDIALOG:
  579.         return(fTrue);
  580.  
  581.     case STF_REINITDIALOG:
  582.     case STF_ACTIVATEAPP:
  583.         return(fTrue);
  584.  
  585.     case WM_COMMAND:
  586.         switch (wParam)
  587.             {
  588.         case IDC_H:
  589.             HdlgShowHelp();
  590.             return(fTrue);
  591.  
  592.         case IDC_B:
  593.         case IDC_C:
  594.         case IDC_X:
  595.         case IDCANCEL:
  596.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  597.                 {
  598.                 DestroyWindow(GetParent(hdlg));
  599.                 return(fTrue);
  600.                 }
  601.             ReactivateSetupScript();
  602.             break;
  603.             }
  604.         break;
  605.         }
  606.  
  607.     return(fFalse);
  608. }
  609.  
  610.  
  611.  
  612. /*
  613. **    Purpose:
  614. **        Information Dialog procedure, without "Exit" button.
  615. **
  616. **    Controls Recognized:
  617. **        Pushbutton - IDC_B, IDC_C, IDC_H
  618. **
  619. **    Initialization Symbols:
  620. **        none.
  621. **
  622. **    Termination Symbols:
  623. **        "DLGEVENT" - one of the following, depending on event:
  624. **                event                value
  625. **                ----------           ----------
  626. **                IDC_B                "BACK"
  627. **                IDC_C                "CONTINUE"
  628. **                IDCANCEL             "CANCEL"
  629. **                STF_ACTIVATEAPP      "REACTIVATE"
  630. **
  631. **    Note:
  632. **        Pushbutton IDC_H will open the related Help dialog, if any.
  633. **
  634. *****************************************************************************/
  635. BOOL FAR PASCAL FInfo0DlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  636. {
  637.     switch (wMsg)
  638.         {
  639.     case WM_INITDIALOG:
  640.         return(fTrue);
  641.  
  642.     case STF_REINITDIALOG:
  643.         return(fTrue);
  644.  
  645.     case STF_ACTIVATEAPP:
  646.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  647.             {
  648.             DestroyWindow(GetParent(hdlg));
  649.             return(fTrue);
  650.             }
  651.         ReactivateSetupScript();
  652.         return(fTrue);
  653.  
  654.     case WM_COMMAND:
  655.         switch (wParam)
  656.             {
  657.         case IDC_H:
  658.             HdlgShowHelp();
  659.             return(fTrue);
  660.  
  661.         case IDC_B:
  662.         case IDC_C:
  663.         case IDCANCEL:
  664.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  665.                 {
  666.                 DestroyWindow(GetParent(hdlg));
  667.                 return(fTrue);
  668.                 }
  669.             ReactivateSetupScript();
  670.             break;
  671.             }
  672.         break;
  673.         }
  674.  
  675.     return(fFalse);
  676. }
  677.  
  678.  
  679.  
  680. /*
  681. **    Purpose:
  682. **        Single Choice Listbox Dialog procedure for templates with exactly one
  683. **        listbox control.
  684. **
  685. **    Controls Recognized:
  686. **        Listbox    - IDC_LIST1
  687. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  688. **
  689. **    Initialization Symbols:
  690. **        "ListItemsIn"  - list of strings to put in the listbox.
  691. **        "ListItemsOut" - simple string (not a list) representing an
  692. **            initial selection in "ListItemsIn".
  693. **
  694. **    Termination Symbols:
  695. **        "ListItemsOut" - selected list item string.
  696. **        "DLGEVENT"     - one of the following, according to control event:
  697. **                event     value
  698. **                -------   -------
  699. **                IDC_B     "BACK"
  700. **                IDC_C     "CONTINUE"
  701. **                IDC_X     "EXIT"
  702. **                IDCANCEL  "CANCEL"
  703. **
  704. **    Note:
  705. **        Pushbutton IDC_H will open the related Help dialog, if any.
  706. **
  707. *****************************************************************************/
  708. BOOL FAR PASCAL FListDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  709. {
  710.     char szListIn[cbSymBuf];
  711.     char szListOut[cbSymBuf];
  712.     WORD iItem;
  713.     WORD cb, i;
  714.     WORD cItems;
  715.  
  716.     switch (wMsg)
  717.         {
  718.     case WM_INITDIALOG:
  719.         cItems = UsGetListLength("ListItemsIn");
  720.         for (i = 1; i <= cItems; ++i)
  721.             {
  722.             cb = CbGetListItem("ListItemsIn", i, szListIn, cbSymBuf);
  723.             Assert(cb < cbSymBuf);
  724.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_ADDSTRING, 0,
  725.                     (LONG)(LPSTR)szListIn);
  726.             }
  727.  
  728.         cb = CbGetSymbolValue("ListItemsOut", szListOut, cbSymBuf);
  729.         Assert(cb < cbSymBuf);
  730.         if (cb == 0)
  731.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETCURSEL, (WORD)-1, 0L);
  732.         else
  733.             {
  734.             for (i = 1, iItem = 0; i <= cItems; ++i, ++iItem)
  735.                 {
  736.                 cb = CbGetListItem("ListItemsIn", i, szListIn, cbSymBuf);
  737.                 Assert(cb < cbSymBuf);
  738.                 if (lstrcmp(szListOut, szListIn) == 0)
  739.                     {
  740.                     SendDlgItemMessage(hdlg,IDC_LIST1,LB_SETCURSEL,iItem,0L);
  741.                     break;
  742.                     }
  743.                 }
  744.             }
  745.  
  746.         /* Note: Depends on number of lines in list box.
  747.         */
  748.         if (iItem < 4)
  749.             iItem = 0;
  750.         SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETTOPINDEX, iItem, 0L);
  751.  
  752.         return(fTrue);
  753.  
  754.     case STF_REINITDIALOG:
  755.     case STF_ACTIVATEAPP:
  756.         return(fTrue);
  757.  
  758.     case WM_COMMAND:
  759.         switch(wParam)
  760.             {
  761.         case IDC_H:
  762.             HdlgShowHelp();
  763.             return(fTrue);
  764.  
  765.         case IDC_LIST1:
  766.             if (HIWORD(lParam) != LBN_DBLCLK)
  767.                 break;
  768.             wParam = IDC_C;
  769.         case IDC_B:
  770.         case IDC_C:
  771.         case IDC_X:
  772.         case IDCANCEL:
  773.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  774.                 {
  775.                 DestroyWindow(GetParent(hdlg));
  776.                 return(fTrue);
  777.                 }
  778.  
  779.             if ((iItem = (WORD)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCURSEL,
  780.                         0, 0L)) == LB_ERR
  781.                     || (cb = (WORD)SendDlgItemMessage(hdlg, IDC_LIST1,
  782.                             LB_GETTEXTLEN, iItem, 0L)) == LB_ERR)
  783.                 *szListOut = '\0';
  784.             else
  785.                 {
  786.                 Assert(cb <= cbSymBuf);
  787.                 SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETTEXT, iItem,
  788.                         (LONG)(LPSTR)szListOut);
  789.                 }
  790.             if (!FSetSymbolValue("ListItemsOut", szListOut))
  791.                 {
  792.                 DestroyWindow(GetParent(hdlg));
  793.                 return(fTrue);
  794.                 }
  795.  
  796.             ReactivateSetupScript();
  797.             break;
  798.             }
  799.         break;
  800.  
  801.         }
  802.  
  803.     return(fFalse);
  804. }
  805.  
  806.  
  807.  
  808. /*
  809. **    Purpose:
  810. **        Modeless Dialog procedure.
  811. **
  812. **    Controls Recognized:
  813. **        none.
  814. **
  815. **    Initialization Symbols:
  816. **        none.
  817. **
  818. **    Termination Symbols:
  819. **        none.
  820. **
  821. **    Note:
  822. **        This dialog procedure is REQUIRED with use of any Billboard
  823. **        MSSetup script functions.
  824. **
  825. *****************************************************************************/
  826. BOOL FAR PASCAL FModelessDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  827. {
  828.     switch (wMsg)
  829.         {
  830.     case WM_INITDIALOG:
  831.         ReactivateSetupScript();
  832.         return(fTrue);
  833.  
  834.     case STF_REINITDIALOG:
  835.     case STF_ACTIVATEAPP:
  836.         return(fTrue);
  837.  
  838.     case WM_CLOSE:
  839.     case WM_COMMAND:
  840.         Assert(fFalse);
  841.         break;
  842.         }
  843.  
  844.     return(fFalse);
  845. }
  846.  
  847.  
  848.  
  849. /*
  850. **    Purpose:
  851. **        Multiple Choice Listbox Dialog procedure for templates with
  852. **        exactly one listbox control.
  853. **
  854. **    Controls Recognized:
  855. **        Listbox    - IDC_LIST1
  856. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_L, IDC_S, IDC_X
  857. **
  858. **    Initialization Symbols:
  859. **        "ListItemsIn"  - list of strings to put in the listbox.
  860. **        "ListItemsOut" - list of strings representing initial
  861. **            selections in "ListItemsIn".
  862. **
  863. **    Termination Symbols:
  864. **        "ListItemsOut" - list of items selected (if any).
  865. **        "DLGEVENT"     - one of the following, according to control event:
  866. **                event     value
  867. **                -------   -------
  868. **                IDC_B     "BACK"
  869. **                IDC_C     "CONTINUE"
  870. **                IDC_X     "EXIT"
  871. **                IDCANCEL  "CANCEL"
  872. **
  873. **    Note:
  874. **        Pushbutton IDC_H will open the related Help dialog, if any.
  875. **        Pushbuttons IDC_L and IDC_S are for "clear all" and "select all"
  876. **        respectively.
  877. **
  878. *****************************************************************************/
  879. BOOL FAR PASCAL FMultiDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  880. {
  881.     WORD i, j, nCount;
  882.     char szListIn[cbSymBuf];
  883.     char szListOut[cbSymBuf];
  884.     WORD iItem, iItemTop;
  885.     WORD cb;
  886.     WORD cItemsIn, cItemsOut;
  887.  
  888.     switch (wMsg)
  889.         {
  890.     case WM_INITDIALOG:
  891.         cItemsIn = UsGetListLength("ListItemsIn");
  892.         nCount = 0;
  893.         for (i = 1; i <= cItemsIn; ++i)
  894.             {
  895.             cb = CbGetListItem("ListItemsIn", i, szListIn, cbSymBuf);
  896.             Assert(cb < cbSymBuf);
  897.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_ADDSTRING, 0,
  898.                     (LONG)(LPSTR)szListIn);
  899.             nCount++;
  900.             }
  901.         Assert(nCount == (WORD)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCOUNT,
  902.                 0, 0L));
  903.  
  904.         cItemsOut = UsGetListLength("ListItemsOut");
  905.         for (i = 1, iItemTop = 0; i <= cItemsOut; ++i, ++iItemTop)
  906.             {
  907.             cb = CbGetListItem("ListItemsOut", i, szListOut, cbSymBuf);
  908.             Assert(cb < cbSymBuf);
  909.             for (j = 1, iItem = 0; j <= cItemsIn; ++j, ++iItem)
  910.                 {
  911.                 cb = CbGetListItem("ListItemsIn", j, szListIn, cbSymBuf);
  912.                 Assert(cb < cbSymBuf);
  913.                 if (lstrcmp(szListOut, szListIn) == 0)
  914.                     {
  915.                     SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETSEL, 1,
  916.                             MAKELONG(iItem, 0));
  917.                     if (iItemTop == 0
  918.                             || (WORD)iItem < iItemTop)
  919.                         iItemTop = (WORD)iItem;
  920.                     break;
  921.                     }
  922.                 }
  923.             }
  924.  
  925.         /* Note: Depends on number of lines in list box.
  926.         */
  927.         if (iItemTop < 4)
  928.             iItemTop = 0;
  929.         SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETTOPINDEX, iItemTop, 0L);
  930.  
  931.         return(fTrue);
  932.  
  933.     case STF_REINITDIALOG:
  934.     case STF_ACTIVATEAPP:
  935.         return(fTrue);
  936.  
  937.     case WM_COMMAND:
  938.         switch(wParam)
  939.             {
  940.         case IDC_S:
  941.         case IDC_L:
  942.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETSEL, (wParam == IDC_S),
  943.                     -1L);
  944.             break;
  945.  
  946.         case IDC_H:
  947.             HdlgShowHelp();
  948.             return(fTrue);
  949.  
  950.         case IDC_B:
  951.         case IDC_C:
  952.         case IDC_X:
  953.         case IDCANCEL:
  954.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  955.                 {
  956.                 DestroyWindow(GetParent(hdlg));
  957.                 return(fTrue);
  958.                 }
  959.  
  960.             /* Note: Could be faster to use LB_GETSELITEMS here.
  961.             */
  962.             nCount = (WORD)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCOUNT, 0,
  963.                     0L);
  964.  
  965.             FRemoveSymbol("ListItemsOut");
  966.             for (i = 0; i < nCount; i++)
  967.                 {
  968.                 if (SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETSEL, (WORD)i, 0L))
  969.                     {
  970.                     SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETTEXT, (WORD)i,
  971.                             (LONG)(LPSTR)szListOut);
  972.                     if (!FAddListItem("ListItemsOut", szListOut))
  973.                         {
  974.                         DestroyWindow(GetParent(hdlg));
  975.                         return(fTrue);
  976.                         }
  977.                     }
  978.                 }
  979.  
  980.             ReactivateSetupScript();
  981.             break;
  982.             }
  983.         break;
  984.         }
  985.  
  986.     return(fFalse);
  987. }
  988.  
  989.  
  990.  
  991. /*
  992. **    Purpose:
  993. **        Quit Dialog procedure.
  994. **
  995. **    Controls Recognized:
  996. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  997. **
  998. **    Initialization Symbols:
  999. **        none.
  1000. **
  1001. **    Termination Symbols:
  1002. **        "DLGEVENT" - one of the following, depending on event:
  1003. **                event                value
  1004. **                ----------           ----------
  1005. **                IDC_B                "BACK"
  1006. **                IDC_C                "CONTINUE"
  1007. **                IDC_X                "EXIT"
  1008. **                IDCANCEL             "CANCEL"
  1009. **                STF_ACTIVATEAPP      "REACTIVATE"
  1010. **
  1011. **    Note:
  1012. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1013. **
  1014. *****************************************************************************/
  1015. BOOL FAR PASCAL FQuitDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1016. {
  1017.     switch (wMsg)
  1018.         {
  1019.     case WM_INITDIALOG:
  1020.         return(fTrue);
  1021.  
  1022.     case STF_REINITDIALOG:
  1023.         return(fTrue);
  1024.  
  1025.     case STF_ACTIVATEAPP:
  1026.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  1027.             {
  1028.             DestroyWindow(GetParent(hdlg));
  1029.             return(fTrue);
  1030.             }
  1031.         ReactivateSetupScript();
  1032.         return(fTrue);
  1033.  
  1034.     case WM_COMMAND:
  1035.         switch(wParam)
  1036.             {
  1037.         case IDC_H:
  1038.             HdlgShowHelp();
  1039.             return(fTrue);
  1040.  
  1041.         case IDC_B:
  1042.         case IDC_C:
  1043.         case IDC_X:
  1044.         case IDCANCEL:
  1045.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1046.                 {
  1047.                 DestroyWindow(GetParent(hdlg));
  1048.                 return(fTrue);
  1049.                 }
  1050.  
  1051.             ReactivateSetupScript();
  1052.             break;
  1053.             }
  1054.         break;
  1055.         }
  1056.     return(fFalse);
  1057. }
  1058.  
  1059.  
  1060.  
  1061. /*
  1062. **    Purpose:
  1063. **        Radio Button Group Dialog procedure for templates with one group
  1064. **        of one to ten radio button controls.
  1065. **
  1066. **    Controls Recognized:
  1067. **        Radio      - IDC_B1 to IDC_B10 (sequential)
  1068. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  1069. **
  1070. **    Initialization Symbols:
  1071. **        "RadioDefault" - index (one-based) of radio button to be
  1072. **            initialized as selected (default is "1").
  1073. **        "OptionsGreyed" - list of (one-based) indexes of radio buttons
  1074. **            to be initialized as disabled.  Indexes not in the list will
  1075. **            be left enabled.
  1076. **
  1077. **    Termination Symbols:
  1078. **        "ButtonChecked" - index of currently selected radio button.
  1079. **        "DLGEVENT"      - one of the following, depending on event:
  1080. **                event                value
  1081. **                ----------           ----------
  1082. **                IDC_B                "BACK"
  1083. **                IDC_C                "CONTINUE"
  1084. **                IDC_X                "EXIT"
  1085. **                IDCANCEL             "CANCEL"
  1086. **                STF_ACTIVATEAPP      "REACTIVATE"
  1087. **
  1088. **    Note:
  1089. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1090. **
  1091. *****************************************************************************/
  1092. BOOL FAR PASCAL FRadioDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1093. {
  1094.     char rgchNum[10];
  1095.     int  iButtonChecked;
  1096.     char szSymBuf[cbSymBuf];
  1097.     WORD i, cb, cItems, idc;
  1098.  
  1099.     switch (wMsg)
  1100.         {
  1101.     case STF_ACTIVATEAPP:
  1102.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  1103.             {
  1104.             DestroyWindow(GetParent(hdlg));
  1105.             return(fTrue);
  1106.             }
  1107.         ReactivateSetupScript();
  1108.         return(fTrue);
  1109.  
  1110.     case WM_INITDIALOG:
  1111.         cb = CbGetSymbolValue("RadioDefault", szSymBuf, cbSymBuf);
  1112.         Assert(cb < cbSymBuf);
  1113.         if (*szSymBuf != '\0')
  1114.             {
  1115.             iButtonChecked = AsciiToInt((LPSTR)szSymBuf);
  1116.             if (iButtonChecked < 1)
  1117.                 iButtonChecked = 0;
  1118.             if (iButtonChecked > 10)
  1119.                 iButtonChecked = 10;
  1120.             }
  1121.         else
  1122.             iButtonChecked = 1;
  1123.  
  1124.         if (iButtonChecked != 0)
  1125.             SendDlgItemMessage(hdlg, IDC_B0 + iButtonChecked, BM_SETCHECK,1,0L);
  1126.  
  1127.         cItems = UsGetListLength("OptionsGreyed");
  1128.         idc = IDC_B1;
  1129.         for (i = 1; i <= cItems; ++i)
  1130.             {
  1131.             int iOpt;
  1132.  
  1133.             cb = CbGetListItem("OptionsGreyed", i, szSymBuf, cbSymBuf);
  1134.             Assert(cb < cbSymBuf);
  1135.             iOpt  = AsciiToInt((LPSTR)szSymBuf);
  1136.             if (iOpt > 0
  1137.                     && iOpt <= 10
  1138.                     && iOpt != iButtonChecked)
  1139.                 EnableWindow(GetDlgItem(hdlg, IDC_B0 + iOpt), 0);
  1140.             else if (*szSymBuf != '\0')
  1141.                 Assert(fFalse);
  1142.             }
  1143.         return(fTrue);
  1144.  
  1145.     case STF_REINITDIALOG:
  1146.         return(fTrue);
  1147.  
  1148.     case WM_COMMAND:
  1149.         switch (wParam)
  1150.             {
  1151.         case IDC_H:
  1152.             HdlgShowHelp();
  1153.             return(fTrue);
  1154.  
  1155.         case IDC_B1:
  1156.         case IDC_B2:
  1157.         case IDC_B3:
  1158.         case IDC_B4:
  1159.         case IDC_B5:
  1160.         case IDC_B6:
  1161.         case IDC_B7:
  1162.         case IDC_B8:
  1163.         case IDC_B9:
  1164.         case IDC_B10:
  1165.             CheckRadioButton(hdlg, IDC_B1, IDC_B10, wParam);
  1166.             if (HIWORD(lParam) != BN_DOUBLECLICKED)
  1167.                 break;
  1168.             wParam = IDC_C;
  1169.         case IDC_B:
  1170.         case IDC_C:
  1171.         case IDC_X:
  1172.         case IDCANCEL:
  1173.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1174.                 {
  1175.                 DestroyWindow(GetParent(hdlg));
  1176.                 return(fTrue);
  1177.                 }
  1178.  
  1179.             iButtonChecked = 0;
  1180.             for (i = 1; i <= 10; i++)
  1181.                 if (SendDlgItemMessage(hdlg, IDC_B0 + i, BM_GETCHECK, 0, 0L))
  1182.                     {
  1183.                     iButtonChecked = i;
  1184.                     break;
  1185.                     }
  1186.  
  1187.             IntToAscii((int)iButtonChecked, (LPSTR)rgchNum);
  1188.             if (!FSetSymbolValue("ButtonChecked", rgchNum))
  1189.                 {
  1190.                 DestroyWindow(GetParent(hdlg));
  1191.                 return(fTrue);
  1192.                 }
  1193.  
  1194.             ReactivateSetupScript();
  1195.             break;
  1196.             }
  1197.         break;
  1198.         }
  1199.  
  1200.     return(fFalse);
  1201. }
  1202.  
  1203.  
  1204.  
  1205. /*
  1206. **    Purpose:
  1207. **        Get Name and Organization Dialog procedure for templates
  1208. **        with two Edit controls.
  1209. **        (Limits the input string length to cbNameMax characters.)
  1210. **
  1211. **    Controls Recognized:
  1212. **        Edit       - IDC_EDIT, IDC_EDIT2
  1213. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  1214. **
  1215. **    Initialization Symbols:
  1216. **        none.
  1217. **
  1218. **    Termination Symbols:
  1219. **        "NameOut" - text in the IDC_EDIT edit control upon termination.
  1220. **        "OrgOut"  - text in the IDC_EDIT2 edit control upon termination.
  1221. **        "DLGEVENT"    - one of the following, depending on event:
  1222. **                event                value
  1223. **                ----------           ----------
  1224. **                IDC_B                "BACK"
  1225. **                IDC_C                "CONTINUE"
  1226. **                IDC_X                "EXIT"
  1227. **                IDCANCEL             "CANCEL"
  1228. **
  1229. **    Note:
  1230. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1231. **
  1232. *****************************************************************************/
  1233. BOOL FAR PASCAL FNameOrgDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1234. {
  1235.     static WORD wSelStart1 = 0;
  1236.     static WORD wSelEnd1   = 0;
  1237.     static WORD wSelStart2 = 0;
  1238.     static WORD wSelEnd2   = 0;
  1239.     char  rgchText[cbNameMax + 1];
  1240.  
  1241.     switch (wMsg)
  1242.         {
  1243.     case WM_INITDIALOG:
  1244.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_LIMITTEXT, cbNameMax, 0L);
  1245.         SetDlgItemText(hdlg, IDC_EDIT, (LPSTR)"");
  1246.  
  1247.         SendDlgItemMessage(hdlg, IDC_EDIT2, EM_LIMITTEXT, cbNameMax, 0L);
  1248.         SetDlgItemText(hdlg, IDC_EDIT2, (LPSTR)"");
  1249.  
  1250.         wSelStart1 = wSelEnd1 = 0;
  1251.         wSelStart2 = wSelEnd2 = 0;
  1252.         return(fTrue);
  1253.  
  1254.     case STF_REINITDIALOG:
  1255.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0, MAKELONG(256, 256));
  1256.         SetFocus(GetDlgItem(hdlg, IDC_EDIT));
  1257.         return(fTrue);
  1258.  
  1259.     case STF_ACTIVATEAPP:
  1260.         return(fTrue);
  1261.  
  1262.     case WM_COMMAND:
  1263.         switch(wParam)
  1264.             {
  1265.         case IDC_EDIT:
  1266.             if (HIWORD(lParam) == EN_SETFOCUS)
  1267.                 SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0,
  1268.                         MAKELONG(wSelStart1, wSelEnd1));
  1269.             else if (HIWORD(lParam) == EN_KILLFOCUS)
  1270.                 {
  1271.                 LONG l = SendDlgItemMessage(hdlg, IDC_EDIT, EM_GETSEL, 0, 0L);
  1272.  
  1273.                 wSelStart1 = LOWORD(l);
  1274.                 wSelEnd1   = HIWORD(l);
  1275.                 }
  1276.             break;
  1277.  
  1278.         case IDC_EDIT2:
  1279.             if (HIWORD(lParam) == EN_SETFOCUS)
  1280.                 SendDlgItemMessage(hdlg, IDC_EDIT2, EM_SETSEL, 0,
  1281.                         MAKELONG(wSelStart2, wSelEnd2));
  1282.             else if (HIWORD(lParam) == EN_KILLFOCUS)
  1283.                 {
  1284.                 LONG l = SendDlgItemMessage(hdlg, IDC_EDIT2, EM_GETSEL, 0, 0L);
  1285.  
  1286.                 wSelStart2 = LOWORD(l);
  1287.                 wSelEnd2   = HIWORD(l);
  1288.                 }
  1289.             break;
  1290.  
  1291.         case IDC_H:
  1292.             HdlgShowHelp();
  1293.             return(fTrue);
  1294.  
  1295.         case IDC_B:
  1296.         case IDC_C:
  1297.         case IDC_X:
  1298.         case IDCANCEL:
  1299.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1300.                 {
  1301.                 DestroyWindow(GetParent(hdlg));
  1302.                 return(fTrue);
  1303.                 }
  1304.  
  1305.             SendDlgItemMessage(hdlg, IDC_EDIT, (WORD)WM_GETTEXT,
  1306.                     cbNameMax + 1, (LONG)((LPSTR)rgchText));
  1307.             if (!FSetSymbolValue("NameOut", rgchText))
  1308.                 {
  1309.                 DestroyWindow(GetParent(hdlg));
  1310.                 return(fTrue);
  1311.                 }
  1312.  
  1313.             SendDlgItemMessage(hdlg, IDC_EDIT2, (WORD)WM_GETTEXT,
  1314.                     cbNameMax + 1, (LONG)((LPSTR)rgchText));
  1315.             if (!FSetSymbolValue("OrgOut", rgchText))
  1316.                 {
  1317.                 DestroyWindow(GetParent(hdlg));
  1318.                 return(fTrue);
  1319.                 }
  1320.  
  1321.             ReactivateSetupScript();
  1322.             break;
  1323.             }
  1324.         break;
  1325.         }
  1326.  
  1327.     return(fFalse);
  1328. }
  1329.  
  1330.  
  1331.  
  1332. /*
  1333. **    Purpose:
  1334. **        Confirm Info Dialog procedure for templates with one to
  1335. **        static text controls.
  1336. **
  1337. **    Controls Recognized:
  1338. **        Text       - IDC_TEXT1 to IDC_TEXT10 (sequential)
  1339. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  1340. **
  1341. **    Initialization Symbols:
  1342. **        "ConfirmTextIn" - list of up to ten string items to initialize
  1343. **            static text items (IDC_TEXT1-10).
  1344. **
  1345. **    Termination Symbols:
  1346. **        "DLGEVENT" - one of the following, depending on event:
  1347. **                event                value
  1348. **                ----------           ----------
  1349. **                IDC_B                "BACK"
  1350. **                IDC_C                "CONTINUE"
  1351. **                IDC_X                "EXIT"
  1352. **                IDCANCEL             "CANCEL"
  1353. **
  1354. **    Note:
  1355. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1356. **
  1357. *****************************************************************************/
  1358. BOOL FAR PASCAL FConfirmDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1359. {
  1360.     WORD  idc;
  1361.     WORD  cItems;
  1362.     WORD  i, cb;
  1363.     char  szSymBuf[cbSymBuf];
  1364.  
  1365.     switch (wMsg)
  1366.         {
  1367.     case WM_INITDIALOG:
  1368.         cItems = UsGetListLength("ConfirmTextIn");
  1369.         idc = IDC_TEXT1;
  1370.         for (i = 1; i <= cItems; ++i)
  1371.             {
  1372.             WORD wCheck = 0;
  1373.  
  1374.             cb = CbGetListItem("ConfirmTextIn", i, szSymBuf, cbSymBuf);
  1375.             Assert(cb < cbSymBuf);
  1376.             SetDlgItemText(hdlg, idc++, szSymBuf);
  1377.             if (i >= 4
  1378.                     && i <= 6)
  1379.                 {
  1380.                 if (*szSymBuf == '\0')
  1381.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_HIDE);
  1382.                 else
  1383.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_SHOWNOACTIVATE);
  1384.                 }
  1385.             }
  1386.         return(fTrue);
  1387.  
  1388.     case STF_REINITDIALOG:
  1389.     case STF_ACTIVATEAPP:
  1390.         return(fTrue);
  1391.  
  1392.     case WM_COMMAND:
  1393.         switch (wParam)
  1394.             {
  1395.         case IDC_H:
  1396.             HdlgShowHelp();
  1397.             return(fTrue);
  1398.  
  1399.         case IDC_B:
  1400.         case IDC_C:
  1401.         case IDC_X:
  1402.         case IDCANCEL:
  1403.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1404.                 {
  1405.                 DestroyWindow(GetParent(hdlg));
  1406.                 return(fTrue);
  1407.                 }
  1408.             ReactivateSetupScript();
  1409.             break;
  1410.             }
  1411.         break;
  1412.         }
  1413.  
  1414.     return(fFalse);
  1415. }
  1416.  
  1417.  
  1418.  
  1419. /*
  1420. **    Purpose:
  1421. **        Initialization routine for DLL.
  1422. **    Arguments:
  1423. **        hInst:       handle to instance of App that required this DLL.
  1424. **        wDataSeg:    number of words in DLL's data segment.
  1425. **        wHeapSize:   number of bytes in DLL's heap.
  1426. **        lpszCmdLine: command line for App that required this DLL.
  1427. **    Returns:
  1428. **        1 always
  1429. *****************************************************************************/
  1430. int FAR PASCAL LibMain(HANDLE hInst, WORD wDataSeg, WORD wHeapSize,
  1431.         LPSTR lpszCmdLine)
  1432. {
  1433.     if (wHeapSize > 0)
  1434.         UnlockData(0);
  1435.  
  1436.     return(1);
  1437. }
  1438.  
  1439.  
  1440.  
  1441. /*
  1442. **    Purpose:
  1443. **        Windows Exit Procedure.
  1444. **    Arguments:
  1445. **        nParam: standard WEP param (ignored).
  1446. **    Returns:
  1447. **        1 always.
  1448. *****************************************************************************/
  1449. int FAR PASCAL WEP (int nParam)
  1450. {
  1451.     return(1);
  1452. }
  1453.  
  1454.  
  1455.  
  1456. /*
  1457. **    Purpose:
  1458. **        Finds the last character in a string.
  1459. **    Arguments:
  1460. **        sz: non-NULL zero terminated string to search.
  1461. **    Returns:
  1462. **        NULL for an empty string.
  1463. **        non-Null string pointer to the last valid character in sz.
  1464. *****************************************************************************/
  1465. LPSTR FAR PASCAL SzLastChar(LPSTR sz)
  1466. {
  1467.     LPSTR szCur  = (LPSTR)NULL;
  1468.     LPSTR szNext = sz;
  1469.  
  1470.     while (*szNext != '\0')
  1471.         szNext = AnsiNext((szCur = szNext));
  1472.  
  1473.     return(szCur);
  1474. }
  1475.  
  1476.  
  1477.  
  1478. /*
  1479. **    Purpose:
  1480. **        Gets the string values for the following WM_COMMAND events:
  1481. **            IDC_B, IDC_C, IDC_X, and IDCANCEL.
  1482. **    Arguments:
  1483. **        wParam: event parameter value
  1484. **    Returns:
  1485. **        Pointer to string value constant, NULL if unknown event.
  1486. *****************************************************************************/
  1487. LPSTR FAR PASCAL SzDlgEvent(WORD wParam)
  1488. {
  1489.     LPSTR szEvent;
  1490.  
  1491.     switch(wParam)
  1492.         {
  1493.     case IDC_B:
  1494.         szEvent = "BACK";
  1495.         break;
  1496.     case IDC_C:
  1497.         szEvent = "CONTINUE";
  1498.         break;
  1499.     case IDC_X:
  1500.         szEvent = "EXIT";
  1501.         break;
  1502.     case IDCANCEL:
  1503.         szEvent = "CANCEL";
  1504.         break;
  1505.     default:
  1506.         szEvent = NULL;
  1507.         break;
  1508.         }
  1509.  
  1510.     return(szEvent);
  1511. }
  1512.  
  1513.  
  1514.  
  1515. /*
  1516. **    Purpose:
  1517. **        Converts an ASCII string representing a positive value
  1518. **        into an integer.
  1519. **    Arguments:
  1520. **        sz: non-NULL zero terminated string to convert.
  1521. **    Returns:
  1522. **        Integer represented by the string.
  1523. *****************************************************************************/
  1524. int FAR PASCAL AsciiToInt(LPSTR sz)
  1525. {
  1526.     int i = 0;
  1527.  
  1528.     while (*sz == ' ' || *sz == '\t')
  1529.         sz++;
  1530.  
  1531.     while (isdigit(*sz))
  1532.         i = (i * 10) + *sz++ - '0';
  1533.  
  1534.     return(i);
  1535. }
  1536.  
  1537.  
  1538.  
  1539. /*
  1540. **    Purpose:
  1541. **        Converts an positive integer (< 100) into a string
  1542. **        representing its value.
  1543. **    Arguments:
  1544. **        i:  integer to convert (positive and < 100).
  1545. **        sz: buffer to hold converted string (at least 3 bytes).
  1546. **    Returns:
  1547. **        sz.
  1548. *****************************************************************************/
  1549. LPSTR FAR PASCAL IntToAscii(int i, LPSTR sz)
  1550. {
  1551.     LPSTR szSav = sz;
  1552.  
  1553.     if (i >= 100
  1554.             || i < 0)
  1555.         Assert(fFalse);
  1556.  
  1557.     if (i >= 10)
  1558.         {
  1559.         *sz++ = (char)('0' + (i / 10));
  1560.         i %= 10;
  1561.         }
  1562.     *sz++ = (char)('0' + i);
  1563.     *sz = '\0';
  1564.  
  1565.     return(szSav);
  1566. }
  1567.  
  1568.  
  1569.  
  1570.