Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
6.7 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /***************************************************************************/
  4. /****************** Basic Class Dialog Handlers ****************************/
  5. /***************************************************************************/
  6. /*
  7. ** Purpose:
  8. ** CheckBox Dialog procedure for templates with one to ten checkbox
  9. ** controls.
  10. ** Control IDs:
  11. ** The Checkbox controls must have sequential ids starting with IDC_B1
  12. ** and working up to a maximum of IDC_B10.
  13. ** Pushbuttons recognized are IDC_O, IDC_C, IDC_M, IDC_H, IDC_X, and IDC_B.
  14. ** Initialization:
  15. ** The symbol $(CheckItemsIn) is evaluated as a list of elements of
  16. ** either 'ON' or 'OFF'. So examples for a template with four
  17. ** checkbox controls would include {ON, ON, ON, ON},
  18. ** {ON, OFF, ON, OFF} and {OFF, OFF, OFF, OFF}. These elements
  19. ** determine if the initial state of the corresponding checkbox
  20. ** control is checked (ON) or unchecked (OFF). If there are more
  21. ** controls than elements, the extra controls will be initialized
  22. ** as unchecked. If there are more elements than controls, the
  23. ** extra elements are ignored.
  24. ** The symbol $(OptionsGreyed) is evaluated as a list of indexes
  25. ** (one-based) of check boxes to be disabled (greyed). Default is
  26. ** none.
  27. ** Termination:
  28. ** The state of each checkbox is queried and a list with the same format
  29. ** as the initialization list is created and stored in the symbol
  30. ** $(CheckItemsOut).
  31. ** The id of the Pushbutton (eg IDC_C) which caused termination is
  32. ** converted to a string and stored in the symbol $(ButtonPressed).
  33. **
  34. *****************************************************************************/
  35. INT_PTR APIENTRY FGstCheckDlgProc(HWND hdlg,
  36. UINT wMsg,
  37. WPARAM wParam,
  38. LPARAM lParam)
  39. {
  40. CHP rgchNum[10];
  41. WORD idc;
  42. RGSZ rgsz;
  43. PSZ psz;
  44. SZ sz;
  45. Unused(lParam);
  46. switch (wMsg) {
  47. case STF_REINITDIALOG:
  48. return(fTrue);
  49. case WM_INITDIALOG:
  50. AssertDataSeg();
  51. if( wMsg == WM_INITDIALOG ) {
  52. FCenterDialogOnDesktop(hdlg);
  53. }
  54. if ((sz = SzFindSymbolValueInSymTab("CheckItemsIn")) == (SZ)NULL)
  55. {
  56. PreCondition(fFalse, fTrue);
  57. return(fTrue);
  58. }
  59. while ((psz = rgsz = RgszFromSzListValue(sz)) == (RGSZ)NULL)
  60. if (!FHandleOOM(hdlg))
  61. {
  62. DestroyWindow(GetParent(hdlg));
  63. return(fTrue);
  64. }
  65. idc = IDC_B1;
  66. while (*psz != (SZ)NULL)
  67. {
  68. WORD wCheck = 0;
  69. if (CrcStringCompare(*(psz++), "ON") == crcEqual)
  70. wCheck = 1;
  71. CheckDlgButton(hdlg, idc++, wCheck);
  72. }
  73. EvalAssert(FFreeRgsz(rgsz));
  74. if ((sz = SzFindSymbolValueInSymTab("OptionsGreyed")) == (SZ)NULL)
  75. {
  76. PreCondition(fFalse, fTrue);
  77. return(fTrue);
  78. }
  79. while ((psz = rgsz = RgszFromSzListValue(sz)) == (RGSZ)NULL)
  80. if (!FHandleOOM(hdlg))
  81. {
  82. DestroyWindow(GetParent(hdlg));
  83. return(fTrue);
  84. }
  85. while (*psz != (SZ)NULL)
  86. {
  87. SZ sz = *(psz++);
  88. INT i = atoi(sz);
  89. if (i > 0 && i <= 10)
  90. EnableWindow(GetDlgItem(hdlg, IDC_B0 + i), 0);
  91. else if (*sz != '\0')
  92. PreCondition(fFalse, fTrue);
  93. }
  94. EvalAssert(FFreeRgsz(rgsz));
  95. return(fTrue);
  96. case WM_CLOSE:
  97. PostMessage(
  98. hdlg,
  99. WM_COMMAND,
  100. MAKELONG(IDC_X, BN_CLICKED),
  101. 0L
  102. );
  103. return(fTrue);
  104. case WM_COMMAND:
  105. switch (LOWORD(wParam))
  106. {
  107. case IDC_B1:
  108. case IDC_B2:
  109. case IDC_B3:
  110. case IDC_B4:
  111. case IDC_B5:
  112. case IDC_B6:
  113. case IDC_B7:
  114. case IDC_B8:
  115. case IDC_B9:
  116. case IDC_B10:
  117. CheckDlgButton(hdlg, LOWORD(wParam),
  118. (UINT)!IsDlgButtonChecked(hdlg, (UINT)wParam));
  119. break;
  120. case IDCANCEL:
  121. if (LOWORD(wParam) == IDCANCEL) {
  122. if (!GetDlgItem(hdlg, IDC_B) || HIWORD(GetKeyState(VK_CONTROL)) || HIWORD(GetKeyState(VK_SHIFT)) || HIWORD(GetKeyState(VK_MENU)))
  123. {
  124. break;
  125. }
  126. wParam = IDC_B;
  127. }
  128. case IDC_O:
  129. case IDC_C:
  130. case IDC_M:
  131. case IDC_B:
  132. case IDC_X:
  133. case IDC_BTN0:
  134. case IDC_BTN1: case IDC_BTN2: case IDC_BTN3:
  135. case IDC_BTN4: case IDC_BTN5: case IDC_BTN6:
  136. case IDC_BTN7: case IDC_BTN8: case IDC_BTN9:
  137. _itoa((INT)wParam, rgchNum, 10);
  138. while (!FAddSymbolValueToSymTab("ButtonPressed", rgchNum))
  139. if (!FHandleOOM(hdlg))
  140. {
  141. DestroyWindow(GetParent(hdlg));
  142. return(fTrue);
  143. }
  144. while ((psz = rgsz = (RGSZ)SAlloc((CB)(11 * sizeof(SZ)))) ==
  145. (RGSZ)NULL)
  146. if (!FHandleOOM(hdlg))
  147. {
  148. DestroyWindow(GetParent(hdlg));
  149. return(fTrue);
  150. }
  151. for (idc = IDC_B1; GetDlgItem(hdlg, idc); psz++, idc++)
  152. {
  153. BOOL fChecked = IsDlgButtonChecked(hdlg, idc);
  154. while ((*psz = SzDupl(fChecked ? "ON" : "OFF")) == (SZ)NULL)
  155. if (!FHandleOOM(hdlg))
  156. {
  157. DestroyWindow(GetParent(hdlg));
  158. return(fTrue);
  159. }
  160. }
  161. *psz = (SZ)NULL;
  162. while ((sz = SzListValueFromRgsz(rgsz)) == (SZ)NULL)
  163. if (!FHandleOOM(hdlg))
  164. {
  165. DestroyWindow(GetParent(hdlg));
  166. return(fTrue);
  167. }
  168. while (!FAddSymbolValueToSymTab("CheckItemsOut", sz))
  169. if (!FHandleOOM(hdlg))
  170. {
  171. DestroyWindow(GetParent(hdlg));
  172. return(fTrue);
  173. }
  174. SFree(sz);
  175. EvalAssert(FFreeRgsz(rgsz));
  176. PostMessage(GetParent(hdlg), (WORD)STF_UI_EVENT, 0, 0L);
  177. break;
  178. }
  179. break;
  180. case STF_DESTROY_DLG:
  181. PostMessage(GetParent(hdlg), (WORD)STF_CHECK_DLG_DESTROYED, 0, 0L);
  182. DestroyWindow(hdlg);
  183. return(fTrue);
  184. }
  185. return(fFalse);
  186. }