Leaked source code of windows server 2003
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.

311 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxopts.c
  5. Abstract:
  6. Functions for handling the Fax Options property sheet page
  7. Environment:
  8. Fax driver user interface
  9. Revision History:
  10. 01/16/96 -davidx-
  11. Created it.
  12. mm/dd/yy -author-
  13. description
  14. --*/
  15. #include "faxui.h"
  16. #include "faxhelp.h"
  17. //
  18. // Table for mapping control IDs to help indices
  19. //
  20. static ULONG_PTR faxOptionsHelpIDs[] = {
  21. IDC_PAPER_SIZE, IDH_FAXDEFAULT_PAPER_SIZE,
  22. IDC_IMAGE_QUALITY, IDH_FAXDEFAULT_IMAGE_QUALITY,
  23. IDC_PORTRAIT, IDH_FAXDEFAULT_PORTRAIT,
  24. IDC_LANDSCAPE, IDH_FAXDEFAULT_LANDSCAPE,
  25. IDI_FAX_OPTIONS, (DWORD) -1,
  26. IDC_TITLE, (DWORD) -1,
  27. IDC_DEFAULT_PRINT_SETUP_GRP, IDH_FAXDEFAULT_DEFAULT_PRINT_SETUP_GRP,
  28. IDC_ORIENTATION, IDH_FAXDEFAULT_ORIENTATION,
  29. 0, 0
  30. };
  31. VOID
  32. DoInitializeFaxOptions(
  33. HWND hDlg,
  34. PUIDATA pUiData
  35. )
  36. /*++
  37. Routine Description:
  38. Initializes the Fax Options property sheet page with information from the registry
  39. Arguments:
  40. hDlg - Handle to the Fax Options property sheet page
  41. pUiData - Points to our UIDATA structure
  42. Return Value:
  43. NONE
  44. --*/
  45. {
  46. PDEVMODE pdmPublic = &pUiData->devmode.dmPublic;
  47. PDMPRIVATE pdmPrivate = &pUiData->devmode.dmPrivate;
  48. TCHAR buffer[MAX_STRING_LEN];
  49. HWND hwndList;
  50. INT itemId;
  51. //
  52. // Initialize the print setup controls:
  53. // paper size
  54. // image quality
  55. // orientation
  56. // billing code
  57. //
  58. if (hwndList = GetDlgItem(hDlg, IDC_PAPER_SIZE)) {
  59. LPTSTR pFormName = pUiData->pFormNames;
  60. INT listIdx;
  61. for (itemId=0; itemId < pUiData->cForms; itemId++, pFormName += CCHPAPERNAME) {
  62. if ((listIdx = (INT)SendMessage(hwndList, CB_ADDSTRING, 0, (LPARAM) pFormName)) != CB_ERR) {
  63. SendMessage(hwndList, CB_SETITEMDATA, listIdx, itemId);
  64. if (_tcscmp(pFormName, pdmPublic->dmFormName) == EQUAL_STRING)
  65. SendMessage(hwndList, CB_SETCURSEL, listIdx, 0);
  66. }
  67. }
  68. }
  69. if (hwndList = GetDlgItem(hDlg, IDC_IMAGE_QUALITY)) {
  70. LoadString(g_hResource, IDS_QUALITY_NORMAL, buffer, MAX_STRING_LEN);
  71. SendMessage(hwndList, CB_ADDSTRING, 0, (LPARAM) buffer);
  72. LoadString(g_hResource, IDS_QUALITY_DRAFT, buffer, MAX_STRING_LEN);
  73. SendMessage(hwndList, CB_ADDSTRING, 0, (LPARAM) buffer);
  74. itemId = (pdmPublic->dmYResolution == FAXRES_VERTDRAFT) ? 1 : 0;
  75. SendMessage(hwndList, CB_SETCURSEL, itemId, 0);
  76. }
  77. itemId = (pdmPublic->dmOrientation == DMORIENT_LANDSCAPE) ?
  78. IDC_LANDSCAPE : IDC_PORTRAIT;
  79. CheckDlgButton(hDlg, itemId, TRUE);
  80. //
  81. // Disable all controls if the user has no permission
  82. //
  83. if (! pUiData->hasPermission) {
  84. EnableWindow(GetDlgItem(hDlg, IDC_PAPER_SIZE), FALSE);
  85. EnableWindow(GetDlgItem(hDlg, IDC_IMAGE_QUALITY), FALSE);
  86. EnableWindow(GetDlgItem(hDlg, IDC_PORTRAIT), FALSE);
  87. EnableWindow(GetDlgItem(hDlg, IDC_LANDSCAPE), FALSE);
  88. }
  89. }
  90. VOID
  91. DoSaveFaxOptions(
  92. HWND hDlg,
  93. PUIDATA pUiData
  94. )
  95. /*++
  96. Routine Description:
  97. Save the information on the Fax Options property sheet page to registry
  98. Arguments:
  99. hDlg - Handle to the Fax Options property sheet page
  100. pUiData - Points to our UIDATA structure
  101. Return Value:
  102. NONE
  103. --*/
  104. {
  105. PDEVMODE pdmPublic = &pUiData->devmode.dmPublic;
  106. PDMPRIVATE pdmPrivate = &pUiData->devmode.dmPrivate;
  107. HWND hwndList;
  108. INT listIdx;
  109. //
  110. // Time to send
  111. //
  112. //
  113. // Retrieve the current settings of print setup controls:
  114. // paper size
  115. // image quality
  116. // orientation
  117. // billing code
  118. //
  119. if ((hwndList = GetDlgItem(hDlg, IDC_PAPER_SIZE)) &&
  120. (listIdx = (INT)SendMessage(hwndList, CB_GETCURSEL, 0, 0)) != CB_ERR)
  121. {
  122. listIdx = (INT)SendMessage(hwndList, CB_GETITEMDATA, listIdx, 0);
  123. if (listIdx >= 0 && listIdx < pUiData->cForms) {
  124. pdmPublic->dmFields &= ~(DM_PAPERLENGTH|DM_PAPERWIDTH);
  125. pdmPublic->dmFields |= DM_FORMNAME;
  126. pdmPublic->dmPaperSize = pUiData->pPapers[listIdx];
  127. CopyString(pdmPublic->dmFormName,
  128. pUiData->pFormNames + listIdx * CCHPAPERNAME,
  129. CCHFORMNAME);
  130. }
  131. }
  132. pdmPublic->dmPrintQuality = FAXRES_HORIZONTAL;
  133. pdmPublic->dmYResolution =
  134. (SendDlgItemMessage(hDlg, IDC_IMAGE_QUALITY, CB_GETCURSEL, 0, 0) == 1) ?
  135. FAXRES_VERTDRAFT :
  136. FAXRES_VERTICAL;
  137. pdmPublic->dmOrientation =
  138. IsDlgButtonChecked(hDlg, IDC_LANDSCAPE) ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;
  139. }
  140. INT_PTR
  141. FaxOptionsProc(
  142. HWND hDlg,
  143. UINT message,
  144. WPARAM wParam,
  145. LPARAM lParam
  146. )
  147. /*++
  148. Routine Description:
  149. Procedure for handling Fax Options property sheet page
  150. Arguments:
  151. hDlg - Identifies the property sheet page
  152. message - Specifies the message
  153. wParam - Specifies additional message-specific information
  154. lParam - Specifies additional message-specific information
  155. Return Value:
  156. Depends on the value of message parameter
  157. --*/
  158. {
  159. PUIDATA pUiData;
  160. static BOOL bPortrait;
  161. switch (message) {
  162. case WM_INITDIALOG:
  163. //
  164. // Remember the pointer to our UIDATA structure
  165. //
  166. lParam = ((PROPSHEETPAGE *) lParam)->lParam;
  167. pUiData = (PUIDATA) lParam;
  168. Assert(ValidUiData(pUiData));
  169. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  170. //
  171. // Intitialize the controls with information from the registry
  172. //
  173. DoInitializeFaxOptions(hDlg, pUiData);
  174. bPortrait = IsDlgButtonChecked(hDlg,IDC_PORTRAIT);
  175. return TRUE;
  176. case WM_COMMAND:
  177. if (HIWORD(wParam) == CBN_SELCHANGE) {
  178. if (GetDlgCtrlID((HWND)lParam) == IDC_IMAGE_QUALITY ||
  179. GetDlgCtrlID((HWND)lParam) == IDC_PAPER_SIZE ) {
  180. PropSheet_Changed(GetParent(hDlg),hDlg);
  181. }
  182. }
  183. if (HIWORD(wParam) == BN_CLICKED) {
  184. if ((LOWORD(wParam) == IDC_PORTRAIT && !bPortrait) ||
  185. (LOWORD(wParam) == IDC_LANDSCAPE && bPortrait)) {
  186. PropSheet_Changed(GetParent(hDlg),hDlg);
  187. }
  188. }
  189. break;
  190. case WM_NOTIFY:
  191. if (((NMHDR *) lParam)->code == PSN_APPLY) {
  192. pUiData = (PUIDATA) GetWindowLongPtr(hDlg, DWLP_USER);
  193. Assert(ValidUiData(pUiData));
  194. //
  195. // User pressed OK or Apply - validate inputs and save changes
  196. //
  197. DoSaveFaxOptions(hDlg, pUiData);
  198. //
  199. // HACK: Inform common UI library that user has pressed OK
  200. //
  201. pUiData->pfnComPropSheet(pUiData->hComPropSheet,
  202. CPSFUNC_SET_RESULT,
  203. (LPARAM) pUiData->hFaxOptsPage,
  204. CPSUI_OK);
  205. return TRUE;
  206. } else if (((NMHDR *) lParam)->code == DTN_DATETIMECHANGE) {
  207. PropSheet_Changed(GetParent(hDlg),hDlg);
  208. }
  209. break;
  210. case WM_HELP:
  211. WinHelpContextPopup(((LPHELPINFO)lParam)->dwContextId, hDlg);
  212. return TRUE;
  213. }
  214. return FALSE;
  215. }