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.

256 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. statopts.c
  5. Abstract:
  6. Functions to handle status monitor options dialog
  7. Environment:
  8. Fax configuration applet
  9. Revision History:
  10. 12/3/96 -georgeje-
  11. Created it.
  12. mm/dd/yy -author-
  13. description
  14. --*/
  15. #include "faxcpl.h"
  16. VOID
  17. DoInitStatusOptions(
  18. HWND hDlg
  19. )
  20. /*++
  21. Routine Description:
  22. Initializes the Status Options property sheet page with information from the registry
  23. Arguments:
  24. hDlg - Handle to the Status Options property sheet page
  25. Return Value:
  26. NONE
  27. --*/
  28. #define InitStatusOptionsCheckBox(id, pValueName, DefaultValue) \
  29. CheckDlgButton( hDlg, id, GetRegistryDWord( hRegKey, pValueName, DefaultValue ));
  30. {
  31. HKEY hRegKey;
  32. GetFaxDeviceAndConfigInfo();
  33. //
  34. // Open the user info registry key for reading
  35. //
  36. if (! (hRegKey = GetUserInfoRegKey(REGKEY_FAX_USERINFO, REG_READWRITE)))
  37. return;
  38. //
  39. // Fill in the edit text fields
  40. //
  41. InitStatusOptionsCheckBox(IDC_STATUS_TASKBAR, REGVAL_TASKBAR, BST_CHECKED);
  42. InitStatusOptionsCheckBox(IDC_STATUS_ONTOP, REGVAL_ALWAYS_ON_TOP, BST_CHECKED);
  43. InitStatusOptionsCheckBox(IDC_STATUS_VISUAL, REGVAL_VISUAL_NOTIFICATION, BST_CHECKED);
  44. InitStatusOptionsCheckBox(IDC_STATUS_SOUND, REGVAL_SOUND_NOTIFICATION, BST_UNCHECKED);
  45. InitStatusOptionsCheckBox(IDC_STATUS_MANUAL, REGVAL_ENABLE_MANUAL_ANSWER, BST_UNCHECKED);
  46. //
  47. // Close the registry key before returning to the caller
  48. //
  49. RegCloseKey(hRegKey);
  50. }
  51. VOID
  52. DoSaveStatusOptions(
  53. HWND hDlg
  54. )
  55. /*++
  56. Routine Description:
  57. Save the information on the Status Options property sheet page to registry
  58. Arguments:
  59. hDlg - Handle to the Status Options property sheet page
  60. Return Value:
  61. NONE
  62. --*/
  63. #define SaveStatusOptionsCheckBox(id, pValueName) \
  64. SaveRegistryDWord(hRegKey, pValueName, IsDlgButtonChecked(hDlg, id));
  65. {
  66. HKEY hRegKey;
  67. HWND hStatWnd;
  68. BOOL fSaveConfig = FALSE;
  69. //
  70. // Open the user registry key for writing and create it if necessary
  71. //
  72. if (! GetChangedFlag(STATUS_OPTIONS_PAGE) ||
  73. ! (hRegKey = GetUserInfoRegKey(REGKEY_FAX_USERINFO, REG_READWRITE)))
  74. {
  75. return;;
  76. }
  77. SaveStatusOptionsCheckBox(IDC_STATUS_TASKBAR, REGVAL_TASKBAR);
  78. SaveStatusOptionsCheckBox(IDC_STATUS_ONTOP, REGVAL_ALWAYS_ON_TOP);
  79. SaveStatusOptionsCheckBox(IDC_STATUS_VISUAL, REGVAL_VISUAL_NOTIFICATION);
  80. SaveStatusOptionsCheckBox(IDC_STATUS_SOUND, REGVAL_SOUND_NOTIFICATION);
  81. SaveStatusOptionsCheckBox(IDC_STATUS_MANUAL, REGVAL_ENABLE_MANUAL_ANSWER);
  82. //
  83. // Close the registry key before returning to the caller
  84. //
  85. RegCloseKey(hRegKey);
  86. if (IsDlgButtonChecked( hDlg, IDC_STATUS_MANUAL ) == BST_CHECKED &&
  87. gConfigData->pDevInfo[0].Rings != 99) {
  88. gConfigData->pDevInfo[0].Rings = 99;
  89. fSaveConfig = TRUE;
  90. } else if (gConfigData->pDevInfo->Rings == 99) {
  91. gConfigData->pDevInfo[0].Rings = 2;
  92. fSaveConfig = TRUE;
  93. }
  94. if (fSaveConfig) {
  95. SaveFaxDeviceAndConfigInfo( hDlg, STATUS_OPTIONS_PAGE );
  96. }
  97. //
  98. // Notify the status app that the configuration has changed.
  99. // The Window Class and message in the following two lines
  100. // are hard coded. If you change them, then they must also
  101. // be changed in the Fax Status Monitor
  102. //
  103. hStatWnd = FindWindow(FAXSTAT_WINCLASS, NULL);
  104. if (hStatWnd) {
  105. PostMessage(hStatWnd, WM_USER + 203, 0, 0);
  106. }
  107. }
  108. BOOL
  109. StatusOptionsProc(
  110. HWND hDlg,
  111. UINT message,
  112. UINT wParam,
  113. LONG lParam
  114. )
  115. /*++
  116. Routine Description:
  117. Procedure for handling the "Status Options" tab
  118. Arguments:
  119. hDlg - Identifies the property sheet page
  120. message - Specifies the message
  121. wParam - Specifies additional message-specific information
  122. lParam - Specifies additional message-specific information
  123. Return Value:
  124. Depends on the value of message parameter
  125. --*/
  126. {
  127. LPNMHDR lpNMHdr = (LPNMHDR) lParam;
  128. switch (message) {
  129. case WM_INITDIALOG:
  130. DoInitStatusOptions( hDlg );
  131. return TRUE;
  132. case WM_COMMAND:
  133. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  134. case IDC_STATUS_TASKBAR:
  135. case IDC_STATUS_ONTOP:
  136. case IDC_STATUS_VISUAL:
  137. case IDC_STATUS_SOUND:
  138. case IDC_STATUS_MANUAL:
  139. if (GET_WM_COMMAND_CMD(wParam, lParam) == BN_CLICKED)
  140. break;
  141. default:
  142. return FALSE;
  143. }
  144. SetChangedFlag(hDlg, STATUS_OPTIONS_PAGE, TRUE);
  145. return TRUE;
  146. case WM_NOTIFY:
  147. switch (lpNMHdr->code) {
  148. case PSN_SETACTIVE:
  149. break;
  150. case PSN_APPLY:
  151. //
  152. // User pressed OK or Apply - validate inputs and save changes
  153. //
  154. DoSaveStatusOptions(hDlg);
  155. SetChangedFlag(hDlg, STATUS_OPTIONS_PAGE, FALSE);
  156. return PSNRET_NOERROR;
  157. }
  158. break;
  159. case WM_HELP:
  160. case WM_CONTEXTMENU:
  161. return HandleHelpPopup(hDlg, message, wParam, lParam, STATUS_OPTIONS_PAGE);
  162. }
  163. return FALSE;
  164. }