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.

270 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. servercp.c
  5. Abstract:
  6. Functions for handling events in the "Server Cover Page" 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 "coverpg.h"
  18. VOID
  19. DoActivateServerCoverPage(
  20. HWND hDlg
  21. )
  22. /*++
  23. Routine Description:
  24. Called when the "Server Cover Page" property page is activated
  25. Arguments:
  26. hDlg - Window handle to the "Server Cover Page" property page
  27. Return Value:
  28. NONE
  29. --*/
  30. {
  31. //
  32. // Controls on the "Server Cover Page" page which may be enabled or disabled
  33. //
  34. static INT servercpCtrls[] = {
  35. IDC_USE_SERVERCP,
  36. IDC_COVERPG_NEW,
  37. IDC_COVERPG_OPEN,
  38. IDC_COVERPG_ADD,
  39. IDC_COVERPG_REMOVE,
  40. 0,
  41. };
  42. BOOL enabled = FALSE;
  43. SetChangedFlag(hDlg, SERVER_COVERPG_PAGE, FALSE);
  44. Verbose(("Updating 'Server Cover Page' page ...\n"));
  45. //
  46. // Whether the user must use server-based cover pages
  47. //
  48. CheckDlgButton(hDlg, IDC_USE_SERVERCP, gConfigData->pFaxConfig->ServerCp);
  49. //
  50. // Initialize cover page controls
  51. //
  52. FreeCoverPageInfo(gConfigData->pCPInfo);
  53. gConfigData->pCPInfo = AllocCoverPageInfo(TRUE);
  54. InitCoverPageList(gConfigData->pCPInfo, hDlg);
  55. enabled = gConfigData->pServerName == NULL;
  56. //
  57. // Disable or enable the controls depending on whether the user
  58. // has privilege to perform printer administration.
  59. //
  60. EnableControls(hDlg, servercpCtrls, enabled);
  61. }
  62. BOOL
  63. DoSaveServerCoverPage(
  64. HWND hDlg
  65. )
  66. /*++
  67. Routine Description:
  68. Save the information on the "Server Cover Page" property page
  69. Arguments:
  70. hDlg - Handle to the "Server Cover Page" property page
  71. Return Value:
  72. TRUE if successful, FALSE if there is an error
  73. --*/
  74. {
  75. //
  76. // Check if anything on this page was changed
  77. //
  78. Verbose(("Saving 'Server Cover Page' page ...\n"));
  79. if (!GetChangedFlag(SERVER_COVERPG_PAGE)) {
  80. return TRUE;
  81. }
  82. //
  83. // Whether the user must use server-based cover pages
  84. //
  85. gConfigData->pFaxConfig->ServerCp = IsDlgButtonChecked(hDlg, IDC_USE_SERVERCP) ? 1 : 0;
  86. return SaveFaxDeviceAndConfigInfo(hDlg, SERVER_COVERPG_PAGE);
  87. }
  88. BOOL
  89. ServerCoverPageProc(
  90. HWND hDlg,
  91. UINT message,
  92. UINT wParam,
  93. LONG lParam
  94. )
  95. /*++
  96. Routine Description:
  97. Procedure for handling the "Server Cover Page" tab
  98. Arguments:
  99. hDlg - Identifies the property sheet page
  100. message - Specifies the message
  101. wParam - Specifies additional message-specific information
  102. lParam - Specifies additional message-specific information
  103. Return Value:
  104. Depends on the value of message parameter
  105. --*/
  106. {
  107. INT cmdId;
  108. switch (message) {
  109. case WM_INITDIALOG:
  110. return TRUE;
  111. case WM_COMMAND:
  112. switch (cmdId = GET_WM_COMMAND_ID(wParam, lParam)) {
  113. case IDC_USE_SERVERCP:
  114. SetChangedFlag(hDlg, SERVER_COVERPG_PAGE, TRUE);
  115. return TRUE;
  116. case IDC_COVERPG_ADD:
  117. case IDC_COVERPG_NEW:
  118. case IDC_COVERPG_OPEN:
  119. case IDC_COVERPG_REMOVE:
  120. //
  121. // User clicked one of the buttons for managing cover page files
  122. //
  123. cmdId = (cmdId == IDC_COVERPG_REMOVE) ? CPACTION_REMOVE :
  124. (cmdId == IDC_COVERPG_OPEN) ? CPACTION_OPEN :
  125. (cmdId == IDC_COVERPG_NEW) ? CPACTION_NEW : CPACTION_BROWSE;
  126. ManageCoverPageList(hDlg,
  127. gConfigData->pCPInfo,
  128. GetDlgItem(hDlg, IDC_COVERPG_LIST),
  129. cmdId);
  130. return TRUE;
  131. case IDC_COVERPG_LIST:
  132. switch (GET_WM_COMMAND_CMD(wParam, lParam)) {
  133. case LBN_SELCHANGE:
  134. UpdateCoverPageControls(hDlg);
  135. break;
  136. case LBN_DBLCLK:
  137. //
  138. // Double-clicking in the cover page list is equivalent
  139. // to pressing the "Open" button
  140. //
  141. ManageCoverPageList(hDlg,
  142. gConfigData->pCPInfo,
  143. GetDlgItem(hDlg, cmdId),
  144. CPACTION_OPEN);
  145. break;
  146. }
  147. return TRUE;
  148. }
  149. break;
  150. case WM_NOTIFY:
  151. switch (((NMHDR *) lParam)->code) {
  152. case PSN_SETACTIVE:
  153. DoActivateServerCoverPage(hDlg);
  154. break;
  155. case PSN_APPLY:
  156. //
  157. // User pressed OK or Apply - validate inputs and save changes
  158. //
  159. if (! DoSaveServerCoverPage(hDlg)) {
  160. SetWindowLong(hDlg, DWL_MSGRESULT, -1);
  161. return PSNRET_INVALID_NOCHANGEPAGE;
  162. } else {
  163. SetChangedFlag(hDlg, SERVER_COVERPG_PAGE, FALSE);
  164. return PSNRET_NOERROR;
  165. }
  166. }
  167. break;
  168. case WM_HELP:
  169. case WM_CONTEXTMENU:
  170. return HandleHelpPopup(hDlg, message, wParam, lParam, SERVER_COVERPG_PAGE);
  171. }
  172. return FALSE;
  173. }