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.

719 lines
28 KiB

  1. /*++
  2. Copyright (c) 1996-2002 Microsoft Corp. & Ricoh Co., Ltd. All rights reserved.
  3. FILE: RPDLDLG.CPP
  4. Abstract: Add OEM Page (FAX)
  5. Functions: FaxPageProc
  6. Environment: Windows NT Unidrv5 driver
  7. Revision History:
  8. 10/20/98 -Masatoshi Kubokura-
  9. Last modified for Windows2000.
  10. 08/30/99 -Masatoshi Kubokura-
  11. Began to modify for NT4SP6(Unidrv5.4).
  12. 09/02/99 -Masatoshi Kubokura-
  13. Last modified for NT4SP6.
  14. 10/05/2000 -Masatoshi Kubokura-
  15. Last modified for XP inbox.
  16. 03/04/2002 -Masatoshi Kubokura-
  17. Include strsafe.h.
  18. Use safe_sprintfW() instead of wsprintfW().
  19. Use OemToCharBuff() instead of OemToChar().
  20. 04/01/2002 -Masatoshi Kubokura-
  21. Use safe_strlenW() instead of lstrlen().
  22. --*/
  23. #include "pdev.h"
  24. #include "resource.h"
  25. #include <prsht.h>
  26. #ifndef WINNT_40
  27. #include "strsafe.h" // @Mar/01/2002
  28. #endif // !WINNT_40
  29. extern HINSTANCE ghInstance; // MSKK 98/10/08
  30. WORD wFaxResoStrID[3] = {
  31. IDS_RPDL_FAX_RESO_SUPER,
  32. IDS_RPDL_FAX_RESO_FINE,
  33. IDS_RPDL_FAX_RESO_COARSE
  34. };
  35. WORD wFaxChStrID[4] = {
  36. IDS_RPDL_FAX_CH_G3,
  37. IDS_RPDL_FAX_CH_G4,
  38. IDS_RPDL_FAX_CH_G3_1,
  39. IDS_RPDL_FAX_CH_G3_2
  40. };
  41. #define FAXCH_G4 1
  42. extern "C" {
  43. // External Functions' prototype
  44. extern INT safe_sprintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, ...);
  45. extern INT safe_strlenW(wchar_t* psz, size_t cchMax);
  46. // Local Functions' prototype
  47. INT_PTR APIENTRY FaxPageProc(HWND, UINT, WPARAM, LPARAM);
  48. INT_PTR APIENTRY FaxSubDialog(HWND, UINT, WPARAM, LPARAM);
  49. /***************************************************************************
  50. Function Name : InitMainDlg
  51. ***************************************************************************/
  52. VOID InitMainDlg(
  53. HWND hDlg,
  54. PUIDATA pUiData)
  55. {
  56. // initialize check box (send fax, clear fax number after send)
  57. SendDlgItemMessage(hDlg, IDC_CHECK_SEND, BM_SETCHECK,
  58. (WORD)TO1BIT(pUiData->fUiOption, FAX_SEND), 0);
  59. SendDlgItemMessage(hDlg, IDC_CHECK_CLRNUM, BM_SETCHECK,
  60. BITTEST32(pUiData->fUiOption, HOLD_OPTIONS)? 0 : 1, 0);
  61. // initialize edit box
  62. SetDlgItemText(hDlg, IDC_EDIT_FAXNUM, pUiData->FaxNumBuf);
  63. SendDlgItemMessage(hDlg, IDC_EDIT_FAXNUM, EM_LIMITTEXT, FAXBUFSIZE256-1, 0);
  64. SetDlgItemText(hDlg, IDC_EDIT_EXTNUM, pUiData->FaxExtNumBuf);
  65. SendDlgItemMessage(hDlg, IDC_EDIT_EXTNUM, EM_LIMITTEXT, FAXEXTNUMBUFSIZE-1, 0);
  66. } //*** InitMainDlg
  67. /***************************************************************************
  68. Function Name : InitSubDlg
  69. ***************************************************************************/
  70. VOID InitSubDlg(
  71. HWND hDlg,
  72. PUIDATA pUiData)
  73. {
  74. WORD num;
  75. WCHAR wcTmp[64];
  76. // initialize edit box
  77. num = (pUiData->FaxSendTime[0] == 0)? FAXTIMEBUFSIZE : 0;
  78. SetDlgItemText(hDlg, IDC_EDIT_HOUR, pUiData->FaxSendTime);
  79. SendDlgItemMessage(hDlg, IDC_EDIT_HOUR, EM_LIMITTEXT, 2, 0);
  80. SetDlgItemText(hDlg, IDC_EDIT_MINUTE, &pUiData->FaxSendTime[3]);
  81. SendDlgItemMessage(hDlg, IDC_EDIT_MINUTE, EM_LIMITTEXT, 2, 0);
  82. // next while loop must be after SetDlgItemText(IDC_EDIT_xxx)
  83. while (num-- > 0)
  84. pUiData->FaxSendTime[num] = 0;
  85. // initialize combo box (FAX resolution, Send channel)
  86. SendDlgItemMessage(hDlg, IDC_COMBO_RESO, CB_RESETCONTENT, 0, 0);
  87. SendDlgItemMessage(hDlg, IDC_COMBO_CHANNEL, CB_RESETCONTENT, 0, 0);
  88. for (num = 0; num < 3; num++)
  89. {
  90. LoadString(ghInstance, wFaxResoStrID[num], wcTmp, 64);
  91. SendDlgItemMessage(hDlg, IDC_COMBO_RESO, CB_ADDSTRING, 0, (LPARAM)wcTmp);
  92. }
  93. for (num = 0; num < 4; num++)
  94. {
  95. LoadString(ghInstance, wFaxChStrID[num], wcTmp, 64);
  96. SendDlgItemMessage(hDlg, IDC_COMBO_CHANNEL, CB_ADDSTRING, 0, (LPARAM)wcTmp);
  97. }
  98. SendDlgItemMessage(hDlg, IDC_COMBO_RESO, CB_SETCURSEL, pUiData->FaxReso, 0);
  99. SendDlgItemMessage(hDlg, IDC_COMBO_CHANNEL, CB_SETCURSEL, pUiData->FaxCh, 0);
  100. // initialize check box (set time, set simultaneous print)
  101. if (BITTEST32(pUiData->fUiOption, FAX_SETTIME))
  102. {
  103. SendDlgItemMessage(hDlg, IDC_CHECK_TIME, BM_SETCHECK, 1, 0);
  104. }
  105. else
  106. {
  107. SendDlgItemMessage(hDlg, IDC_CHECK_TIME, BM_SETCHECK, 0, 0);
  108. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HOUR), FALSE);
  109. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MINUTE), FALSE);
  110. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_HOUR), FALSE);
  111. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_MINUTE), FALSE);
  112. }
  113. SendDlgItemMessage(hDlg, IDC_CHECK_PRINT, BM_SETCHECK,
  114. (WORD)TO1BIT(pUiData->fUiOption, FAX_SIMULPRINT), 0);
  115. // initialize radio button (send RPDL command, use MH)
  116. CheckRadioButton(hDlg, IDC_RADIO_CMD_OFF, IDC_RADIO_CMD_ON,
  117. BITTEST32(pUiData->fUiOption, FAX_RPDLCMD)?
  118. IDC_RADIO_CMD_ON:IDC_RADIO_CMD_OFF);
  119. CheckRadioButton(hDlg, IDC_RADIO_MH_OFF, IDC_RADIO_MH_ON,
  120. BITTEST32(pUiData->fUiOption, FAX_MH)?
  121. IDC_RADIO_MH_ON:IDC_RADIO_MH_OFF);
  122. } //*** InitSubDlg
  123. /***************************************************************************
  124. Function Name : StoreSubDialogInfo
  125. store option dialog infomation
  126. ***************************************************************************/
  127. VOID StoreSubDialogInfo(
  128. PUIDATA pUiData)
  129. {
  130. WORD num = FAXTIMEBUFSIZE;
  131. LPWSTR lpDst = pUiData->FaxSendTimeTmp, lpSrc = pUiData->FaxSendTime;
  132. while (num-- > 0)
  133. *lpDst++ = *lpSrc++;
  134. pUiData->FaxResoTmp = pUiData->FaxReso;
  135. pUiData->FaxChTmp = pUiData->FaxCh;
  136. pUiData->fUiOptionTmp = pUiData->fUiOption;
  137. } //*** StoreSubDialogInfo
  138. /***************************************************************************
  139. Function Name : ResumeSubDialogInfo
  140. resume option dialog infomation
  141. ***************************************************************************/
  142. VOID ResumeSubDialogInfo(
  143. PUIDATA pUiData)
  144. {
  145. WORD num = FAXTIMEBUFSIZE;
  146. LPWSTR lpDst = pUiData->FaxSendTime, lpSrc = pUiData->FaxSendTimeTmp;
  147. while (num-- > 0)
  148. *lpDst++ = *lpSrc++;
  149. pUiData->FaxReso = pUiData->FaxResoTmp;
  150. pUiData->FaxCh = pUiData->FaxChTmp;
  151. pUiData->fUiOption = pUiData->fUiOptionTmp;
  152. } //*** ResumeSubDialogInfo
  153. /***************************************************************************
  154. Function Name : GetInfoFromOEMPdev
  155. get fax data from private devmode
  156. ***************************************************************************/
  157. VOID GetInfoFromOEMPdev(PUIDATA pUiData)
  158. {
  159. POEMUD_EXTRADATA pOEMExtra = pUiData->pOEMExtra;
  160. BYTE TmpBuf[FAXTIMEBUFSIZE];
  161. // if previous fax is finished and hold-options flag isn't valid,
  162. // reset private devmode
  163. if (BITTEST32(pOEMExtra->fUiOption, PRINT_DONE) &&
  164. !BITTEST32(pOEMExtra->fUiOption, HOLD_OPTIONS))
  165. {
  166. WORD num;
  167. pOEMExtra->FaxReso = pOEMExtra->FaxCh = 0;
  168. for (num = 0; num < FAXBUFSIZE256; num++)
  169. pOEMExtra->FaxNumBuf[num] = 0;
  170. for (num = 0; num < FAXEXTNUMBUFSIZE; num++)
  171. pOEMExtra->FaxExtNumBuf[num] = 0;
  172. for (num = 0; num < FAXTIMEBUFSIZE; num++)
  173. pOEMExtra->FaxSendTime[num] = 0;
  174. BITCLR32(pOEMExtra->fUiOption, FAX_SEND);
  175. BITCLR32(pOEMExtra->fUiOption, FAX_SETTIME);
  176. BITCLR32(pOEMExtra->fUiOption, FAX_SIMULPRINT);
  177. BITCLR32(pOEMExtra->fUiOption, FAX_MH);
  178. BITCLR32(pOEMExtra->fUiOption, FAX_RPDLCMD);
  179. // do not clear PRINT_DONE flag here
  180. }
  181. // copy fax flag
  182. pUiData->fUiOption = pOEMExtra->fUiOption;
  183. // ascii to unicode
  184. // @Mar/04/2002 ->
  185. // OemToChar((LPSTR)pOEMExtra->FaxNumBuf, pUiData->FaxNumBuf);
  186. // OemToChar((LPSTR)pOEMExtra->FaxExtNumBuf, pUiData->FaxExtNumBuf);
  187. OemToCharBuff((LPSTR)pOEMExtra->FaxNumBuf, pUiData->FaxNumBuf, FAXBUFSIZE256);
  188. OemToCharBuff((LPSTR)pOEMExtra->FaxExtNumBuf, pUiData->FaxExtNumBuf, FAXEXTNUMBUFSIZE);
  189. // @Mar/04/2002 <-
  190. // modfify time string from "hhmm" to "hh"+"mm"
  191. TmpBuf[0] = pOEMExtra->FaxSendTime[0];
  192. TmpBuf[1] = pOEMExtra->FaxSendTime[1];
  193. TmpBuf[2] = TmpBuf[5] = 0;
  194. TmpBuf[3] = pOEMExtra->FaxSendTime[2];
  195. TmpBuf[4] = pOEMExtra->FaxSendTime[3];
  196. // @Mar/04/2002 ->
  197. // OemToChar((LPSTR)&TmpBuf[0], &(pUiData->FaxSendTime[0]));
  198. // OemToChar((LPSTR)&TmpBuf[3], &(pUiData->FaxSendTime[3]));
  199. OemToCharBuff((LPSTR)&TmpBuf[0], &(pUiData->FaxSendTime[0]), FAXTIMEBUFSIZE);
  200. OemToCharBuff((LPSTR)&TmpBuf[3], &(pUiData->FaxSendTime[3]), FAXTIMEBUFSIZE - 3);
  201. // @Mar/04/2002 <-
  202. pUiData->FaxReso = pOEMExtra->FaxReso;
  203. pUiData->FaxCh = pOEMExtra->FaxCh;
  204. } //*** GetInfoFromOEMPdev
  205. /***************************************************************************
  206. Function Name : SetInfoToOEMPdev
  207. set fax data to private devmode
  208. ***************************************************************************/
  209. VOID SetInfoToOEMPdev(PUIDATA pUiData)
  210. {
  211. POEMUD_EXTRADATA pOEMExtra = pUiData->pOEMExtra;
  212. BYTE TmpBuf[FAXTIMEBUFSIZE];
  213. if (!BITTEST32(pUiData->fUiOption, FAXMAINDLG_UPDATED))
  214. return;
  215. // unicode to ascii
  216. CharToOem(pUiData->FaxNumBuf, (LPSTR)pOEMExtra->FaxNumBuf);
  217. CharToOem(pUiData->FaxExtNumBuf, (LPSTR)pOEMExtra->FaxExtNumBuf);
  218. // if only main dialog is changed
  219. if (!BITTEST32(pUiData->fUiOption, FAXSUBDLG_UPDATE_APPLIED))
  220. {
  221. // copy fax flag
  222. BITCPY32(pOEMExtra->fUiOption, pUiData->fUiOption, FAX_SEND); // (dst, src, bit)
  223. BITCPY32(pOEMExtra->fUiOption, pUiData->fUiOption, HOLD_OPTIONS);
  224. BITCPY32(pOEMExtra->fUiOption, pUiData->fUiOption, PRINT_DONE); // @Sep/25/2001
  225. }
  226. // if sub dialog is also changed
  227. else
  228. {
  229. // copy fax flag
  230. pOEMExtra->fUiOption = pUiData->fUiOption;
  231. BITCLR32(pOEMExtra->fUiOption, FAXMAINDLG_UPDATED);
  232. BITCLR32(pOEMExtra->fUiOption, FAXSUBDLG_UPDATED);
  233. BITCLR32(pOEMExtra->fUiOption, FAXSUBDLG_UPDATE_APPLIED);
  234. BITCLR32(pOEMExtra->fUiOption, FAXSUBDLG_INITDONE);
  235. // modfify time string from "hh"+"mm" to "hhmm"
  236. CharToOem(&(pUiData->FaxSendTime[0]), (LPSTR)&TmpBuf[0]);
  237. CharToOem(&(pUiData->FaxSendTime[3]), (LPSTR)&TmpBuf[3]);
  238. // hour
  239. if (TmpBuf[1] == 0) // 1 number
  240. {
  241. pOEMExtra->FaxSendTime[0] = '0';
  242. pOEMExtra->FaxSendTime[1] = TmpBuf[0];
  243. }
  244. else
  245. {
  246. pOEMExtra->FaxSendTime[0] = TmpBuf[0];
  247. pOEMExtra->FaxSendTime[1] = TmpBuf[1];
  248. }
  249. // minute
  250. if (TmpBuf[3] == 0) // nothing set
  251. {
  252. pOEMExtra->FaxSendTime[2] = pOEMExtra->FaxSendTime[3] = '0';
  253. }
  254. else if (TmpBuf[4] == 0) // 1 number
  255. {
  256. pOEMExtra->FaxSendTime[2] = '0';
  257. pOEMExtra->FaxSendTime[3] = TmpBuf[3];
  258. }
  259. else
  260. {
  261. pOEMExtra->FaxSendTime[2] = TmpBuf[3];
  262. pOEMExtra->FaxSendTime[3] = TmpBuf[4];
  263. }
  264. pOEMExtra->FaxSendTime[4] = 0;
  265. pOEMExtra->FaxReso = pUiData->FaxReso;
  266. pOEMExtra->FaxCh = pUiData->FaxCh;
  267. }
  268. return;
  269. } //*** SetInfoToOEMPdev
  270. /***************************************************************************
  271. Function Name : FaxPageProc
  272. Parameters : HWND hDlg Handle of this Dialog
  273. UINT uMessage
  274. WPARAM wParam
  275. LPARAM lParam
  276. Modify Note : Make this for Win95 minidriver. Jun/05/96 Kubokura
  277. Modify. Sep/22/98 Kubokura
  278. ***************************************************************************/
  279. INT_PTR APIENTRY FaxPageProc(
  280. HWND hDlg,
  281. UINT uMessage,
  282. WPARAM wParam,
  283. LPARAM lParam)
  284. {
  285. PUIDATA pUiData;
  286. WORD fModified = FALSE;
  287. switch (uMessage)
  288. {
  289. case WM_INITDIALOG:
  290. pUiData = (PUIDATA)((LPPROPSHEETPAGE)lParam)->lParam;
  291. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pUiData);
  292. // get fax data from private devmode
  293. GetInfoFromOEMPdev(pUiData);
  294. InitMainDlg(hDlg, pUiData);
  295. BITCLR32(pUiData->fUiOption, FAXMAINDLG_UPDATED);
  296. BITCLR32(pUiData->fUiOption, FAXSUBDLG_UPDATE_APPLIED); // @Oct/02/98
  297. BITCLR32(pUiData->fUiOption, FAXSUBDLG_INITDONE); // @Sep/29/98
  298. #ifdef WINNT_40 // @Sep/02/99
  299. // Disable FAX tab options when user has no permission.
  300. if (BITTEST32(pUiData->fUiOption, UIPLUGIN_NOPERMISSION))
  301. {
  302. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXMAIN_1), FALSE);
  303. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXMAIN_2), FALSE);
  304. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXMAIN_3), FALSE);
  305. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXMAIN_4), FALSE);
  306. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_SEND), FALSE);
  307. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FAXNUM), FALSE);
  308. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_EXTNUM), FALSE);
  309. EnableWindow(GetDlgItem(hDlg, IDD_OPTION), FALSE);
  310. EnableWindow(GetDlgItem(hDlg, IDD_FAXMAIN_DEFAULT), FALSE);
  311. // @Sep/21/2001 ->
  312. // EnableWindow(GetDlgItem(hDlg, IDC_LABEL_CLRNUM), FALSE);
  313. EnableWindow(GetDlgItem(hDlg, IDC_CHECK_CLRNUM), FALSE);
  314. // @Sep/21/2001 <-
  315. }
  316. #endif // WINNT_40
  317. break;
  318. case WM_COMMAND:
  319. pUiData = (PUIDATA)GetWindowLongPtr(hDlg, DWLP_USER);
  320. switch(LOWORD(wParam))
  321. {
  322. case IDC_CHECK_SEND:
  323. if (BITTEST32(pUiData->fUiOption, FAX_SEND))
  324. BITCLR32(pUiData->fUiOption, FAX_SEND);
  325. else
  326. BITSET32(pUiData->fUiOption, FAX_SEND);
  327. SendDlgItemMessage(hDlg, IDC_CHECK_SEND, BM_SETCHECK,
  328. (WORD)TO1BIT(pUiData->fUiOption, FAX_SEND), 0);
  329. fModified = TRUE;
  330. break;
  331. case IDC_CHECK_CLRNUM:
  332. if (BITTEST32(pUiData->fUiOption, HOLD_OPTIONS))
  333. BITCLR32(pUiData->fUiOption, HOLD_OPTIONS);
  334. else
  335. BITSET32(pUiData->fUiOption, HOLD_OPTIONS);
  336. SendDlgItemMessage(hDlg, IDC_CHECK_CLRNUM, BM_SETCHECK,
  337. BITTEST32(pUiData->fUiOption, HOLD_OPTIONS)? 0 : 1, 0);
  338. fModified = TRUE;
  339. break;
  340. case IDC_EDIT_FAXNUM:
  341. {
  342. int old_len = safe_strlenW(pUiData->FaxNumBuf, FAXBUFSIZE256);
  343. GetDlgItemText(hDlg, IDC_EDIT_FAXNUM, pUiData->FaxNumBuf,
  344. FAXBUFSIZE256);
  345. if (old_len != safe_strlenW(pUiData->FaxNumBuf, FAXBUFSIZE256))
  346. fModified = TRUE;
  347. }
  348. break;
  349. case IDC_EDIT_EXTNUM:
  350. {
  351. int old_len = safe_strlenW(pUiData->FaxExtNumBuf, FAXEXTNUMBUFSIZE);
  352. GetDlgItemText(hDlg, IDC_EDIT_EXTNUM, pUiData->FaxExtNumBuf,
  353. FAXEXTNUMBUFSIZE);
  354. if (old_len != safe_strlenW(pUiData->FaxExtNumBuf, FAXEXTNUMBUFSIZE))
  355. fModified = TRUE;
  356. }
  357. break;
  358. // set option button
  359. case IDD_OPTION:
  360. if(ghInstance)
  361. {
  362. //DLGPROC lpDlgFunc = (DLGPROC)MakeProcInstance(FaxSubDialog, ghInstance); // add (DLGPROC) @Aug/30/99
  363. DialogBoxParam(ghInstance, MAKEINTRESOURCE(IDD_FAXSUB),
  364. hDlg, FaxSubDialog, (LPARAM)pUiData);
  365. // hDlg, lpDlgFunc, (LPARAM)pUiData);
  366. //FreeProcInstance(lpDlgFunc);
  367. fModified = TRUE;
  368. }
  369. break;
  370. // set defaults button
  371. case IDD_FAXMAIN_DEFAULT:
  372. pUiData->FaxNumBuf[0] =
  373. pUiData->FaxExtNumBuf[0] = 0;
  374. BITCLR32(pUiData->fUiOption, FAX_SEND);
  375. SendDlgItemMessage(hDlg, IDC_CHECK_SEND, BM_SETCHECK,
  376. (WORD)TO1BIT(pUiData->fUiOption, FAX_SEND), 0);
  377. BITCLR32(pUiData->fUiOption, HOLD_OPTIONS);
  378. SendDlgItemMessage(hDlg, IDC_CHECK_CLRNUM, BM_SETCHECK,
  379. BITTEST32(pUiData->fUiOption, HOLD_OPTIONS)? 0 : 1, 0);
  380. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_FAXNUM), TRUE);
  381. SetDlgItemText(hDlg, IDC_EDIT_FAXNUM, pUiData->FaxNumBuf);
  382. SetDlgItemText(hDlg, IDC_EDIT_EXTNUM, pUiData->FaxExtNumBuf);
  383. fModified = TRUE;
  384. break;
  385. default:
  386. return FALSE;
  387. }
  388. break;
  389. case WM_NOTIFY:
  390. pUiData = (PUIDATA)GetWindowLongPtr(hDlg, DWLP_USER);
  391. {
  392. NMHDR FAR *lpnmhdr = (NMHDR FAR *)lParam;
  393. switch (lpnmhdr->code)
  394. {
  395. WORD num;
  396. case PSN_SETACTIVE:
  397. break;
  398. // In case of PSN_KILLACTIVE, return FALSE to get PSN_APPLY.
  399. case PSN_KILLACTIVE: // this is when user pushs OK/APPLY button.(1)
  400. VERBOSE((DLLTEXT("** FaxPageProc: PSN_KILLACTIVE **\n")));
  401. BITSET32(pUiData->fUiOption, FAXMAINDLG_UPDATED); // @Sep/29/98
  402. if (BITTEST32(pUiData->fUiOption, FAXSUBDLG_UPDATED)) // @Oct/02/98
  403. BITSET32(pUiData->fUiOption, FAXSUBDLG_UPDATE_APPLIED);
  404. return FALSE;
  405. case PSN_APPLY: // this is when user pushs OK/APPLY button.(2)
  406. VERBOSE((DLLTEXT("** FaxPageProc: PSN_APPLY **\n")));
  407. // clear PRINT_DONE flag of private devmode @Oct/20/98
  408. if (BITTEST32(pUiData->fUiOption, PRINT_DONE)) // eliminate mid pOEMExtra-> @Sep/22/2000
  409. {
  410. BITCLR32(pUiData->fUiOption, PRINT_DONE); // eliminate mid pOEMExtra-> @Sep/22/2000
  411. VERBOSE(("** Delete file: %ls **\n", pUiData->pOEMExtra->SharedFileName));
  412. DeleteFile(pUiData->pOEMExtra->SharedFileName);
  413. }
  414. // set shared data to private devmode @Oct/15/98
  415. SetInfoToOEMPdev(pUiData);
  416. // update private devmode @Oct/15/98
  417. pUiData->pfnComPropSheet(pUiData->hComPropSheet,
  418. CPSFUNC_SET_RESULT,
  419. (LPARAM)pUiData->hPropPage,
  420. (LPARAM)CPSUI_OK);
  421. VERBOSE((DLLTEXT("** PSN_APPLY fUiOption=%x **\n"), pUiData->fUiOption));
  422. break;
  423. case PSN_RESET: // this is when user pushs CANCEL button
  424. VERBOSE((DLLTEXT("** FaxPageProc: PSN_RESET **\n")));
  425. break;
  426. }
  427. }
  428. break;
  429. default:
  430. return FALSE;
  431. }
  432. // activate APPLY button
  433. if (fModified)
  434. PropSheet_Changed(GetParent(hDlg), hDlg);
  435. return TRUE;
  436. } //*** FaxPageProc
  437. /***************************************************************************
  438. Function Name : FaxSubDialog
  439. Parameters : HWND hDlg Handle of this Dialog
  440. UINT uMessage
  441. WPARAM wParam
  442. LPARAM lParam
  443. Modify Note : Make this for Win95 minidriver. Jun/05/96 Kubokura
  444. Modify. Sep/22/98 Kubokura
  445. ***************************************************************************/
  446. INT_PTR APIENTRY FaxSubDialog(
  447. HWND hDlg,
  448. UINT uMessage,
  449. WPARAM wParam,
  450. LPARAM lParam)
  451. {
  452. PUIDATA pUiData;
  453. switch (uMessage)
  454. {
  455. case WM_INITDIALOG:
  456. pUiData = (PUIDATA)lParam;
  457. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pUiData);
  458. // if right after opening this dialog
  459. if (!BITTEST32(pUiData->fUiOption, FAXSUBDLG_INITDONE))
  460. {
  461. BITSET32(pUiData->fUiOption, FAXSUBDLG_INITDONE);
  462. StoreSubDialogInfo(pUiData);
  463. }
  464. else
  465. {
  466. ResumeSubDialogInfo(pUiData);
  467. }
  468. InitSubDlg(hDlg, pUiData);
  469. BITCLR32(pUiData->fUiOption, FAXSUBDLG_UPDATED);
  470. break;
  471. case WM_COMMAND:
  472. pUiData = (PUIDATA)GetWindowLongPtr(hDlg, DWLP_USER);
  473. switch(LOWORD(wParam))
  474. {
  475. WORD num;
  476. case IDC_CHECK_TIME:
  477. if (BITTEST32(pUiData->fUiOption, FAX_SETTIME))
  478. {
  479. BITCLR32(pUiData->fUiOption, FAX_SETTIME);
  480. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HOUR), FALSE);
  481. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MINUTE), FALSE);
  482. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_HOUR), FALSE);
  483. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_MINUTE), FALSE);
  484. }
  485. else
  486. {
  487. BITSET32(pUiData->fUiOption, FAX_SETTIME);
  488. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HOUR), TRUE);
  489. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MINUTE), TRUE);
  490. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_HOUR), TRUE);
  491. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_MINUTE), TRUE);
  492. }
  493. SendDlgItemMessage(hDlg, IDC_CHECK_TIME, BM_SETCHECK,
  494. (WORD)TO1BIT(pUiData->fUiOption, FAX_SETTIME), 0);
  495. break;
  496. case IDC_CHECK_PRINT:
  497. if (BITTEST32(pUiData->fUiOption, FAX_SIMULPRINT))
  498. BITCLR32(pUiData->fUiOption, FAX_SIMULPRINT);
  499. else
  500. BITSET32(pUiData->fUiOption, FAX_SIMULPRINT);
  501. SendDlgItemMessage(hDlg, IDC_CHECK_PRINT, BM_SETCHECK,
  502. (WORD)TO1BIT(pUiData->fUiOption, FAX_SIMULPRINT), 0);
  503. break;
  504. case IDC_EDIT_HOUR:
  505. {
  506. INT hour;
  507. // get hour of send time
  508. GetDlgItemText(hDlg, IDC_EDIT_HOUR, pUiData->FaxSendTime, 3);
  509. if ((hour = _wtoi(&pUiData->FaxSendTime[0])) < 10)
  510. safe_sprintfW(&pUiData->FaxSendTime[0], FAXTIMEBUFSIZE, L"0%d", hour);
  511. else if (hour > 23)
  512. safe_sprintfW(&pUiData->FaxSendTime[0], FAXTIMEBUFSIZE, L"23");
  513. }
  514. break;
  515. case IDC_EDIT_MINUTE:
  516. {
  517. INT minute;
  518. // get minute of send time
  519. GetDlgItemText(hDlg, IDC_EDIT_MINUTE, &pUiData->FaxSendTime[3], 3);
  520. if ((minute = _wtoi(&pUiData->FaxSendTime[3])) < 10)
  521. safe_sprintfW(&pUiData->FaxSendTime[3], FAXTIMEBUFSIZE, L"0%d", minute);
  522. else if (minute > 59)
  523. safe_sprintfW(&pUiData->FaxSendTime[3], FAXTIMEBUFSIZE, L"59");
  524. }
  525. break;
  526. case IDC_COMBO_RESO:
  527. if (HIWORD(wParam) == CBN_SELCHANGE)
  528. pUiData->FaxReso = (WORD)SendDlgItemMessage(hDlg, IDC_COMBO_RESO,
  529. CB_GETCURSEL, 0, 0);
  530. break;
  531. case IDC_COMBO_CHANNEL:
  532. if (HIWORD(wParam) == CBN_SELCHANGE)
  533. pUiData->FaxCh = (WORD)SendDlgItemMessage(hDlg, IDC_COMBO_CHANNEL,
  534. CB_GETCURSEL, 0, 0);
  535. // if channel is G4, disable send RPDL mode
  536. if (pUiData->FaxCh == FAXCH_G4)
  537. {
  538. BITCLR32(pUiData->fUiOption, FAX_RPDLCMD);
  539. CheckRadioButton(hDlg, IDC_RADIO_CMD_OFF, IDC_RADIO_CMD_ON,
  540. IDC_RADIO_CMD_OFF);
  541. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_CMD_OFF), FALSE);
  542. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_CMD_ON), FALSE);
  543. }
  544. else
  545. {
  546. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_CMD_OFF), TRUE);
  547. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_CMD_ON), TRUE);
  548. }
  549. break;
  550. case IDC_RADIO_CMD_OFF:
  551. BITCLR32(pUiData->fUiOption, FAX_RPDLCMD);
  552. CheckRadioButton(hDlg, IDC_RADIO_CMD_OFF, IDC_RADIO_CMD_ON,
  553. IDC_RADIO_CMD_OFF);
  554. break;
  555. case IDC_RADIO_CMD_ON:
  556. BITSET32(pUiData->fUiOption, FAX_RPDLCMD);
  557. CheckRadioButton(hDlg, IDC_RADIO_CMD_OFF, IDC_RADIO_CMD_ON,
  558. IDC_RADIO_CMD_ON);
  559. break;
  560. case IDC_RADIO_MH_OFF:
  561. BITCLR32(pUiData->fUiOption, FAX_MH);
  562. CheckRadioButton(hDlg, IDC_RADIO_MH_OFF, IDC_RADIO_MH_ON,
  563. IDC_RADIO_MH_OFF);
  564. break;
  565. case IDC_RADIO_MH_ON:
  566. BITSET32(pUiData->fUiOption, FAX_MH);
  567. CheckRadioButton(hDlg, IDC_RADIO_MH_OFF, IDC_RADIO_MH_ON,
  568. IDC_RADIO_MH_ON);
  569. break;
  570. // set defaults button
  571. case IDD_FAXSUB_DEFAULT:
  572. pUiData->FaxReso = pUiData->FaxCh = 0;
  573. BITCLR32(pUiData->fUiOption, FAX_SETTIME);
  574. BITCLR32(pUiData->fUiOption, FAX_SIMULPRINT);
  575. BITCLR32(pUiData->fUiOption, FAX_MH);
  576. BITCLR32(pUiData->fUiOption, FAX_RPDLCMD);
  577. SendDlgItemMessage(hDlg, IDC_CHECK_TIME, BM_SETCHECK,
  578. (WORD)TO1BIT(pUiData->fUiOption, FAX_SETTIME), 0);
  579. SendDlgItemMessage(hDlg, IDC_CHECK_PRINT, BM_SETCHECK,
  580. (WORD)TO1BIT(pUiData->fUiOption, FAX_SIMULPRINT), 0);
  581. SetDlgItemText(hDlg, IDC_EDIT_HOUR, NULL);
  582. SetDlgItemText(hDlg, IDC_EDIT_MINUTE, NULL);
  583. // next for loop must be after SetDlgItemText(IDC_EDIT_xxx)
  584. for (num = 0; num < FAXTIMEBUFSIZE; num++)
  585. pUiData->FaxSendTime[num] = 0;
  586. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_HOUR), FALSE);
  587. EnableWindow(GetDlgItem(hDlg, IDC_EDIT_MINUTE), FALSE);
  588. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_HOUR), FALSE);
  589. EnableWindow(GetDlgItem(hDlg, IDC_LABEL_FAXSUB_MINUTE), FALSE);
  590. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_CMD_OFF), TRUE);
  591. EnableWindow(GetDlgItem(hDlg, IDC_RADIO_CMD_ON), TRUE);
  592. SendDlgItemMessage(hDlg, IDC_COMBO_RESO, CB_SETCURSEL,
  593. pUiData->FaxReso, 0);
  594. SendDlgItemMessage(hDlg, IDC_COMBO_CHANNEL, CB_SETCURSEL,
  595. pUiData->FaxCh, 0);
  596. CheckRadioButton(hDlg, IDC_RADIO_CMD_OFF, IDC_RADIO_CMD_ON,
  597. BITTEST32(pUiData->fUiOption, FAX_RPDLCMD)?
  598. IDC_RADIO_CMD_ON:IDC_RADIO_CMD_OFF);
  599. CheckRadioButton(hDlg, IDC_RADIO_MH_OFF, IDC_RADIO_MH_ON,
  600. BITTEST32(pUiData->fUiOption, FAX_MH)?
  601. IDC_RADIO_MH_ON:IDC_RADIO_MH_OFF);
  602. break;
  603. case IDCANCEL:
  604. ResumeSubDialogInfo(pUiData);
  605. goto _OPT_END;
  606. case IDOK:
  607. StoreSubDialogInfo(pUiData);
  608. BITSET32(pUiData->fUiOption, FAXSUBDLG_UPDATED);
  609. _OPT_END:
  610. EndDialog(hDlg, wParam);
  611. break;
  612. default:
  613. return FALSE;
  614. }
  615. break;
  616. default:
  617. return FALSE;
  618. }
  619. return TRUE;
  620. } //*** FaxSubDialog
  621. } // End of extern "C"