home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / sdk / win32s / setup / bldcui / dlgprocs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-11  |  46.1 KB  |  1,739 lines

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