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.

295 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxopts.c
  5. Abstract:
  6. Functions for handling events in the "Fax Options" 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. VOID
  18. DoActivateFaxOptions(
  19. HWND hDlg
  20. )
  21. /*++
  22. Routine Description:
  23. Called when the "Fax Options" page is activated
  24. Arguments:
  25. hDlg - Window handle to the "Fax Options" page
  26. Return Value:
  27. NONE
  28. --*/
  29. {
  30. //
  31. // Controls on the "Fax Options" page which may be enabled or disabled
  32. //
  33. static INT faxOptionsCtrls[] = {
  34. IDC_BILLING_CODE,
  35. IDC_EMAIL,
  36. 0,
  37. };
  38. SetChangedFlag(hDlg, CLIENT_OPTIONS_PAGE, FALSE);
  39. //
  40. // Disable dialog controls if there is no printer is selected
  41. //
  42. Verbose(("Updating 'Fax Options' page ...\n"));
  43. //
  44. // Enable dialog controls
  45. //
  46. EnableControls(hDlg, faxOptionsCtrls, TRUE);
  47. //
  48. // Billing code
  49. //
  50. MySetDlgItemText(hDlg, IDC_BILLING_CODE, pdmPrivate->billingCode);
  51. //
  52. // Email Address
  53. //
  54. MySetDlgItemText(hDlg, IDC_EMAIL, pdmPrivate->emailAddress);
  55. }
  56. VOID
  57. DoSaveFaxOptions(
  58. HWND hDlg
  59. )
  60. /*++
  61. Routine Description:
  62. Save the information on the "Fax Options" property sheet page
  63. Arguments:
  64. hDlg - Handle to the Fax Options property sheet page
  65. Return Value:
  66. NONE
  67. --*/
  68. {
  69. PDEVMODE pdmPublic;
  70. PDMPRIVATE pdmPrivate;
  71. HWND hwndList;
  72. INT listIdx;
  73. LPTSTR pPrinterSelName;
  74. //
  75. // Check if anything on this page was changed
  76. //
  77. Verbose(("Saving 'Fax Options' page ...\n"));
  78. if (! GetChangedFlag(CLIENT_OPTIONS_PAGE) ||
  79. ! IsPrinterSelInSync(CLIENT_OPTIONS_PAGE) ||
  80. ! (pPrinterSelName = GetPrinterSelName()))
  81. {
  82. return;
  83. }
  84. //
  85. // Time to send
  86. //
  87. pdmPublic = &gConfigData->devmode.dmPublic;
  88. pdmPrivate = &gConfigData->devmode.dmPrivate;
  89. pdmPrivate->whenToSend =
  90. IsDlgButtonChecked(hDlg, IDC_SEND_AT_CHEAP) ? SENDFAX_AT_CHEAP :
  91. IsDlgButtonChecked(hDlg, IDC_SEND_AT_TIME) ? SENDFAX_AT_TIME : SENDFAX_ASAP;
  92. //
  93. // Retrieve the current settings of send-at time control
  94. //
  95. GetTimeControlValue(hDlg, IDC_TC_AT_TIME, &pdmPrivate->sendAtTime);
  96. //
  97. // Retrieve the current settings of print setup controls:
  98. // paper size
  99. // image quality
  100. // orientation
  101. // billing code
  102. //
  103. if ((hwndList = GetDlgItem(hDlg, IDC_PAPER_SIZE)) &&
  104. (listIdx = SendMessage(hwndList, CB_GETCURSEL, 0, 0)) != CB_ERR)
  105. {
  106. listIdx = SendMessage(hwndList, CB_GETITEMDATA, listIdx, 0);
  107. if (listIdx >= 0 && listIdx < gConfigData->cForms) {
  108. pdmPublic->dmFields &= ~(DM_PAPERLENGTH|DM_PAPERWIDTH);
  109. pdmPublic->dmFields |= DM_FORMNAME;
  110. pdmPublic->dmPaperSize = gConfigData->pFormInfo[listIdx].paperSizeIndex;
  111. _tcscpy(pdmPublic->dmFormName, gConfigData->pFormInfo[listIdx].pFormName);
  112. }
  113. }
  114. pdmPublic->dmPrintQuality = FAXRES_HORIZONTAL;
  115. pdmPublic->dmYResolution =
  116. (SendDlgItemMessage(hDlg, IDC_IMAGE_QUALITY, CB_GETCURSEL, 0, 0) == 1) ?
  117. FAXRES_VERTDRAFT :
  118. FAXRES_VERTICAL;
  119. pdmPublic->dmOrientation =
  120. IsDlgButtonChecked(hDlg, IDC_LANDSCAPE) ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
  121. GetDlgItemText(hDlg, IDC_BILLING_CODE, pdmPrivate->billingCode, MAX_BILLING_CODE);
  122. GetDlgItemText(hDlg, IDC_EMAIL, pdmPrivate->emailAddress, MAX_EMAIL_ADDRESS);
  123. //
  124. // Save per-user devmode information
  125. //
  126. SavePerUserDevmode(pPrinterSelName, (PDEVMODE) &gConfigData->devmode);
  127. }
  128. BOOL
  129. FaxOptionsProc(
  130. HWND hDlg,
  131. UINT message,
  132. UINT wParam,
  133. LONG lParam
  134. )
  135. /*++
  136. Routine Description:
  137. Procedure for handling the "Fax Options" tab
  138. Arguments:
  139. hDlg - Identifies the property sheet page
  140. message - Specifies the message
  141. wParam - Specifies additional message-specific information
  142. lParam - Specifies additional message-specific information
  143. Return Value:
  144. Depends on the value of message parameter
  145. --*/
  146. {
  147. INT cmdId;
  148. BOOL result;
  149. switch (message) {
  150. case WM_INITDIALOG:
  151. SendDlgItemMessage(hDlg, IDC_BILLING_CODE, EM_SETLIMITTEXT, MAX_BILLING_CODE-1, 0);
  152. SendDlgItemMessage(hDlg, IDC_EMAIL, EM_SETLIMITTEXT, MAX_EMAIL_ADDRESS-1, 0);
  153. if (gConfigData->configType & FAXCONFIG_WORKSTATION) {
  154. HideWindow( GetDlgItem( hDlg, IDC_EMAIL ) );
  155. HideWindow( GetDlgItem( hDlg, IDCSTATIC_EMAIL ) );
  156. }
  157. return TRUE;
  158. case WM_COMMAND:
  159. switch (cmdId = GET_WM_COMMAND_ID(wParam, lParam)) {
  160. case IDC_BILLING_CODE:
  161. if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE || insideSetDlgItemText)
  162. return TRUE;
  163. break;
  164. case IDC_EMAIL:
  165. if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE || insideSetDlgItemText)
  166. return TRUE;
  167. break;
  168. default:
  169. return FALSE;
  170. }
  171. SetChangedFlag(hDlg, CLIENT_OPTIONS_PAGE, TRUE);
  172. return result;
  173. case WM_NOTIFY:
  174. switch (((NMHDR *) lParam)->code) {
  175. case PSN_SETACTIVE:
  176. DoActivateFaxOptions(hDlg);
  177. break;
  178. case PSN_APPLY:
  179. //
  180. // User pressed OK or Apply - validate inputs and save changes
  181. //
  182. DoSaveFaxOptions(hDlg);
  183. SetChangedFlag(hDlg, CLIENT_OPTIONS_PAGE, FALSE);
  184. return PSNRET_NOERROR;
  185. }
  186. break;
  187. case WM_HELP:
  188. case WM_CONTEXTMENU:
  189. return HandleHelpPopup(hDlg, message, wParam, lParam, CLIENT_OPTIONS_PAGE);
  190. }
  191. return FALSE;
  192. }