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.

170 lines
5.2 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /***************************************************************************/
  4. /****************** Basic Class Dialog Handlers ****************************/
  5. /***************************************************************************/
  6. #define cchpMax 511
  7. /*
  8. ** Purpose:
  9. ** Edit Dialog procedure for templates with exactly one edit control.
  10. ** Control IDs:
  11. ** The Edit control must have an id of IDC_EDIT1.
  12. ** Pushbuttons recognized are IDC_O, IDC_C, IDC_M, IDC_H, IDC_X, and IDC_B.
  13. ** Initialization:
  14. ** The symbol $(EditTextIn) is used to set the initial text in the Edit
  15. ** control. It is set to the empty string if the symbol is not found.
  16. ** The symbol $(EditFocus) is used to set what portion of the initial
  17. ** string is selected. Supported values are 'END' (default), 'ALL', or
  18. ** 'START'.
  19. ** Termination:
  20. ** The string in the Edit control is stored in the symbol $(EditTextOut).
  21. ** The id of the Pushbutton (eg IDC_C) which caused termination is
  22. ** converted to a string and stored in the symbol $(ButtonPressed).
  23. **
  24. *****************************************************************************/
  25. INT_PTR APIENTRY FGstEditDlgProc(HWND hdlg,
  26. UINT wMsg,
  27. WPARAM wParam,
  28. LPARAM lParam)
  29. {
  30. static WPARAM wSelStart = 0;
  31. static WPARAM wSelEnd = 0;
  32. CHP rgchNum[10];
  33. CHP rgchText[cchpMax + 1];
  34. SZ sz;
  35. CCHP cchp;
  36. Unused(lParam);
  37. switch (wMsg)
  38. {
  39. case WM_INITDIALOG:
  40. AssertDataSeg();
  41. if( wMsg == WM_INITDIALOG ) {
  42. FCenterDialogOnDesktop(hdlg);
  43. }
  44. cchp = cchpMax;
  45. if ((sz = SzFindSymbolValueInSymTab("EditTextLim")) != (SZ)NULL)
  46. cchp = (CCHP) atoi(sz);
  47. SendDlgItemMessage(hdlg, IDC_EDIT1, EM_LIMITTEXT, cchp, 0L);
  48. if ((sz = SzFindSymbolValueInSymTab("EditTextIn")) == (SZ)NULL)
  49. sz = "";
  50. Assert(sz != NULL);
  51. SetDlgItemText(hdlg, IDC_EDIT1, (LPSTR)sz);
  52. cchp = strlen(sz);
  53. if ((sz = SzFindSymbolValueInSymTab("EditFocus")) == (SZ)NULL)
  54. sz = "END";
  55. /* default == END */
  56. wSelStart = (WPARAM)cchp;
  57. wSelEnd = (WPARAM)cchp;
  58. if (CrcStringCompare(sz, "END") == crcEqual)
  59. ;
  60. else if (CrcStringCompare(sz, "ALL") == crcEqual)
  61. {
  62. wSelStart = 0;
  63. wSelEnd = INT_MAX;
  64. }
  65. else if (CrcStringCompare(sz, "START") == crcEqual)
  66. {
  67. wSelStart = 0;
  68. wSelEnd = 0;
  69. }
  70. return(fTrue);
  71. case STF_REINITDIALOG:
  72. SetFocus( GetDlgItem(hdlg, IDC_EDIT1 ) );
  73. return(fTrue);
  74. // case STF_DLG_ACTIVATE:
  75. // case WM_MOUSEACTIVATE:
  76. // if (FActiveStackTop())
  77. // break;
  78. // EvalAssert(FInactivateHelp());
  79. // SetWindowPos(hdlg, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  80. // /* fall through */
  81. // case STF_UILIB_ACTIVATE:
  82. // EvalAssert(FActivateStackTop());
  83. // return(fTrue);
  84. case WM_CLOSE:
  85. PostMessage(
  86. hdlg,
  87. WM_COMMAND,
  88. MAKELONG(IDC_X, BN_CLICKED),
  89. 0L
  90. );
  91. return(fTrue);
  92. case WM_COMMAND:
  93. switch(LOWORD(wParam))
  94. {
  95. case IDC_EDIT1:
  96. if (HIWORD(wParam) == EN_SETFOCUS)
  97. SendDlgItemMessage(hdlg, IDC_EDIT1, EM_SETSEL, wSelStart,
  98. wSelEnd);
  99. else if (HIWORD(wParam) == EN_KILLFOCUS)
  100. SendDlgItemMessage(hdlg, IDC_EDIT1, EM_GETSEL, (WPARAM)&wSelStart,
  101. (LPARAM)&wSelEnd);
  102. break;
  103. case IDCANCEL:
  104. if (LOWORD(wParam) == IDCANCEL) {
  105. if (!GetDlgItem(hdlg, IDC_B) || HIWORD(GetKeyState(VK_CONTROL)) || HIWORD(GetKeyState(VK_SHIFT)) || HIWORD(GetKeyState(VK_MENU)))
  106. {
  107. break;
  108. }
  109. wParam = IDC_B;
  110. }
  111. case IDC_C:
  112. case IDC_B:
  113. case IDC_O:
  114. case IDC_M:
  115. case IDC_X:
  116. case IDC_BTN0:
  117. case IDC_BTN1: case IDC_BTN2: case IDC_BTN3:
  118. case IDC_BTN4: case IDC_BTN5: case IDC_BTN6:
  119. case IDC_BTN7: case IDC_BTN8: case IDC_BTN9:
  120. _itoa((INT)wParam, rgchNum, 10);
  121. while (!FAddSymbolValueToSymTab("ButtonPressed", rgchNum))
  122. if (!FHandleOOM(hdlg))
  123. {
  124. DestroyWindow(GetParent(hdlg));
  125. return(fTrue);
  126. }
  127. SendDlgItemMessage(hdlg, IDC_EDIT1, (WORD)WM_GETTEXT, cchpMax + 1,
  128. (LPARAM)rgchText);
  129. while (!FAddSymbolValueToSymTab("EditTextOut", rgchText))
  130. if (!FHandleOOM(hdlg))
  131. {
  132. DestroyWindow(GetParent(hdlg));
  133. return(fTrue);
  134. }
  135. PostMessage(GetParent(hdlg), (WORD)STF_UI_EVENT, 0, 0L);
  136. break;
  137. }
  138. break;
  139. case STF_DESTROY_DLG:
  140. PostMessage(GetParent(hdlg), (WORD)STF_EDIT_DLG_DESTROYED, 0, 0L);
  141. DestroyWindow(hdlg);
  142. return(fTrue);
  143. }
  144. return(fFalse);
  145. }