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.

194 lines
4.9 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /***************************************************************************/
  4. /****************** Basic Class Dialog Handlers ****************************/
  5. /***************************************************************************/
  6. /*
  7. ** Purpose:
  8. ** Radio Button Group Dialog procedure for templates with one group
  9. ** of one to ten radio button controls.
  10. ** Control IDs:
  11. ** The Radio button 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 $(RadioDefault) is evaluated as an index (one-based) of
  16. ** the radio button to be set on. Default is 1.
  17. ** The symbol $(OptionsGreyed) is evaluated as a list of indexes
  18. ** (one-based) of radio buttons to be disabled (greyed). Default is
  19. ** none.
  20. ** Termination:
  21. ** The index of the currently selected radio button is stored in the
  22. ** symbol $(ButtonChecked). The id of the Pushbutton (eg IDC_C) which
  23. ** caused termination is converted to a string and stored in the
  24. ** symbol $(ButtonPressed).
  25. **
  26. *****************************************************************************/
  27. INT_PTR APIENTRY FGstRadioDlgProc(HWND hdlg, UINT wMsg, WPARAM wParam,
  28. LPARAM lParam)
  29. {
  30. CHP rgchNum[10];
  31. INT i, iButtonChecked;
  32. static INT iButtonMax;
  33. WORD idc;
  34. SZ sz;
  35. PSZ psz;
  36. RGSZ rgsz;
  37. Unused(lParam);
  38. switch (wMsg)
  39. {
  40. case WM_INITDIALOG:
  41. AssertDataSeg();
  42. if( wMsg == WM_INITDIALOG ) {
  43. FCenterDialogOnDesktop(hdlg);
  44. }
  45. for (i = IDC_B1; i <= IDC_B10 && GetDlgItem(hdlg, i) != (HWND)NULL; i++)
  46. ;
  47. iButtonMax = i - 1;
  48. if ((sz = SzFindSymbolValueInSymTab("RadioDefault")) != (SZ)NULL)
  49. {
  50. iButtonChecked = atoi(sz);
  51. if (iButtonChecked < 1)
  52. iButtonChecked = 0;
  53. if (iButtonChecked > 10)
  54. iButtonChecked = 10;
  55. }
  56. else
  57. iButtonChecked = 1;
  58. if (iButtonChecked != 0)
  59. SendDlgItemMessage(hdlg, IDC_B0 + iButtonChecked, BM_SETCHECK,1,0L);
  60. if ((sz = SzFindSymbolValueInSymTab("OptionsGreyed")) == (SZ)NULL)
  61. {
  62. PreCondition(fFalse, fTrue);
  63. return(fTrue);
  64. }
  65. while ((psz = rgsz = RgszFromSzListValue(sz)) == (RGSZ)NULL)
  66. if (!FHandleOOM(hdlg))
  67. {
  68. DestroyWindow(GetParent(hdlg));
  69. return(fTrue);
  70. }
  71. while (*psz != (SZ)NULL)
  72. {
  73. SZ sz = *(psz++);
  74. INT i = atoi(sz);
  75. if (i > 0 && i <= 10 && i != iButtonChecked)
  76. EnableWindow(GetDlgItem(hdlg, IDC_B0 + i), 0);
  77. else if (*sz != '\0')
  78. PreCondition(fFalse, fTrue);
  79. }
  80. EvalAssert(FFreeRgsz(rgsz));
  81. return(fTrue);
  82. case STF_REINITDIALOG:
  83. return(fTrue);
  84. // case STF_DLG_ACTIVATE:
  85. // case WM_MOUSEACTIVATE:
  86. // if (FActiveStackTop())
  87. // break;
  88. // EvalAssert(FInactivateHelp());
  89. // SetWindowPos(hdlg, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  90. // /* fall through */
  91. // case STF_UILIB_ACTIVATE:
  92. // EvalAssert(FActivateStackTop());
  93. // return(fTrue);
  94. case WM_CLOSE:
  95. PostMessage(
  96. hdlg,
  97. WM_COMMAND,
  98. MAKELONG(IDC_X, BN_CLICKED),
  99. 0L
  100. );
  101. return(fTrue);
  102. case WM_COMMAND:
  103. switch (idc = LOWORD(wParam))
  104. {
  105. case IDC_B1:
  106. case IDC_B2:
  107. case IDC_B3:
  108. case IDC_B4:
  109. case IDC_B5:
  110. case IDC_B6:
  111. case IDC_B7:
  112. case IDC_B8:
  113. case IDC_B9:
  114. case IDC_B10:
  115. CheckRadioButton(hdlg, IDC_B1, iButtonMax, (INT)idc);
  116. if (HIWORD(wParam) != BN_DOUBLECLICKED)
  117. break;
  118. wParam = IDC_C;
  119. /* Fall through */
  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. iButtonChecked = 0;
  145. for (i = 1; i <= 10; i++)
  146. if (SendDlgItemMessage(hdlg, IDC_B0 + i, BM_GETCHECK, 0, 0L))
  147. {
  148. iButtonChecked = i;
  149. break;
  150. }
  151. _itoa((INT)iButtonChecked, rgchNum, 10);
  152. while (!FAddSymbolValueToSymTab("ButtonChecked", rgchNum))
  153. if (!FHandleOOM(hdlg))
  154. {
  155. DestroyWindow(GetParent(hdlg));
  156. return(fTrue);
  157. }
  158. PostMessage(GetParent(hdlg), (WORD)STF_UI_EVENT, 0, 0L);
  159. break;
  160. }
  161. break;
  162. case STF_DESTROY_DLG:
  163. PostMessage(GetParent(hdlg), (WORD)STF_RADIO_DLG_DESTROYED, 0, 0L);
  164. DestroyWindow(hdlg);
  165. return(fTrue);
  166. }
  167. return(fFalse);
  168. }