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.

284 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. userinfo.c
  5. Abstract:
  6. Functions for handling events in the "User Info" tab of
  7. the fax client configuration property sheet
  8. Environment:
  9. Fax configuration applet
  10. Revision History:
  11. 03/13/96 -davidx-
  12. Created it.
  13. mm/dd/yy -author-
  14. description
  15. --*/
  16. #include "faxcpl.h"
  17. #include "tapiutil.h"
  18. VOID
  19. DoInitUserInfo(
  20. HWND hDlg
  21. )
  22. /*++
  23. Routine Description:
  24. Initializes the User Info property sheet page with information from the registry
  25. Arguments:
  26. hDlg - Handle to the User Info property sheet page
  27. Return Value:
  28. NONE
  29. --*/
  30. #define InitUserInfoTextField(id, pValueName) \
  31. SetDlgItemText(hDlg, id, GetRegistryString(hRegKey, pValueName, buffer, MAX_STRING_LEN))
  32. {
  33. TCHAR buffer[MAX_STRING_LEN];
  34. HKEY hRegKey;
  35. //
  36. // Maximum length for various text fields in the dialog
  37. //
  38. static INT textLimits[] = {
  39. IDC_SENDER_NAME, 128,
  40. IDC_SENDER_FAX_NUMBER, 64,
  41. IDC_SENDER_MAILBOX, 64,
  42. IDC_SENDER_COMPANY, 128,
  43. IDC_SENDER_ADDRESS, 256,
  44. IDC_SENDER_TITLE, 64,
  45. IDC_SENDER_DEPT, 64,
  46. IDC_SENDER_OFFICE_LOC, 64,
  47. IDC_SENDER_OFFICE_TL, 64,
  48. IDC_SENDER_HOME_TL, 64,
  49. IDC_BILLING_CODE, 64,
  50. 0,
  51. };
  52. LimitTextFields(hDlg, textLimits);
  53. //
  54. // Open the user info registry key for reading
  55. //
  56. if (! (hRegKey = GetUserInfoRegKey(REGKEY_FAX_USERINFO, REG_READWRITE)))
  57. return;
  58. //
  59. // Initialize the list of countries
  60. //
  61. insideSetDlgItemText = TRUE;
  62. //
  63. // Fill in the edit text fields
  64. //
  65. InitUserInfoTextField(IDC_SENDER_NAME, REGVAL_FULLNAME);
  66. InitUserInfoTextField(IDC_SENDER_FAX_NUMBER, REGVAL_FAX_NUMBER);
  67. InitUserInfoTextField(IDC_SENDER_MAILBOX, REGVAL_MAILBOX);
  68. InitUserInfoTextField(IDC_SENDER_COMPANY, REGVAL_COMPANY);
  69. InitUserInfoTextField(IDC_SENDER_TITLE, REGVAL_TITLE);
  70. InitUserInfoTextField(IDC_SENDER_ADDRESS, REGVAL_ADDRESS);
  71. InitUserInfoTextField(IDC_SENDER_DEPT, REGVAL_DEPT);
  72. InitUserInfoTextField(IDC_SENDER_OFFICE_LOC, REGVAL_OFFICE);
  73. InitUserInfoTextField(IDC_SENDER_HOME_TL, REGVAL_HOME_PHONE);
  74. InitUserInfoTextField(IDC_SENDER_OFFICE_TL, REGVAL_OFFICE_PHONE);
  75. InitUserInfoTextField(IDC_SENDER_BILLING_CODE, REGVAL_BILLING_CODE);
  76. insideSetDlgItemText = FALSE;
  77. //
  78. // Close the registry key before returning to the caller
  79. //
  80. RegCloseKey(hRegKey);
  81. }
  82. VOID
  83. DoSaveUserInfo(
  84. HWND hDlg
  85. )
  86. /*++
  87. Routine Description:
  88. Save the information on the User Info property sheet page to registry
  89. Arguments:
  90. hDlg - Handle to the User Info property sheet page
  91. Return Value:
  92. NONE
  93. --*/
  94. #define SaveUserInfoTextField(id, pValueName) { \
  95. if (! GetDlgItemText(hDlg, id, buffer, MAX_STRING_LEN)) \
  96. buffer[0] = NUL; \
  97. SaveRegistryString(hRegKey, pValueName, buffer); \
  98. }
  99. {
  100. TCHAR buffer[MAX_STRING_LEN];
  101. HKEY hRegKey;
  102. //
  103. // Open the user registry key for writing and create it if necessary
  104. //
  105. if (! GetChangedFlag(USER_INFO_PAGE) ||
  106. ! (hRegKey = GetUserInfoRegKey(REGKEY_FAX_USERINFO, REG_READWRITE)))
  107. {
  108. return;
  109. }
  110. SaveUserInfoTextField(IDC_SENDER_NAME, REGVAL_FULLNAME);
  111. SaveUserInfoTextField(IDC_SENDER_FAX_NUMBER, REGVAL_FAX_NUMBER);
  112. SaveUserInfoTextField(IDC_SENDER_MAILBOX, REGVAL_MAILBOX);
  113. SaveUserInfoTextField(IDC_SENDER_COMPANY, REGVAL_COMPANY);
  114. SaveUserInfoTextField(IDC_SENDER_TITLE, REGVAL_TITLE);
  115. SaveUserInfoTextField(IDC_SENDER_ADDRESS, REGVAL_ADDRESS);
  116. SaveUserInfoTextField(IDC_SENDER_DEPT, REGVAL_DEPT);
  117. SaveUserInfoTextField(IDC_SENDER_OFFICE_LOC, REGVAL_OFFICE);
  118. SaveUserInfoTextField(IDC_SENDER_HOME_TL, REGVAL_HOME_PHONE);
  119. SaveUserInfoTextField(IDC_SENDER_OFFICE_TL, REGVAL_OFFICE_PHONE);
  120. SaveUserInfoTextField(IDC_SENDER_BILLING_CODE, REGVAL_BILLING_CODE);
  121. //
  122. // Close the registry key before returning to the caller
  123. //
  124. RegCloseKey(hRegKey);
  125. }
  126. BOOL
  127. UserInfoProc(
  128. HWND hDlg,
  129. UINT message,
  130. UINT wParam,
  131. LONG lParam
  132. )
  133. /*++
  134. Routine Description:
  135. Procedure for handling the "User Info" tab
  136. Arguments:
  137. hDlg - Identifies the property sheet page
  138. message - Specifies the message
  139. wParam - Specifies additional message-specific information
  140. lParam - Specifies additional message-specific information
  141. Return Value:
  142. Depends on the value of message parameter
  143. --*/
  144. {
  145. switch (message) {
  146. case WM_INITDIALOG:
  147. //
  148. // Perform any necessary TAPI initialization
  149. //
  150. InitTapiService();
  151. //
  152. // Initialize the text fields with information from the registry
  153. //
  154. DoInitUserInfo(hDlg);
  155. return TRUE;
  156. case WM_COMMAND:
  157. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  158. case IDC_SENDER_NAME:
  159. case IDC_SENDER_FAX_NUMBER:
  160. case IDC_SENDER_MAILBOX:
  161. case IDC_SENDER_COMPANY:
  162. case IDC_SENDER_ADDRESS:
  163. case IDC_SENDER_TITLE:
  164. case IDC_SENDER_DEPT:
  165. case IDC_SENDER_OFFICE_LOC:
  166. case IDC_SENDER_OFFICE_TL:
  167. case IDC_SENDER_HOME_TL:
  168. case IDC_SENDER_BILLING_CODE:
  169. if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE && !insideSetDlgItemText)
  170. break;
  171. default:
  172. return FALSE;
  173. }
  174. SetChangedFlag(hDlg, USER_INFO_PAGE, TRUE);
  175. return TRUE;
  176. case WM_NOTIFY:
  177. switch (((NMHDR *) lParam)->code) {
  178. case PSN_SETACTIVE:
  179. break;
  180. case PSN_APPLY:
  181. //
  182. // User pressed OK or Apply - validate inputs and save changes
  183. //
  184. DoSaveUserInfo(hDlg);
  185. SetChangedFlag(hDlg, USER_INFO_PAGE, FALSE);
  186. return PSNRET_NOERROR;
  187. }
  188. break;
  189. case WM_HELP:
  190. case WM_CONTEXTMENU:
  191. return HandleHelpPopup(hDlg, message, wParam, lParam, USER_INFO_PAGE);
  192. }
  193. return FALSE;
  194. }