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.

183 lines
5.1 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1993-1994
  4. *
  5. * TITLE: REGSTRED.C
  6. *
  7. * VERSION: 4.01
  8. *
  9. * AUTHOR: Tracy Sharpe
  10. *
  11. * DATE: 05 Mar 1994
  12. *
  13. * String edit dialog for use by the Registry Editor.
  14. *
  15. ********************************************************************************
  16. *
  17. * CHANGE LOG:
  18. *
  19. * DATE REV DESCRIPTION
  20. * ----------- --- -------------------------------------------------------------
  21. * 05 Mar 1994 TCS Original implementation.
  22. *
  23. *******************************************************************************/
  24. #include "pch.h"
  25. #include "regresid.h"
  26. #include "reghelp.h"
  27. const DWORD s_EditStringValueHelpIDs[] = {
  28. IDC_VALUEDATA, IDH_REGEDIT_VALUEDATA,
  29. IDC_VALUENAME, IDH_REGEDIT_VALUENAME,
  30. 0, 0
  31. };
  32. BOOL
  33. PASCAL
  34. EditStringValue_OnInitDialog(
  35. HWND hWnd,
  36. HWND hFocusWnd,
  37. LPARAM lParam
  38. );
  39. /*******************************************************************************
  40. *
  41. * EditStringValueDlgProc
  42. *
  43. * DESCRIPTION:
  44. *
  45. * PARAMETERS:
  46. *
  47. *******************************************************************************/
  48. INT_PTR
  49. CALLBACK
  50. EditStringValueDlgProc(
  51. HWND hWnd,
  52. UINT Message,
  53. WPARAM wParam,
  54. LPARAM lParam
  55. )
  56. {
  57. LPEDITVALUEPARAM lpEditValueParam;
  58. switch (Message)
  59. {
  60. HANDLE_MSG(hWnd, WM_INITDIALOG, EditStringValue_OnInitDialog);
  61. case WM_COMMAND:
  62. {
  63. DWORD dwCommand = GET_WM_COMMAND_ID(wParam, lParam);
  64. switch (dwCommand)
  65. {
  66. case IDOK:
  67. {
  68. UINT ccValueData;
  69. UINT cbValueData;
  70. PBYTE pbValueData = NULL;
  71. lpEditValueParam = (LPEDITVALUEPARAM) GetWindowLongPtr(hWnd, DWLP_USER);
  72. // this maybe a multi-string, if so the sizeof(TCHAR) is added to
  73. // allow for the multi-string to be terminated also.
  74. ccValueData = (UINT) SendDlgItemMessage(hWnd, IDC_VALUEDATA,
  75. WM_GETTEXTLENGTH, 0, 0) + 2;
  76. cbValueData = ccValueData * sizeof(TCHAR);
  77. if (cbValueData > lpEditValueParam->cbValueData)
  78. {
  79. // need a bigger buffer
  80. PBYTE pbValueData =
  81. LocalReAlloc(lpEditValueParam->pValueData, cbValueData, LMEM_MOVEABLE);
  82. if (!pbValueData)
  83. {
  84. InternalMessageBox(g_hInstance, hWnd, MAKEINTRESOURCE(IDS_EDITVALNOMEMORY),
  85. MAKEINTRESOURCE(IDS_EDITVALERRORTITLE), MB_ICONERROR | MB_OK, NULL);
  86. dwCommand = IDCANCEL;
  87. }
  88. else
  89. {
  90. lpEditValueParam->pValueData = pbValueData;
  91. }
  92. }
  93. // sizeof(TCHAR) to remove multi-string null char from count
  94. lpEditValueParam->cbValueData = cbValueData - sizeof(TCHAR);
  95. GetDlgItemText(hWnd, IDC_VALUEDATA, (PTSTR)lpEditValueParam->
  96. pValueData, lpEditValueParam->cbValueData - sizeof(TCHAR));
  97. lpEditValueParam->pValueData[lpEditValueParam->cbValueData - sizeof(TCHAR)]
  98. = TEXT('\0');
  99. }
  100. // FALL THROUGH
  101. case IDCANCEL:
  102. EndDialog(hWnd, dwCommand);
  103. break;
  104. }
  105. }
  106. break;
  107. case WM_HELP:
  108. WinHelp(((LPHELPINFO) lParam)-> hItemHandle, g_pHelpFileName,
  109. HELP_WM_HELP, (ULONG_PTR) s_EditStringValueHelpIDs);
  110. break;
  111. case WM_CONTEXTMENU:
  112. WinHelp((HWND) wParam, g_pHelpFileName, HELP_CONTEXTMENU,
  113. (ULONG_PTR) s_EditStringValueHelpIDs);
  114. break;
  115. default:
  116. return FALSE;
  117. }
  118. return TRUE;
  119. }
  120. /*******************************************************************************
  121. *
  122. * EditStringValue_OnInitDialog
  123. *
  124. * DESCRIPTION:
  125. *
  126. * PARAMETERS:
  127. * hWnd, handle of EditStringValue window.
  128. * hFocusWnd,
  129. * lParam,
  130. *
  131. *******************************************************************************/
  132. BOOL
  133. PASCAL
  134. EditStringValue_OnInitDialog(
  135. HWND hWnd,
  136. HWND hFocusWnd,
  137. LPARAM lParam
  138. )
  139. {
  140. LPEDITVALUEPARAM lpEditValueParam;
  141. // Change maximum number of characters of the edit control, to its
  142. // maximum limit (from 3000 characters to 4G characters).
  143. SendDlgItemMessage( hWnd, IDC_VALUEDATA, EM_LIMITTEXT, 0, 0L );
  144. SetWindowLongPtr(hWnd, DWLP_USER, lParam);
  145. lpEditValueParam = (LPEDITVALUEPARAM) lParam;
  146. SetDlgItemText(hWnd, IDC_VALUENAME, lpEditValueParam-> pValueName);
  147. SetDlgItemText(hWnd, IDC_VALUEDATA, (PTSTR)lpEditValueParam-> pValueData);
  148. return TRUE;
  149. UNREFERENCED_PARAMETER(hFocusWnd);
  150. }