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.

1428 lines
56 KiB

  1. /*++
  2. Copyright (c) 1996-2002 Microsoft Corp. & Ricoh Co., Ltd. All rights reserved.
  3. FILE: RPDLUI.CPP
  4. Abstract: Main file for OEM UI plugin module.
  5. Functions: OEMCommonUIProp
  6. OEMDocumentPropertySheets
  7. Environment: Windows NT Unidrv5 driver
  8. Revision History:
  9. 04/01/99 -Masatoshi Kubokura-
  10. Last modified for Windows2000.
  11. 08/30/99 -Masatoshi Kubokura-
  12. Began to modify for NT4SP6(Unidrv5.4).
  13. 09/29/99 -Masatoshi Kubokura-
  14. Last modified for NT4SP6.
  15. 05/22/2000 -Masatoshi Kubokura-
  16. V.1.03 for NT4
  17. 11/29/2000 -Masatoshi Kubokura-
  18. Last modified for XP inbox.
  19. 03/01/2002 -Masatoshi Kubokura-
  20. Include strsafe.h.
  21. Add FileNameBufSize as arg3 at RWFileData().
  22. Use safe_sprintfW() instead of wsprintfW().
  23. 03/29/2002 -Masatoshi Kubokura-
  24. Eliminate "#if 0".
  25. Use SecureZeroMemory() instead of memset(,0,)
  26. 04/03/2002 -Masatoshi Kubokura-
  27. Use safe_strlenW() instead of lstrlen().
  28. --*/
  29. #include "pdev.h"
  30. #include "resource.h"
  31. #include "rpdlui.h"
  32. #include <prsht.h>
  33. #ifndef WINNT_40
  34. #include "strsafe.h" // @Mar/01/2002
  35. #endif // !WINNT_40
  36. //#pragma setlocale(".932") // MSKK 98/7/15, OBSOLETE @Sep/19/98
  37. ////////////////////////////////////////////////////////
  38. // GLOBALS
  39. ////////////////////////////////////////////////////////
  40. HINSTANCE ghInstance = NULL;
  41. ////////////////////////////////////////////////////////
  42. // INTERNAL MACROS and DEFINES
  43. ////////////////////////////////////////////////////////
  44. #if DBG
  45. //giDebugLevel = DBG_VERBOSE;
  46. ////#define giDebugLevel DBG_VERBOSE // enable VERBOSE() in each file
  47. #endif
  48. // @Apr/04/2002 ->
  49. #define RES_ID_MASK 0xffff
  50. #define is_valid_ptr(p) (~RES_ID_MASK & (UINT_PTR)(p))
  51. // @Apr/04/2002 <-
  52. // Resource in other DLL @Sep/24/99
  53. WCHAR STR_UNIRESDLL[] = L"UNIRES.DLL";
  54. WCHAR STR_RPDLRESDLL[] = L"RPDLRES.DLL";
  55. #define UNIRES_DLL 0
  56. #define RPDLRES_DLL 1
  57. #define THIS_DLL 2
  58. // ID of UNIRES.DLL (This comes from STDNAMES.GPD.)
  59. #define IDS_UNIRES_IMAGECONTROL_DISPLAY 11112
  60. // ID of RPDLRES.DLL (This comes from RPDLRES.RC.)
  61. #define IDS_RPDLRES_COLLATETYPE 675 // @Sep/29/99
  62. WCHAR REGVAL_ACTUALNAME[] = L"Model"; // @Oct/07/98
  63. #ifndef GWMODEL // @Sep/26/2000
  64. #ifndef WINNT_40 // @Sep/01/99
  65. WCHAR HELPFILENAME[] = L"%s\\3\\RPDLCFG.HLP"; // add "\\3" @Oct/30/98
  66. #else // WINNT_40
  67. WCHAR HELPFILENAME[] = L"%s\\2\\RPDLCFG.HLP";
  68. #endif // WINNT_40
  69. #else // GWMODEL
  70. #ifndef WINNT_40
  71. WCHAR HELPFILENAME[] = L"%s\\3\\RPDLCFG2.HLP";
  72. #else // WINNT_40
  73. WCHAR HELPFILENAME[] = L"%s\\2\\RPDLCFG2.HLP";
  74. #endif // WINNT_40
  75. #endif // GWMODEL
  76. // OBSOLETE @Sep/27/99 ->
  77. //CHAR UNIDRV_FEATURE_DUPLEX[] = "Duplex";
  78. //CHAR UNIDRV_DUPLEX_NONE[] = "NONE";
  79. // @Sep/27/99 <-
  80. // OEM items: VariableScaling(1)+Barcode(2)+TOMBO(3)+Duplex(2)
  81. // (add TOMBO @Sep/15/98)
  82. #define RPDL_OEM_ITEMS 8
  83. #define ITEM_SCALING 0
  84. #define ITEM_BAR_HEIGHT 1
  85. #define ITEM_BAR_SUBFONT 2
  86. #define ITEM_TOMBO_ADD 3
  87. #define ITEM_TOMBO_ADJX 4
  88. #define ITEM_TOMBO_ADJY 5
  89. #define ITEM_BIND_MARGIN 6 // <-3 @Sep/15/98
  90. #define ITEM_BIND_RIGHT 7 // <-4 @Sep/15/98
  91. #define DMPUB_SCALING (DMPUB_USER+1+ITEM_SCALING) // 101
  92. #define DMPUB_BAR_H (DMPUB_USER+1+ITEM_BAR_HEIGHT) // 102
  93. #define DMPUB_BAR_SUBFONT (DMPUB_USER+1+ITEM_BAR_SUBFONT) // 103
  94. #define DMPUB_TOMBO_ADD (DMPUB_USER+1+ITEM_TOMBO_ADD) // 104
  95. #define DMPUB_TOMBO_ADJX (DMPUB_USER+1+ITEM_TOMBO_ADJX) // 105
  96. #define DMPUB_TOMBO_ADJY (DMPUB_USER+1+ITEM_TOMBO_ADJY) // 106
  97. #define DMPUB_BIND_MARGIN (DMPUB_USER+1+ITEM_BIND_MARGIN) // 107
  98. #define DMPUB_BIND_RIGHT (DMPUB_USER+1+ITEM_BIND_RIGHT) // 108
  99. #define LEVEL_2 2
  100. #define SEL_YES 0 // <-YES_2STATES @Sep/29/99
  101. #define SEL_NO 1 // <-NO_2STATES @Sep/29/99
  102. #define SEL_STANDARD 0 // @Sep/29/99
  103. #define SEL_DUPLEX_NONE 0 // @Sep/29/99
  104. // max string size in resource (RPDLDLG.RC)
  105. #define ITEM_STR_LEN128 128
  106. #define ITEM_STR_LEN8 8
  107. // string IDs in resource (RPDLDLG.RC)
  108. WORD wItemStrID[RPDL_OEM_ITEMS] = {
  109. IDS_RPDL_SCALING,
  110. IDS_RPDL_BAR_HEIGHT,
  111. IDS_RPDL_BAR_SUBFONT,
  112. IDS_RPDL_TOMBO_ADD,
  113. IDS_RPDL_TOMBO_ADJX,
  114. IDS_RPDL_TOMBO_ADJY,
  115. IDS_RPDL_BIND_MARGIN,
  116. IDS_RPDL_BIND_RIGHT
  117. };
  118. OPTPARAM MinMaxRangeScalingOP[] = {
  119. {
  120. sizeof(OPTPARAM), // cbSize
  121. 0, // OPTPF_xxx
  122. 0, // style
  123. __TEXT("%"), // pData (postfix)
  124. IDI_CPSUI_GENERIC_OPTION, // IconID
  125. 0 // lParam
  126. },
  127. {
  128. sizeof(OPTPARAM), // cbSize
  129. 0, // OPTPF_xxx
  130. 0, // style
  131. NULL, // pData (help line)
  132. (DWORD)VAR_SCALING_MIN, // IconID (low range)
  133. VAR_SCALING_MAX // lParam (high range)
  134. }
  135. };
  136. OPTTYPE TVOTUDArrowScalingOT = {
  137. sizeof(OPTTYPE), // cbSize
  138. TVOT_UDARROW, // Type
  139. 0, // Flags OPTTF_xxxx
  140. 2, // Count
  141. 0, // BegCtrlID
  142. MinMaxRangeScalingOP, // pOptParam
  143. 0 // Style, OTS_xxxx
  144. };
  145. OPTPARAM MinMaxRangeBarHeightOP[] = {
  146. {
  147. sizeof(OPTPARAM), // cbSize
  148. 0, // OPTPF_xxx
  149. 0, // style
  150. __TEXT("mm"), // pData (postfix)
  151. IDI_CPSUI_GENERIC_OPTION, // IconID
  152. 0 // lParam
  153. },
  154. {
  155. sizeof(OPTPARAM), // cbSize
  156. 0, // OPTPF_xxx
  157. 0, // style
  158. NULL, // pData (help line)
  159. (DWORD)BAR_H_MIN, // IconID (low range)
  160. BAR_H_MAX // lParam (high range)
  161. }
  162. };
  163. OPTTYPE TVOTUDArrowBarHeightOT = {
  164. sizeof(OPTTYPE), // cbSize
  165. TVOT_UDARROW, // Type
  166. 0, // Flags OPTTF_xxxx
  167. 2, // Count
  168. 0, // BegCtrlID
  169. MinMaxRangeBarHeightOP, // pOptParam
  170. 0 // Style, OTS_xxxx
  171. };
  172. OPTPARAM MinMaxRangeBindMarginOP[] = {
  173. {
  174. sizeof(OPTPARAM), // cbSize
  175. 0, // OPTPF_xxx
  176. 0, // style
  177. __TEXT("mm"), // pData (postfix)
  178. IDI_CPSUI_GENERIC_OPTION, // IconID
  179. 0 // lParam
  180. },
  181. {
  182. sizeof(OPTPARAM), // cbSize
  183. 0, // OPTPF_xxx
  184. 0, // style
  185. NULL, // pData (help line)
  186. (DWORD)BIND_MARGIN_MIN, // IconID (low range)
  187. BIND_MARGIN_MAX // lParam (high range)
  188. }
  189. };
  190. OPTTYPE TVOTUDArrowBindMarginOT = {
  191. sizeof(OPTTYPE), // cbSize
  192. TVOT_UDARROW, // Type
  193. 0, // Flags OPTTF_xxxx
  194. 2, // Count
  195. 0, // BegCtrlID
  196. MinMaxRangeBindMarginOP, // pOptParam
  197. 0 // Style, OTS_xxxx
  198. };
  199. // @Sep/15/98 ->
  200. OPTPARAM MinMaxRangeTOMBO_AdjXOP[] = {
  201. {
  202. sizeof(OPTPARAM), // cbSize
  203. 0, // OPTPF_xxx
  204. 0, // style
  205. __TEXT("x 0.1mm"), // pData (postfix)
  206. IDI_CPSUI_GENERIC_OPTION, // IconID
  207. 0 // lParam
  208. },
  209. {
  210. sizeof(OPTPARAM), // cbSize
  211. 0, // OPTPF_xxx
  212. 0, // style
  213. NULL, // pData (help line)
  214. (DWORD)TOMBO_ADJ_MIN, // IconID (low range)
  215. TOMBO_ADJ_MAX // lParam (high range)
  216. }
  217. };
  218. OPTTYPE TVOTUDArrowTOMBO_AdjXOT = {
  219. sizeof(OPTTYPE), // cbSize
  220. TVOT_UDARROW, // Type
  221. 0, // Flags OPTTF_xxxx
  222. 2, // Count
  223. 0, // BegCtrlID
  224. MinMaxRangeTOMBO_AdjXOP, // pOptParam
  225. 0 // Style, OTS_xxxx
  226. };
  227. OPTPARAM MinMaxRangeTOMBO_AdjYOP[] = {
  228. {
  229. sizeof(OPTPARAM), // cbSize
  230. 0, // OPTPF_xxx
  231. 0, // style
  232. __TEXT("x 0.1mm"), // pData (postfix)
  233. IDI_CPSUI_GENERIC_OPTION, // IconID
  234. 0 // lParam
  235. },
  236. {
  237. sizeof(OPTPARAM), // cbSize
  238. 0, // OPTPF_xxx
  239. 0, // style
  240. NULL, // pData (help line)
  241. (DWORD)TOMBO_ADJ_MIN, // IconID (low range)
  242. TOMBO_ADJ_MAX // lParam (high range)
  243. }
  244. };
  245. OPTTYPE TVOTUDArrowTOMBO_AdjYOT = {
  246. sizeof(OPTTYPE), // cbSize
  247. TVOT_UDARROW, // Type
  248. 0, // Flags OPTTF_xxxx
  249. 2, // Count
  250. 0, // BegCtrlID
  251. MinMaxRangeTOMBO_AdjYOP, // pOptParam
  252. 0 // Style, OTS_xxxx
  253. };
  254. // @Sep/15/98 <-
  255. OPTPARAM YesNoOP[] = {
  256. {
  257. sizeof(OPTPARAM), // cbSize
  258. 0, // OPTPF_xxx
  259. 0, // style
  260. NULL, // pData (<-IDS_CPSUI_YES MSKK Sep/11/98)
  261. // @Sep/06/99 ->
  262. // IDI_CPSUI_EMPTY, // IconID (<-IDI_CPSUI_YES @Jul/30/98)
  263. IDI_CPSUI_GENERIC_OPTION, // IconID
  264. // @Sep/06/99 <-
  265. 1 // lParam
  266. },
  267. {
  268. sizeof(OPTPARAM), // cbSize
  269. 0, // OPTPF_xxx
  270. 0, // style
  271. NULL, // pData (<-IDS_CPSUI_NO MSKK Sep/11/98)
  272. // @Sep/06/99 ->
  273. // IDI_CPSUI_EMPTY, // IconID (<-IDI_CPSUI_NO @Jul/30/98)
  274. IDI_CPSUI_GENERIC_OPTION, // IconID
  275. // @Sep/06/99 <-
  276. 0 // lParam
  277. }
  278. };
  279. OPTTYPE YesNoOT = {
  280. sizeof(OPTTYPE), // cbSize
  281. TVOT_2STATES, // Type
  282. 0, // Flags OPTTF_xxxx
  283. 2, // Count
  284. 0, // BegCtrlID
  285. YesNoOP, // pOptParam
  286. 0 // Style, OTS_xxxx
  287. };
  288. OPTITEM TVOEMUIOptItems[] = {
  289. { // Variable Scaling
  290. sizeof(OPTITEM), // cbSize(size of this structure)
  291. LEVEL_2, // Level(level in the tree view)
  292. 0, // DlgPageIdx(Index to the pDlgPage)
  293. OPTIF_CALLBACK|OPTIF_HAS_POIEXT, // add OPTIF_HAS_POIEXT @May/20/98
  294. 0, // UserData(caller's own data)
  295. __TEXT(""), // pName(name of the item)
  296. VAR_SCALING_DEFAULT, // Sel(current selection)
  297. NULL, // pExtChkBox/pExtPush
  298. &TVOTUDArrowScalingOT, // pOptType
  299. 50, // HelpIndex(Help file index) @May/20/98
  300. DMPUB_SCALING // DMPubID(Devmode public filed ID)
  301. },
  302. { // Barcode Height
  303. sizeof(OPTITEM), // cbSize(size of this structure)
  304. LEVEL_2, // Level(level in the tree view)
  305. 0, // DlgPageIdx(Index to the pDlgPage)
  306. OPTIF_CALLBACK|OPTIF_HAS_POIEXT, // add OPTIF_HAS_POIEXT
  307. 0, // UserData(caller's own data)
  308. __TEXT(""), // pName(name of the item)
  309. BAR_H_DEFAULT, // Sel(current selection)
  310. NULL, // pExtChkBox/pExtPush
  311. &TVOTUDArrowBarHeightOT, // pOptType
  312. 51, // HelpIndex(Help file index)
  313. DMPUB_BAR_H // DMPubID(Devmode public filed ID)
  314. },
  315. { // Print Barcode with Readable Characters
  316. sizeof(OPTITEM), // cbSize(size of this structure)
  317. LEVEL_2, // Level(level in the tree view)
  318. 0, // DlgPageIdx(Index to the pDlgPage)
  319. OPTIF_CALLBACK|OPTIF_HAS_POIEXT, // add OPTIF_HAS_POIEXT
  320. 0, // UserData(caller's own data)
  321. __TEXT(""), // pName(name of the item)
  322. SEL_YES, // Sel(current selection)
  323. NULL, // pExtChkBox/pExtPush
  324. &YesNoOT, // pOptType
  325. 52, // HelpIndex(Help file index)
  326. DMPUB_BAR_SUBFONT // DMPubID(Devmode public filed ID)
  327. },
  328. // @Sep/15/98 ->
  329. { // Print Crops
  330. sizeof(OPTITEM), // cbSize(size of this structure)
  331. LEVEL_2, // Level(level in the tree view)
  332. 0, // DlgPageIdx(Index to the pDlgPage)
  333. OPTIF_CALLBACK|OPTIF_HAS_POIEXT,
  334. 0, // UserData(caller's own data)
  335. __TEXT(""), // pName(name of the item)
  336. SEL_NO, // Sel(current selection)
  337. NULL, // pExtChkBox/pExtPush
  338. &YesNoOT, // pOptType
  339. 55, // HelpIndex(Help file index)
  340. DMPUB_TOMBO_ADD // DMPubID(Devmode public filed ID)
  341. },
  342. { // Adjust Horizontal Distance of Crops
  343. sizeof(OPTITEM), // cbSize(size of this structure)
  344. LEVEL_2, // Level(level in the tree view)
  345. 0, // DlgPageIdx(Index to the pDlgPage)
  346. OPTIF_CALLBACK|OPTIF_HAS_POIEXT,
  347. 0, // UserData(caller's own data)
  348. __TEXT(""), // pName(name of the item)
  349. DEFAULT_0, // Sel(current selection)
  350. NULL, // pExtChkBox/pExtPush
  351. &TVOTUDArrowTOMBO_AdjXOT, // pOptType
  352. 56, // HelpIndex(Help file index)
  353. DMPUB_TOMBO_ADJX // DMPubID(Devmode public filed ID)
  354. },
  355. { // Adjust Vertical Distance of Crops
  356. sizeof(OPTITEM), // cbSize(size of this structure)
  357. LEVEL_2, // Level(level in the tree view)
  358. 0, // DlgPageIdx(Index to the pDlgPage)
  359. OPTIF_CALLBACK|OPTIF_HAS_POIEXT,
  360. 0, // UserData(caller's own data)
  361. __TEXT(""), // pName(name of the item)
  362. DEFAULT_0, // Sel(current selection)
  363. NULL, // pExtChkBox/pExtPush
  364. &TVOTUDArrowTOMBO_AdjYOT, // pOptType
  365. 57, // HelpIndex(Help file index)
  366. DMPUB_TOMBO_ADJY // DMPubID(Devmode public filed ID)
  367. },
  368. // @Sep/15/98 <-
  369. { // Binding Margin
  370. sizeof(OPTITEM), // cbSize(size of this structure)
  371. LEVEL_2, // Level(level in the tree view)
  372. 0, // DlgPageIdx(Index to the pDlgPage)
  373. OPTIF_CALLBACK|OPTIF_HAS_POIEXT, // add OPTIF_HAS_POIEXT
  374. 0, // UserData(caller's own data)
  375. __TEXT(""), // pName(name of the item)
  376. DEFAULT_0, // Sel(current selection) (0->DEFAULT_0 @Sep/15/98)
  377. NULL, // pExtChkBox/pExtPush
  378. &TVOTUDArrowBindMarginOT, // pOptType
  379. 53, // HelpIndex(Help file index)
  380. DMPUB_BIND_MARGIN // DMPubID(Devmode public filed ID)
  381. },
  382. { // Bind Right Side if Possible
  383. sizeof(OPTITEM), // cbSize(size of this structure)
  384. LEVEL_2, // Level(level in the tree view)
  385. 0, // DlgPageIdx(Index to the pDlgPage)
  386. OPTIF_CALLBACK|OPTIF_HAS_POIEXT, // add OPTIF_HAS_POIEXT
  387. 0, // UserData(caller's own data)
  388. __TEXT(""), // pName(name of the item)
  389. SEL_NO, // Sel(current selection)
  390. NULL, // pExtChkBox/pExtPush
  391. &YesNoOT, // pOptType
  392. 54, // HelpIndex(Help file index)
  393. DMPUB_BIND_RIGHT // DMPubID(Devmode public filed ID)
  394. }
  395. };
  396. ////////////////////////////////////////////////////////
  397. // EXTERNAL
  398. ////////////////////////////////////////////////////////
  399. extern "C" {
  400. #ifndef GWMODEL
  401. extern INT_PTR CALLBACK FaxPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  402. #endif // !GWMODEL
  403. #ifdef JOBLOGSUPPORT_DLG
  404. extern INT_PTR CALLBACK JobPageProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  405. #endif // JOBLOGSUPPORT_DLG
  406. // @Mar/01/2002 ->
  407. //extern BOOL RWFileData(PFILEDATA pFileData, LPWSTR pwszFileName, LONG type);
  408. extern BOOL RWFileData(PFILEDATA pFileData, LPWSTR pwszFileName, LONG FileNameBufSize, LONG type);
  409. extern INT safe_sprintfW(wchar_t* pszDest, size_t cchDest, const wchar_t* pszFormat, ...);
  410. // @Mar/01/2002 <-
  411. }
  412. ////////////////////////////////////////////////////////
  413. // INTERNAL PROTOTYPES
  414. ////////////////////////////////////////////////////////
  415. LONG APIENTRY DOCPROP_CallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam);
  416. #ifdef DISKLESSMODEL
  417. LONG APIENTRY PRNPROP_CallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam);
  418. #endif // DISKLESSMODEL
  419. INT SearchItemByName(POPTITEM pOptItem, WORD cOptItem, UINT uiResDLL, UINT uiResID);
  420. INT SearchItemByID(POPTITEM pOptItem, WORD cOptItem, BYTE DMPubID);
  421. BOOL IsValidDuplex(POEMCUIPPARAM pOEMUIParam);
  422. // Need to export these functions as c declarations.
  423. extern "C" {
  424. //////////////////////////////////////////////////////////////////////////
  425. // Function: safe_strlenW
  426. //////////////////////////////////////////////////////////////////////////
  427. INT safe_strlenW(wchar_t* psz, size_t cchMax)
  428. {
  429. #ifndef WINNT_40
  430. HRESULT hr;
  431. size_t cch = 0;
  432. hr = StringCchLengthW(psz, cchMax, &cch);
  433. VERBOSE(("** safe_strlenW: size(lstrlen)=%d **\n", lstrlen(psz)));
  434. VERBOSE(("** safe_strlenW: size(StringCchLength)=%d **\n", cch));
  435. if (SUCCEEDED(hr))
  436. return cch;
  437. else
  438. return 0;
  439. #else // WINNT_40
  440. return lstrlenW(psz);
  441. #endif // WINNT_40
  442. } //*** safe_strlenW
  443. //////////////////////////////////////////////////////////////////////////
  444. // Function: DllMain
  445. //
  446. // Description: Dll entry point for initialization..
  447. //
  448. //////////////////////////////////////////////////////////////////////////
  449. BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved)
  450. {
  451. VERBOSE((DLLTEXT("** enter DllMain **\n")));
  452. switch(wReason)
  453. {
  454. case DLL_PROCESS_ATTACH:
  455. VERBOSE((DLLTEXT("** Process attach. **\n")));
  456. // Save DLL instance for use later.
  457. ghInstance = hInst;
  458. break;
  459. case DLL_THREAD_ATTACH:
  460. VERBOSE((DLLTEXT("Thread attach.\n")));
  461. break;
  462. case DLL_PROCESS_DETACH:
  463. VERBOSE((DLLTEXT("Process detach.\n")));
  464. break;
  465. case DLL_THREAD_DETACH:
  466. VERBOSE((DLLTEXT("Thread detach.\n")));
  467. break;
  468. }
  469. return TRUE;
  470. } //*** DllMain
  471. //////////////////////////////////////////////////////////////////////////
  472. // Function: OEMCommonUIProp
  473. //////////////////////////////////////////////////////////////////////////
  474. BOOL APIENTRY OEMCommonUIProp(DWORD dwMode, POEMCUIPPARAM pOEMUIParam)
  475. {
  476. POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pOEMUIParam); // @Oct/06/98
  477. #if DBG
  478. LPCSTR OEMCommonUIProp_Mode[] = {
  479. "Bad Index",
  480. "OEMCUIP_DOCPROP",
  481. "OEMCUIP_PRNPROP",
  482. };
  483. giDebugLevel = DBG_VERBOSE;
  484. VERBOSE((DLLTEXT("OEMCommonUI(%s) entry. cOEMOptItems=%d\n"),
  485. OEMCommonUIProp_Mode[dwMode], pOEMUIParam->cOEMOptItems));
  486. #endif // DBG
  487. // Sep/26/2000 ->
  488. // // if called from DrvDevicePropertySheets, exit @Dec/26/97
  489. // if (OEMCUIP_PRNPROP == dwMode)
  490. // {
  491. // pOEMUIParam->cOEMOptItems = 0;
  492. // return TRUE;
  493. // }
  494. // // Validate parameters.
  495. // if((OEMCUIP_DOCPROP != dwMode) || !IsValidOEMUIParam(dwMode, pOEMUIParam))
  496. // {
  497. //#if DBG
  498. // ERR((DLLTEXT("OEMCommonUI() ERROR_INVALID_PARAMETER.\n"
  499. // "\tdwMode = %d, pOEMUIParam = %#lx.\n"),
  500. // dwMode, pOEMUIParam));
  501. // DumpOEMUIParam(dwMode, pOEMUIParam);
  502. //#endif // DBG
  503. // // Return invalid parameter error.
  504. // SetLastError(ERROR_INVALID_PARAMETER);
  505. // return FALSE;
  506. // }
  507. // Sep/26/2000 <-
  508. if(NULL == pOEMUIParam->pOEMOptItems) // The first call
  509. {
  510. DWORD dwSize;
  511. WCHAR wchNameBuf[64];
  512. VERBOSE((DLLTEXT(" The 1st call.\n")));
  513. // Sep/22/2000 ->
  514. if (OEMCUIP_PRNPROP == dwMode)
  515. {
  516. #ifndef DISKLESSMODEL
  517. pOEMUIParam->cOEMOptItems = 0;
  518. #else // DISKLESSMODEL
  519. pOEMUIParam->cOEMOptItems = 1; // dummy item
  520. #endif // DISKLESSMODEL
  521. return TRUE;
  522. }
  523. // Sep/22/2000 <-
  524. // Return number of requested tree view items to add.
  525. pOEMUIParam->cOEMOptItems = RPDL_OEM_ITEMS;
  526. // Clear flag of printer capability.
  527. BITCLR_UPPER_FLAG(pOEMExtra->fUiOption);
  528. // Get actual printer name (completely modify @Oct/07/98)
  529. if (ERROR_SUCCESS == GetPrinterDataW(pOEMUIParam->hPrinter, REGVAL_ACTUALNAME,
  530. NULL, (LPBYTE)wchNameBuf, 64, &dwSize))
  531. {
  532. WORD wCnt;
  533. // Check printer capability from actual printer name.
  534. for (wCnt = 0; UniqueModel[wCnt].fCapability ; wCnt++)
  535. {
  536. if (!lstrcmpW(wchNameBuf, UniqueModel[wCnt].Name))
  537. {
  538. VERBOSE((DLLTEXT("** UNIQUE MODEL:%ls **\n"), wchNameBuf));
  539. pOEMExtra->fUiOption |= UniqueModel[wCnt].fCapability;
  540. break;
  541. }
  542. }
  543. #ifdef GWMODEL // @Sep/21/2000
  544. pOEMExtra->fUiOption |= BIT(OPT_VARIABLE_SCALING);
  545. #endif // GWMODEL
  546. }
  547. }
  548. else // The second call
  549. {
  550. POPTITEM pItemDst, pItemSrc;
  551. WORD wCount;
  552. WCHAR DrvDirName[MAX_PATH]; // MAX_PATH=260
  553. DWORD dwSize;
  554. LPTSTR pHelpFile;
  555. POPTPARAM lpYNParam ; // MSKK Sep/11/98
  556. POPTPARAM lpYesParam, lpNoParam ; // @Sep/19/98
  557. // @Sep/24/99 ->
  558. POPTITEM pOptItem;
  559. INT iNum;
  560. // @Sep/24/99 <-
  561. VERBOSE((DLLTEXT(" The 2nd call.\n")));
  562. // Sep/26/2000 ->
  563. if (0 == pOEMUIParam->cOEMOptItems)
  564. return TRUE;
  565. // Sep/26/2000 <-
  566. // Sep/22/2000 ->
  567. // fill out data for dummy item to call PRNPROP_CallBack
  568. if (OEMCUIP_PRNPROP == dwMode)
  569. {
  570. #ifdef DISKLESSMODEL
  571. POPTITEM pOptItem = pOEMUIParam->pOEMOptItems;
  572. pOptItem->cbSize = sizeof(OPTITEM);
  573. pOptItem->Level = 2; // Level 2
  574. pOptItem->pName = NULL;
  575. pOptItem->pOptType = NULL;
  576. pOptItem->DMPubID = DMPUB_NONE;
  577. pOptItem->Flags = OPTIF_HIDE | OPTIF_CALLBACK; // invisible and with callback
  578. pOEMUIParam->OEMCUIPCallback = PRNPROP_CallBack;
  579. #endif // DISKLESSMODEL
  580. return TRUE;
  581. }
  582. // Sep/22/2000 <-
  583. // Init OEMOptItmes.
  584. // Use SecureZeroMemory @Mar/29/2002 ->
  585. #if defined(WINNT_40) || defined(RICOH_RELEASE)
  586. memset(pOEMUIParam->pOEMOptItems, 0, sizeof(OPTITEM) * pOEMUIParam->cOEMOptItems);
  587. #else
  588. SecureZeroMemory(pOEMUIParam->pOEMOptItems, sizeof(OPTITEM) * pOEMUIParam->cOEMOptItems);
  589. #endif
  590. // Mar/29/2002 <-
  591. // Get printerdriver directory where help file is.
  592. pHelpFile = NULL;
  593. dwSize = sizeof(DrvDirName);
  594. if (GetPrinterDriverDirectoryW(NULL, NULL, 1, (PBYTE)DrvDirName, dwSize, &dwSize))
  595. {
  596. dwSize += sizeof(HELPFILENAME);
  597. pHelpFile = (LPTSTR)HeapAlloc(pOEMUIParam->hOEMHeap, HEAP_ZERO_MEMORY, dwSize);
  598. if (pHelpFile) { // 392060: PREFIX
  599. safe_sprintfW(pHelpFile, dwSize / sizeof(WCHAR), HELPFILENAME, DrvDirName);
  600. VERBOSE((DLLTEXT("** PrintDriverDir:size=%d, %ls **\n"), dwSize, pHelpFile));
  601. }
  602. }
  603. // Fill out tree view items.
  604. // wCount 0:VariableScaling, 1,2:Barcode, 3-5:TOMBO 6,7:Duplex
  605. for (wCount = 0; wCount < pOEMUIParam->cOEMOptItems; wCount++)
  606. {
  607. pItemDst = &(pOEMUIParam->pOEMOptItems[wCount]);
  608. pItemSrc = &(TVOEMUIOptItems[wCount]);
  609. pItemDst->cbSize = pItemSrc->cbSize;
  610. pItemDst->Level = pItemSrc->Level;
  611. pItemDst->Flags = pItemSrc->Flags;
  612. pItemDst->pName = (LPTSTR)HeapAlloc(pOEMUIParam->hOEMHeap,
  613. HEAP_ZERO_MEMORY, ITEM_STR_LEN128);
  614. LoadString(ghInstance, wItemStrID[wCount], pItemDst->pName, ITEM_STR_LEN128);
  615. pItemDst->pOptType = pItemSrc->pOptType;
  616. pItemDst->DMPubID = pItemSrc->DMPubID;
  617. if (pHelpFile)
  618. {
  619. // enable help
  620. pItemDst->HelpIndex = pItemSrc->HelpIndex;
  621. pItemDst->pOIExt = (POIEXT)HeapAlloc(pOEMUIParam->hOEMHeap, HEAP_ZERO_MEMORY,
  622. sizeof(OIEXT));
  623. if (pItemDst->pOIExt) { // 392061: PREFIX
  624. pItemDst->pOIExt->cbSize = sizeof(OIEXT);
  625. // set help file name
  626. pItemDst->pOIExt->pHelpFile = pHelpFile;
  627. }
  628. }
  629. }
  630. // Set strings "Yes"/"No" at item options (MSKK Sep/11/98, LoadString @Sep/19/98)
  631. // at ITEM_BAR_SUBFONT
  632. lpYesParam = pOEMUIParam->pOEMOptItems[ITEM_BAR_SUBFONT].pOptType->pOptParam;
  633. lpYesParam->pData = (LPTSTR)HeapAlloc(pOEMUIParam->hOEMHeap,
  634. HEAP_ZERO_MEMORY, ITEM_STR_LEN8);
  635. LoadString(ghInstance, IDS_RPDL_YES, lpYesParam->pData, ITEM_STR_LEN8);
  636. lpNoParam = lpYesParam + 1;
  637. lpNoParam->pData = (LPTSTR)HeapAlloc(pOEMUIParam->hOEMHeap,
  638. HEAP_ZERO_MEMORY, ITEM_STR_LEN8);
  639. LoadString(ghInstance, IDS_RPDL_NO, lpNoParam->pData, ITEM_STR_LEN8);
  640. // at ITEM_TOMBO_ADD @Sep/15/98
  641. lpYNParam = pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADD].pOptType->pOptParam;
  642. lpYNParam->pData = lpYesParam->pData;
  643. (lpYNParam+1)->pData = lpNoParam->pData;
  644. // at ITEM_BIND_RIGHT
  645. lpYNParam = pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].pOptType->pOptParam;
  646. lpYNParam->pData = lpYesParam->pData;
  647. (lpYNParam+1)->pData = lpNoParam->pData;
  648. // Initialize options
  649. if (BITTEST32(pOEMExtra->fUiOption, OPT_VARIABLE_SCALING)) // @Apr/20/98
  650. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Sel = (LONG)pOEMExtra->UiScale;
  651. else
  652. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags |= OPTIF_HIDE;
  653. // @Sep/24/99 ->
  654. // If ImageControl isn't set to "Standard", disable Scaling.
  655. iNum = SearchItemByName((pOptItem = pOEMUIParam->pDrvOptItems),
  656. (WORD)pOEMUIParam->cDrvOptItems,
  657. UNIRES_DLL, IDS_UNIRES_IMAGECONTROL_DISPLAY);
  658. if (0 <= iNum && SEL_STANDARD != (pOptItem+iNum)->Sel)
  659. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags |= OPTIF_DISABLED;
  660. // @Sep/24/99 <-
  661. pOEMUIParam->pOEMOptItems[ITEM_BAR_HEIGHT].Sel = (LONG)pOEMExtra->UiBarHeight;
  662. if (BITTEST32(pOEMExtra->fUiOption, DISABLE_BAR_SUBFONT))
  663. pOEMUIParam->pOEMOptItems[ITEM_BAR_SUBFONT].Sel = SEL_NO;
  664. else
  665. pOEMUIParam->pOEMOptItems[ITEM_BAR_SUBFONT].Sel = SEL_YES;
  666. // @Sep/16/98 ->
  667. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_TOMBO))
  668. {
  669. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADD].Sel = SEL_YES;
  670. }
  671. else
  672. {
  673. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADD].Sel = SEL_NO;
  674. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags |= OPTIF_DISABLED;
  675. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags |= OPTIF_DISABLED;
  676. }
  677. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Sel = (LONG)pOEMExtra->nUiTomboAdjX;
  678. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Sel = (LONG)pOEMExtra->nUiTomboAdjY;
  679. // @Sep/16/98 <-
  680. if (BITTEST32(pOEMExtra->fUiOption, OPT_NODUPLEX)) // @Apr/20/98
  681. {
  682. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags |= OPTIF_HIDE;
  683. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags |= OPTIF_HIDE;
  684. }
  685. else
  686. {
  687. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Sel = (LONG)pOEMExtra->UiBindMargin;
  688. if (BITTEST32(pOEMExtra->fUiOption, ENABLE_BIND_RIGHT))
  689. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Sel = SEL_YES;
  690. else
  691. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Sel = SEL_NO;
  692. if (!IsValidDuplex(pOEMUIParam))
  693. {
  694. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags |= OPTIF_DISABLED;
  695. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags |= OPTIF_DISABLED;
  696. }
  697. }
  698. pOEMUIParam->OEMCUIPCallback = DOCPROP_CallBack;
  699. }
  700. return TRUE;
  701. } //*** OEMCommonUIProp
  702. } // End of extern "C"
  703. LONG APIENTRY DOCPROP_CallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam)
  704. {
  705. LONG Action = CPSUICB_ACTION_NONE;
  706. // @Sep/24/99 ->
  707. POPTITEM pOptItem;
  708. INT iNum;
  709. DWORD dwPrevFlags;
  710. // @Sep/24/99 <-
  711. #if DBG
  712. VERBOSE((DLLTEXT("DOCPROP_CallBack() entry.\n")));
  713. switch (pCallbackParam->Reason)
  714. {
  715. case CPSUICB_REASON_SEL_CHANGED:
  716. VERBOSE((DLLTEXT(" CPSUICB_REASON_SEL_CHANGED\n"))); break;
  717. case CPSUICB_REASON_PUSHBUTTON:
  718. VERBOSE((DLLTEXT(" CPSUICB_REASON_PUSHBUTTON\n"))); break;
  719. case CPSUICB_REASON_DLGPROC:
  720. VERBOSE((DLLTEXT(" CPSUICB_REASON_DLGPROC\n"))); break;
  721. case CPSUICB_REASON_UNDO_CHANGES:
  722. VERBOSE((DLLTEXT(" CPSUICB_REASON_UNDO_CHANGES\n"))); break;
  723. case CPSUICB_REASON_EXTPUSH:
  724. VERBOSE((DLLTEXT(" CPSUICB_REASON_EXTPUSH\n"))); break;
  725. case CPSUICB_REASON_APPLYNOW:
  726. VERBOSE((DLLTEXT(" CPSUICB_REASON_APPLYNOW\n"))); break;
  727. case CPSUICB_REASON_OPTITEM_SETFOCUS:
  728. VERBOSE((DLLTEXT(" CPSUICB_REASON_OPTITEM_SETFOCUS\n"))); break;
  729. case CPSUICB_REASON_ITEMS_REVERTED:
  730. VERBOSE((DLLTEXT(" CPSUICB_REASON_ITEMS_REVERTED\n"))); break;
  731. case CPSUICB_REASON_ABOUT:
  732. VERBOSE((DLLTEXT(" CPSUICB_REASON_ABOUT\n"))); break;
  733. }
  734. VERBOSE((DLLTEXT(" DMPubID=%d, Sel=%d, Flags=%x\n"),
  735. pCallbackParam->pCurItem->DMPubID,
  736. pCallbackParam->pCurItem->Sel,
  737. pCallbackParam->pCurItem->Flags));
  738. #endif // DBG
  739. switch (pCallbackParam->Reason)
  740. {
  741. case CPSUICB_REASON_OPTITEM_SETFOCUS:
  742. // @May/22/2000 ->
  743. #ifdef WINNT_40
  744. // If collate check box exists (i.e. printer collate is available),
  745. // set dmCollate.
  746. // Search Copies&Collate item
  747. if ((iNum = SearchItemByID((pOptItem = pOEMUIParam->pDrvOptItems),
  748. (WORD)pOEMUIParam->cDrvOptItems,
  749. DMPUB_COPIES_COLLATE)) >= 0)
  750. {
  751. if ((pOptItem+iNum)->pExtChkBox && pOEMUIParam->pPublicDM)
  752. {
  753. pOEMUIParam->pPublicDM->dmCollate = DMCOLLATE_TRUE;
  754. pOEMUIParam->pPublicDM->dmFields |= DM_COLLATE;
  755. }
  756. }
  757. #endif // WINNT_40
  758. // @May/22/2000 <-
  759. break;
  760. case CPSUICB_REASON_SEL_CHANGED:
  761. // if duplex setting is changed
  762. if (DMPUB_DUPLEX == pCallbackParam->pCurItem->DMPubID)
  763. {
  764. // if duplex is disabled
  765. if (!IsValidDuplex(pOEMUIParam))
  766. {
  767. // disable ITEM_BIND_xxx.
  768. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags |= OPTIF_DISABLED;
  769. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags |= OPTIF_DISABLED;
  770. }
  771. else
  772. {
  773. // enable ITEM_BIND_xxx.
  774. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags &= ~OPTIF_DISABLED;
  775. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags &= ~OPTIF_DISABLED;
  776. }
  777. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags |= OPTIF_CHANGED;
  778. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags |= OPTIF_CHANGED;
  779. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  780. // OBSOLETE @Sep/24/99 ->
  781. // break; // @Sep/16/98
  782. // @Sep/24/99 <-
  783. }
  784. // @Sep/16/98 ->
  785. // if TOMBO_ADD setting is changed
  786. if (DMPUB_TOMBO_ADD == pCallbackParam->pCurItem->DMPubID)
  787. {
  788. // if TOMBO is enabled
  789. if (SEL_YES == pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADD].Sel)
  790. {
  791. // enable ITEM_TOMBO_ADJX/Y.
  792. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags &= ~OPTIF_DISABLED;
  793. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags &= ~OPTIF_DISABLED;
  794. }
  795. else
  796. {
  797. // disable ITEM_TOMBO_ADJX/Y.
  798. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags |= OPTIF_DISABLED;
  799. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags |= OPTIF_DISABLED;
  800. }
  801. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags |= OPTIF_CHANGED;
  802. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags |= OPTIF_CHANGED;
  803. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  804. // OBSOLETE @Sep/24/99 ->
  805. // break;
  806. // @Sep/24/99 <-
  807. }
  808. // @Sep/16/98 <-
  809. // @Sep/24/99 ->
  810. // If ImageControl isn't set to "Standard", disable Scaling.
  811. dwPrevFlags = pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags;
  812. iNum = SearchItemByName((pOptItem = pOEMUIParam->pDrvOptItems),
  813. (WORD)pOEMUIParam->cDrvOptItems,
  814. UNIRES_DLL, IDS_UNIRES_IMAGECONTROL_DISPLAY);
  815. if (0 <= iNum && SEL_STANDARD != (pOptItem+iNum)->Sel)
  816. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags |= OPTIF_DISABLED;
  817. else
  818. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags &= ~OPTIF_DISABLED;
  819. if (pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags != dwPrevFlags)
  820. {
  821. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags |= OPTIF_CHANGED;
  822. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  823. }
  824. // @Sep/24/99 <-
  825. break;
  826. case CPSUICB_REASON_APPLYNOW:
  827. {
  828. POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pOEMUIParam); // @Oct/06/98
  829. if (BITTEST32(pOEMExtra->fUiOption, OPT_VARIABLE_SCALING))
  830. pOEMExtra->UiScale = (WORD)pOEMUIParam->pOEMOptItems[ITEM_SCALING].Sel;
  831. else
  832. pOEMExtra->UiScale = VAR_SCALING_DEFAULT;
  833. pOEMExtra->UiBarHeight = (WORD)pOEMUIParam->pOEMOptItems[ITEM_BAR_HEIGHT].Sel;
  834. if (SEL_YES == pOEMUIParam->pOEMOptItems[ITEM_BAR_SUBFONT].Sel)
  835. BITCLR32(pOEMExtra->fUiOption, DISABLE_BAR_SUBFONT);
  836. else
  837. BITSET32(pOEMExtra->fUiOption, DISABLE_BAR_SUBFONT);
  838. // @Sep/16/98 ->
  839. if (SEL_YES == pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADD].Sel)
  840. BITSET32(pOEMExtra->fUiOption, ENABLE_TOMBO);
  841. else
  842. BITCLR32(pOEMExtra->fUiOption, ENABLE_TOMBO);
  843. pOEMExtra->nUiTomboAdjX = (SHORT)pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Sel;
  844. pOEMExtra->nUiTomboAdjY = (SHORT)pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Sel;
  845. // @Sep/16/98 <-
  846. if (!BITTEST32(pOEMExtra->fUiOption, OPT_NODUPLEX))
  847. {
  848. pOEMExtra->UiBindMargin = (WORD)pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Sel;
  849. if (SEL_YES == pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Sel)
  850. BITSET32(pOEMExtra->fUiOption, ENABLE_BIND_RIGHT);
  851. else
  852. BITCLR32(pOEMExtra->fUiOption, ENABLE_BIND_RIGHT);
  853. }
  854. }
  855. Action = CPSUICB_ACTION_ITEMS_APPLIED;
  856. break;
  857. case CPSUICB_REASON_ITEMS_REVERTED:
  858. // @Sep/16/98 ->
  859. if (!BITTEST32(MINIPRIVATE_DM(pOEMUIParam)->fUiOption, OPT_NODUPLEX))
  860. {
  861. // if duplex is enabled
  862. if (IsValidDuplex(pOEMUIParam))
  863. {
  864. // enable ITEM_BIND_xxx.
  865. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags &= ~OPTIF_DISABLED;
  866. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags &= ~OPTIF_DISABLED;
  867. }
  868. else
  869. {
  870. // disable ITEM_BIND_xxx.
  871. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags |= OPTIF_DISABLED;
  872. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags |= OPTIF_DISABLED;
  873. }
  874. pOEMUIParam->pOEMOptItems[ITEM_BIND_MARGIN].Flags |= OPTIF_CHANGED;
  875. pOEMUIParam->pOEMOptItems[ITEM_BIND_RIGHT].Flags |= OPTIF_CHANGED;
  876. }
  877. // if TOMBO is enabled
  878. if (SEL_YES == pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADD].Sel)
  879. {
  880. // enable ITEM_TOMBO_ADJX/Y.
  881. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags &= ~OPTIF_DISABLED;
  882. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags &= ~OPTIF_DISABLED;
  883. }
  884. else
  885. {
  886. // disable ITEM_TOMBO_ADJX/Y.
  887. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags |= OPTIF_DISABLED;
  888. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags |= OPTIF_DISABLED;
  889. }
  890. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJX].Flags |= OPTIF_CHANGED;
  891. pOEMUIParam->pOEMOptItems[ITEM_TOMBO_ADJY].Flags |= OPTIF_CHANGED;
  892. // @Sep/24/99 ->
  893. // If ImageControl isn't set to "Standard", disable Scaling.
  894. iNum = SearchItemByName((pOptItem = pOEMUIParam->pDrvOptItems),
  895. (WORD)pOEMUIParam->cDrvOptItems,
  896. UNIRES_DLL, IDS_UNIRES_IMAGECONTROL_DISPLAY);
  897. if (0 <= iNum && SEL_STANDARD != (pOptItem+iNum)->Sel)
  898. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags |= OPTIF_DISABLED;
  899. else
  900. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags &= ~OPTIF_DISABLED;
  901. pOEMUIParam->pOEMOptItems[ITEM_SCALING].Flags |= OPTIF_CHANGED;
  902. // @Sep/24/99 <-
  903. Action = CPSUICB_ACTION_OPTIF_CHANGED;
  904. // @Sep/16/98 <-
  905. break;
  906. }
  907. return Action;
  908. } //*** DOCPROP_CallBack
  909. // @Sep/22/2000 ->
  910. #ifdef DISKLESSMODEL
  911. LONG APIENTRY PRNPROP_CallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam)
  912. {
  913. LONG Action = CPSUICB_ACTION_NONE;
  914. #if DBG
  915. giDebugLevel = DBG_VERBOSE;
  916. #endif // DBG
  917. VERBOSE((DLLTEXT("PRNPROP_CallBack() entry.\n")));
  918. switch (pCallbackParam->Reason)
  919. {
  920. case CPSUICB_REASON_APPLYNOW:
  921. Action = CPSUICB_ACTION_ITEMS_APPLIED;
  922. {
  923. POPTITEM pOptItem;
  924. WCHAR wcHDName[ITEM_STR_LEN128];
  925. INT iCnt2;
  926. INT iCnt = ITEM_HARDDISK_NAMES;
  927. INT cOptItem = (INT)pOEMUIParam->cDrvOptItems;
  928. UINT uID = IDS_ITEM_HARDDISK;
  929. BYTE ValueData = 0; // We suppose Hard Disk isn't installed as default.
  930. // Check item name with several candidate ("HDD", "Memory / HDD",...).
  931. while (iCnt-- > 0)
  932. {
  933. // yasho's point-out @Nov/29/2000 ->
  934. // LoadString(ghInstance, uID, wcHDName, sizeof(wcHDName));
  935. LoadString(ghInstance, uID, wcHDName, sizeof(wcHDName) / sizeof(*wcHDName));
  936. uID++;
  937. // @Nov/29/2000 <-
  938. pOptItem = pOEMUIParam->pDrvOptItems;
  939. for (iCnt2 = 0; iCnt2 < cOptItem; iCnt2++, pOptItem++)
  940. {
  941. VERBOSE((DLLTEXT("%d: %ls\n"), iCnt2, pOptItem->pName));
  942. // @Apr/04/2002 ->
  943. // if (lstrlen(pOptItem->pName))
  944. if (is_valid_ptr(pOptItem->pName) && safe_strlenW(pOptItem->pName, ITEM_STR_LEN128))
  945. // @Apr/04/2002 <-
  946. {
  947. // Is item name same as "Hard Disk" or something like?
  948. if (!lstrcmp(pOptItem->pName, wcHDName))
  949. {
  950. // if Hard Disk is installed, value will be 1
  951. ValueData = (BYTE)(pOptItem->Sel % 2);
  952. goto _CHECKNAME_FINISH;
  953. }
  954. }
  955. }
  956. }
  957. _CHECKNAME_FINISH:
  958. // Because pOEMUIParam->pOEMDM (pointer to private devmode) is NULL when
  959. // DrvDevicePropertySheets calls this callback, we use registry.
  960. SetPrinterData(pOEMUIParam->hPrinter, REG_HARDDISK_INSTALLED, REG_BINARY,
  961. (PBYTE)&ValueData, sizeof(BYTE));
  962. }
  963. break;
  964. }
  965. return Action;
  966. } //*** PRNPROP_CallBack
  967. #endif // DISKLESSMODEL
  968. // @Sep/22/2000 <-
  969. // @Sep/24/99 ->
  970. //////////////////////////////////////////////////////////////////////////
  971. // Function: SearchItemByName
  972. //
  973. // Description: Search option item, whose DMPubID == 0, by name
  974. // (e.g. Halftoning, Output Bin, Image Control)
  975. // Parameters:
  976. // pOptItem Pointer to OPTITEMs
  977. // cOptItem Count of OPTITEMs
  978. // uiResDLL resource dll#
  979. // uiResID item's name ID in resource dll
  980. //
  981. // Returns: the item's count(>=0); -1 if fail.
  982. //
  983. //////////////////////////////////////////////////////////////////////////
  984. INT SearchItemByName(POPTITEM pOptItem, WORD cOptItem, UINT uiResDLL, UINT uiResID)
  985. {
  986. HINSTANCE hInst;
  987. WCHAR wszTargetName[ITEM_STR_LEN128];
  988. INT iCnt = -1;
  989. if (UNIRES_DLL == uiResDLL)
  990. hInst = LoadLibrary(STR_UNIRESDLL); // resource in UNIRES.DLL
  991. else if (RPDLRES_DLL == uiResDLL)
  992. hInst = LoadLibrary(STR_RPDLRESDLL); // resource in RPDLRES.DLL @Sep/27/99
  993. else
  994. hInst = ghInstance; // resource in this DLL(RPDLCFG.DLL)
  995. if (hInst)
  996. {
  997. LoadString(hInst, uiResID, wszTargetName, ITEM_STR_LEN128);
  998. for (iCnt = 0; iCnt < (INT)cOptItem; iCnt++, pOptItem++)
  999. {
  1000. VERBOSE((DLLTEXT("** DMPubID=%d, pName=%lx **\n"), pOptItem->DMPubID, pOptItem->pName));
  1001. // @Apr/04/2002 ->
  1002. // if (lstrlen(pOptItem->pName) && !lstrcmp(pOptItem->pName, wszTargetName))
  1003. if (is_valid_ptr(pOptItem->pName) && safe_strlenW(pOptItem->pName, ITEM_STR_LEN128) && !lstrcmp(pOptItem->pName, wszTargetName))
  1004. // @Apr/04/2002 <-
  1005. goto _SEARCHITEM_BYNAME_EXIT;
  1006. }
  1007. iCnt = -1; // search fail
  1008. }
  1009. _SEARCHITEM_BYNAME_EXIT:
  1010. #if DBG
  1011. if (iCnt >= 0)
  1012. {
  1013. VERBOSE((DLLTEXT("** SearchItemByName():SUCCESS #%d **\n"), iCnt));
  1014. VERBOSE((DLLTEXT("** DMPubID=%d"), pOptItem->DMPubID));
  1015. // @Apr/04/2002 ->
  1016. // if (lstrlen(pOptItem->pName))
  1017. if (is_valid_ptr(pOptItem->pName) && safe_strlenW(pOptItem->pName, ITEM_STR_LEN128))
  1018. // @Apr/04/2002 <-
  1019. VERBOSE((", pName=%ls", pOptItem->pName));
  1020. VERBOSE((" **\n"));
  1021. }
  1022. else
  1023. {
  1024. VERBOSE((DLLTEXT("** SearchItemByName():FAIL **\n")));
  1025. }
  1026. #endif // DBG
  1027. if (hInst != 0 && hInst != ghInstance)
  1028. FreeLibrary(hInst);
  1029. return iCnt;
  1030. } //*** SearchItemByName
  1031. //////////////////////////////////////////////////////////////////////////
  1032. // Function: SearchItemByID
  1033. //
  1034. // Description: Search option item by DMPubID
  1035. //
  1036. // Parameters:
  1037. // pOptItem Pointer to OPTITEMs
  1038. // cOptItem Count of OPTITEMs
  1039. // DMPubID Devmode public filed ID
  1040. //
  1041. // Returns: the item's count(>=0); -1 if fail.
  1042. //
  1043. //////////////////////////////////////////////////////////////////////////
  1044. INT SearchItemByID(POPTITEM pOptItem, WORD cOptItem, BYTE DMPubID)
  1045. {
  1046. INT iCnt;
  1047. for (iCnt = 0; iCnt < (INT)cOptItem; iCnt++, pOptItem++)
  1048. {
  1049. if (DMPubID == pOptItem->DMPubID)
  1050. return iCnt;
  1051. }
  1052. return -1; // search fail
  1053. } //*** SearchItemByID
  1054. // @Sep/24/99 <-
  1055. //////////////////////////////////////////////////////////////////////////
  1056. // Function: IsValidDuplex
  1057. //
  1058. // Description: Check Duplex Feature in UI
  1059. //
  1060. // Parameters:
  1061. // pOEMUIParam
  1062. //
  1063. // Returns: TRUE if valid; FALSE otherwise.
  1064. //
  1065. //////////////////////////////////////////////////////////////////////////
  1066. BOOL IsValidDuplex(POEMCUIPPARAM pOEMUIParam)
  1067. {
  1068. // not use DrvGetDriverSetting @Sep/27/99 ->
  1069. // DWORD dwNeeded = 64, dwOptions, dwLastError;
  1070. // BYTE Output[64];
  1071. //// @Oct/06/98 ->
  1072. //// PFN_DrvGetDriverSetting DrvGetDriverSetting = pOEMUIParam->poemuiobj->pOemUIProcs->DrvGetDriverSetting;
  1073. //// @Oct/06/98 <-
  1074. //
  1075. // SetLastError(0);
  1076. // UI_GETDRIVERSETTING(pOEMUIParam->poemuiobj, UNIDRV_FEATURE_DUPLEX,
  1077. // Output, dwNeeded, &dwNeeded, &dwOptions); // @Oct/06/98
  1078. // dwLastError = GetLastError();
  1079. // VERBOSE((DLLTEXT("IsValidDuplex: dwLastError=%d\n"), dwLastError));
  1080. //
  1081. // if (ERROR_SUCCESS == dwLastError)
  1082. // {
  1083. // VERBOSE((DLLTEXT("** Output=%s **\n"), Output));
  1084. //
  1085. // // if duplex is not valid, return FALSE
  1086. // if (!lstrcmpA((LPCSTR)Output, UNIDRV_DUPLEX_NONE))
  1087. // return FALSE;
  1088. // }
  1089. // return TRUE;
  1090. POPTITEM pOptItem;
  1091. INT iNum;
  1092. iNum = SearchItemByID((pOptItem = pOEMUIParam->pDrvOptItems),
  1093. (WORD)pOEMUIParam->cDrvOptItems,
  1094. DMPUB_DUPLEX);
  1095. return (0 <= iNum && SEL_DUPLEX_NONE != (pOptItem+iNum)->Sel);
  1096. // @Sep/27/99 <-
  1097. } //*** IsValidDuplex
  1098. extern "C" {
  1099. //////////////////////////////////////////////////////////////////////////
  1100. // Function: OEMDocumentPropertySheets
  1101. //////////////////////////////////////////////////////////////////////////
  1102. LRESULT APIENTRY OEMDocumentPropertySheets(PPROPSHEETUI_INFO pPSUIInfo, LPARAM lParam)
  1103. {
  1104. LRESULT lResult = FALSE;
  1105. // Validate parameters.
  1106. if( (NULL == pPSUIInfo)
  1107. ||
  1108. IsBadWritePtr(pPSUIInfo, pPSUIInfo->cbSize)
  1109. ||
  1110. (PROPSHEETUI_INFO_VERSION != pPSUIInfo->Version)
  1111. ||
  1112. ( (PROPSHEETUI_REASON_INIT != pPSUIInfo->Reason)
  1113. &&
  1114. (PROPSHEETUI_REASON_GET_INFO_HEADER != pPSUIInfo->Reason)
  1115. &&
  1116. (PROPSHEETUI_REASON_GET_ICON != pPSUIInfo->Reason)
  1117. &&
  1118. (PROPSHEETUI_REASON_SET_RESULT != pPSUIInfo->Reason)
  1119. &&
  1120. (PROPSHEETUI_REASON_DESTROY != pPSUIInfo->Reason)
  1121. )
  1122. )
  1123. {
  1124. ERR((DLLTEXT("OEMDocumentPropertySheets() ERROR_INVALID_PARAMETER.\n")));
  1125. // Return invalid parameter error.
  1126. SetLastError(ERROR_INVALID_PARAMETER);
  1127. return -1;
  1128. }
  1129. VERBOSE(("\n"));
  1130. VERBOSE((DLLTEXT("OEMDocumentPropertySheets() entry. Reason=%d\n"), pPSUIInfo->Reason));
  1131. // @Sep/22/2000 ->
  1132. #ifdef DISKLESSMODEL
  1133. {
  1134. DWORD dwError, dwType, dwNeeded;
  1135. BYTE ValueData;
  1136. POEMUIPSPARAM pOEMUIPSParam = (POEMUIPSPARAM)pPSUIInfo->lParamInit;
  1137. dwError = GetPrinterData(pOEMUIPSParam->hPrinter, REG_HARDDISK_INSTALLED, &dwType,
  1138. (PBYTE)&ValueData, sizeof(BYTE), &dwNeeded);
  1139. if (ERROR_SUCCESS != dwError)
  1140. {
  1141. VERBOSE((DLLTEXT(" CAN'T READ REGISTRY (%d).\n"), dwError));
  1142. return FALSE;
  1143. }
  1144. else if (!ValueData)
  1145. {
  1146. VERBOSE((DLLTEXT(" HARD DISK ISN'T INSTALLED.\n")));
  1147. return FALSE;
  1148. }
  1149. }
  1150. #endif // DISKLESSMODEL
  1151. // @Sep/22/2000 <-
  1152. // Do action.
  1153. switch(pPSUIInfo->Reason)
  1154. {
  1155. case PROPSHEETUI_REASON_INIT:
  1156. {
  1157. POEMUIPSPARAM pOEMUIPSParam = (POEMUIPSPARAM)pPSUIInfo->lParamInit;
  1158. POEMUD_EXTRADATA pOEMExtra = MINIPRIVATE_DM(pOEMUIPSParam); // @Oct/06/98
  1159. #ifdef WINNT_40 // @Sep/02/99
  1160. VERBOSE((DLLTEXT("** dwFlags=%lx **\n"), pOEMUIPSParam->dwFlags));
  1161. if (pOEMUIPSParam->dwFlags & DM_NOPERMISSION)
  1162. BITSET32(pOEMExtra->fUiOption, UIPLUGIN_NOPERMISSION);
  1163. #endif // WINNT_40
  1164. pPSUIInfo->UserData = NULL;
  1165. #ifndef GWMODEL // @Sep/21/2000
  1166. // if fax model, add fax page
  1167. if (BITTEST32(pOEMExtra->fUiOption, FAX_MODEL) &&
  1168. (pPSUIInfo->UserData = (LPARAM)HeapAlloc(pOEMUIPSParam->hOEMHeap,
  1169. HEAP_ZERO_MEMORY,
  1170. sizeof(UIDATA))))
  1171. {
  1172. PROPSHEETPAGE Page;
  1173. PUIDATA pUiData = (PUIDATA)pPSUIInfo->UserData;
  1174. FILEDATA FileData; // <-pFileData (formerly use MemAllocZ) @Mar/17/2000
  1175. // read PRINT_DONE flag from shared data file @Oct/19/98
  1176. FileData.fUiOption = 0;
  1177. // @Mar/01/2002 ->
  1178. // RWFileData(&FileData, pOEMExtra->SharedFileName, GENERIC_READ);
  1179. RWFileData(&FileData, pOEMExtra->SharedFileName, sizeof(pOEMExtra->SharedFileName), GENERIC_READ);
  1180. // @Mar/01/2002 <-
  1181. VERBOSE((DLLTEXT("** Shared File Name=%ls **\n"), pOEMExtra->SharedFileName));
  1182. // set PRINT_DONE flag
  1183. if (BITTEST32(FileData.fUiOption, PRINT_DONE))
  1184. BITSET32(pOEMExtra->fUiOption, PRINT_DONE);
  1185. pUiData->hComPropSheet = pPSUIInfo->hComPropSheet;
  1186. pUiData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet;
  1187. pUiData->pOEMExtra = pOEMExtra;
  1188. // Init property page.
  1189. // Use SecureZeroMemory @Mar/29/2002 ->
  1190. #if defined(WINNT_40) || defined(RICOH_RELEASE)
  1191. memset(&Page, 0, sizeof(PROPSHEETPAGE));
  1192. #else
  1193. SecureZeroMemory(&Page, sizeof(PROPSHEETPAGE));
  1194. #endif
  1195. // Mar/29/2002 <-
  1196. Page.dwSize = sizeof(PROPSHEETPAGE);
  1197. Page.dwFlags = PSP_DEFAULT;
  1198. Page.hInstance = ghInstance;
  1199. Page.pszTemplate = MAKEINTRESOURCE(IDD_FAXMAIN);
  1200. Page.pfnDlgProc = FaxPageProc; // add (DLGPROC) @Aug/30/99
  1201. Page.lParam = (LPARAM)pUiData;
  1202. // Add property sheets.
  1203. lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet,
  1204. CPSFUNC_ADD_PROPSHEETPAGE,
  1205. (LPARAM)&Page, 0);
  1206. pUiData->hPropPage = (HANDLE)lResult;
  1207. VERBOSE((DLLTEXT("** INIT: lResult=%x **\n"), lResult));
  1208. lResult = (lResult > 0)? TRUE : FALSE;
  1209. }
  1210. #else // GWMODEL
  1211. #ifdef JOBLOGSUPPORT_DLG
  1212. // add Job/Log page
  1213. if ((pPSUIInfo->UserData = (LPARAM)HeapAlloc(pOEMUIPSParam->hOEMHeap,
  1214. HEAP_ZERO_MEMORY,
  1215. sizeof(UIDATA))))
  1216. {
  1217. PROPSHEETPAGE Page;
  1218. PUIDATA pUiData = (PUIDATA)pPSUIInfo->UserData;
  1219. FILEDATA FileData; // <- pFileData (formerly use MemAllocZ) @2000/03/15
  1220. // read PRINT_DONE flag from data file
  1221. FileData.fUiOption = 0;
  1222. // @Mar/01/2002 ->
  1223. // RWFileData(&FileData, pOEMExtra->SharedFileName, GENERIC_READ);
  1224. RWFileData(&FileData, pOEMExtra->SharedFileName, sizeof(pOEMExtra->SharedFileName), GENERIC_READ);
  1225. // @Mar/01/2002 <-
  1226. // set PRINT_DONE flag
  1227. if (BITTEST32(FileData.fUiOption, PRINT_DONE))
  1228. BITSET32(pOEMExtra->fUiOption, PRINT_DONE);
  1229. VERBOSE((DLLTEXT("** Flag=%lx,File Name=%ls **\n"),
  1230. pOEMExtra->fUiOption, pOEMExtra->SharedFileName));
  1231. pUiData->hComPropSheet = pPSUIInfo->hComPropSheet;
  1232. pUiData->pfnComPropSheet = pPSUIInfo->pfnComPropSheet;
  1233. pUiData->pOEMExtra = pOEMExtra;
  1234. // Init property page.
  1235. // Use SecureZeroMemory @Mar/29/2002 ->
  1236. #if defined(WINNT_40) || defined(RICOH_RELEASE)
  1237. memset(&Page, 0, sizeof(PROPSHEETPAGE));
  1238. #else
  1239. SecureZeroMemory(&Page, sizeof(PROPSHEETPAGE));
  1240. #endif
  1241. // Mar/29/2002 <-
  1242. Page.dwSize = sizeof(PROPSHEETPAGE);
  1243. Page.dwFlags = PSP_DEFAULT;
  1244. Page.hInstance = ghInstance;
  1245. Page.pszTemplate = MAKEINTRESOURCE(IDD_JOBMAIN);
  1246. Page.pfnDlgProc = JobPageProc;
  1247. Page.lParam = (LPARAM)pUiData;
  1248. // Add property sheets.
  1249. lResult = pPSUIInfo->pfnComPropSheet(pPSUIInfo->hComPropSheet,
  1250. CPSFUNC_ADD_PROPSHEETPAGE,
  1251. (LPARAM)&Page, 0);
  1252. pUiData->hPropPage = (HANDLE)lResult;
  1253. VERBOSE((DLLTEXT("** INIT: lResult=%x **\n"), lResult));
  1254. lResult = (lResult > 0)? TRUE : FALSE;
  1255. }
  1256. #endif // JOBLOGSUPPORT_DLG
  1257. #endif // GWMODEL
  1258. }
  1259. break;
  1260. case PROPSHEETUI_REASON_GET_INFO_HEADER:
  1261. lResult = TRUE;
  1262. break;
  1263. case PROPSHEETUI_REASON_GET_ICON:
  1264. // No icon
  1265. lResult = 0;
  1266. break;
  1267. case PROPSHEETUI_REASON_SET_RESULT:
  1268. {
  1269. PSETRESULT_INFO pInfo = (PSETRESULT_INFO) lParam;
  1270. lResult = pInfo->Result;
  1271. }
  1272. break;
  1273. case PROPSHEETUI_REASON_DESTROY:
  1274. lResult = TRUE;
  1275. if (pPSUIInfo->UserData)
  1276. {
  1277. POEMUIPSPARAM pOEMUIPSParam = (POEMUIPSPARAM)pPSUIInfo->lParamInit;
  1278. HeapFree(pOEMUIPSParam->hOEMHeap, 0, (void*)pPSUIInfo->UserData);
  1279. }
  1280. break;
  1281. }
  1282. pPSUIInfo->Result = lResult;
  1283. return lResult;
  1284. } //*** OEMDocumentPropertySheets
  1285. } // End of extern "C"