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.

1060 lines
25 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. validate.c
  5. Abstract:
  6. This module contains the function to validate all optitem
  7. Author:
  8. 05-Sep-1995 Tue 18:42:44 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. NT Windows - Common Printer Driver UI DLL
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #define DBG_CPSUIFILENAME DbgValidate
  17. #define DBG_VALIDATE 0x00000001
  18. #define DBGITEM_VALIDATE 0x00000002
  19. #define DBG_CLEANUP 0x00000004
  20. #define DBG_ALLOCEDIT 0x00000008
  21. #define DBG_DMPUBHIDE 0x00000010
  22. DEFINE_DBGVAR(0);
  23. #if DBG
  24. static const LPSTR pszDMPub[] = { "DMPUB_ORIENTATION",
  25. "DMPUB_SCALE",
  26. "DMPUB_COPIES_COLLATE",
  27. "DMPUB_DEFSOURCE",
  28. "DMPUB_PRINTQUALITY",
  29. "DMPUB_COLOR",
  30. "DMPUB_DUPLEX",
  31. "DMPUB_TTOPTION",
  32. "DMPUB_FORMNAME",
  33. "DMPUB_ICMMETHOD",
  34. "DMPUB_ICMINTENT",
  35. "DMPUB_MEDIATYPE",
  36. "DMPUB_DITHERTYPE",
  37. "DMPUB_OUTPUTBIN",
  38. "DMPUB_QUALITY",
  39. "DMPUB_NUP",
  40. "DMPUB_PAGEORDER"
  41. };
  42. #endif
  43. extern HINSTANCE hInstDLL;
  44. extern OPTTYPE OptTypeHdrPush;
  45. LONG
  46. ValidateChildrenItems(
  47. PTVWND pTVWnd,
  48. POPTITEM *ppItem,
  49. DWORD DMPubHideBits,
  50. DWORD ParentFlags
  51. )
  52. /*++
  53. Routine Description:
  54. Arguments:
  55. Return Value:
  56. Author:
  57. 05-Sep-1995 Tue 18:43:47 created -by- Daniel Chou (danielc)
  58. Revision History:
  59. --*/
  60. {
  61. POPTITEM pItem;
  62. POPTITEM pNext;
  63. POPTITEM pLastItem;
  64. LONG cGroup = 1;
  65. DWORD Flags;
  66. BYTE DMPubID;
  67. BYTE DlgPageIdx;
  68. BYTE CurLevel;
  69. pNext =
  70. pItem = *ppItem;
  71. CurLevel = pItem->Level;
  72. pLastItem = pTVWnd->pLastItem;
  73. Flags = (ParentFlags &= OPTIF_ITEM_HIDE);
  74. while ((cGroup >= 0) &&
  75. (pItem <= pLastItem) &&
  76. (pItem->Level >= CurLevel)) {
  77. CPSUIASSERT(0, "pItem != pNext", pItem == pNext, 0);
  78. if (pItem->Level > CurLevel) {
  79. cGroup = ValidateChildrenItems(pTVWnd, &pItem, DMPubHideBits, Flags);
  80. pNext = pItem;
  81. continue;
  82. }
  83. DlgPageIdx = pItem->DlgPageIdx;
  84. DMPubID = pItem->DMPubID;
  85. Flags = pItem->Flags;
  86. if ((DMPubHideBits) &&
  87. (DMPubID >= DMPUB_FIRST) &&
  88. (DMPubID <= DMPUB_LAST) &&
  89. (MAKE_DMPUB_HIDEBIT(DMPubID) & DMPubHideBits)) {
  90. Flags |= OPTIF_INT_HIDE;
  91. CPSUIDBG(DBG_DMPUBHIDE, ("Hide DMPUB_ID=%hs, Bits=%08lx (%08lx)",
  92. pszDMPub[DMPubID - DMPUB_FIRST],
  93. MAKE_DMPUB_HIDEBIT(DMPubID), DMPubHideBits));
  94. } else {
  95. Flags &= ~OPTIF_INT_HIDE;
  96. }
  97. {
  98. POPTTYPE pOptType;
  99. POPTPARAM pOptParam = NULL;
  100. PEXTCHKBOX pECB;
  101. INT Count;
  102. INT IconCount;
  103. INT cNotHide;
  104. BYTE Mask;
  105. BYTE HideBits;
  106. LONG MinSel;
  107. LONG MaxSel;
  108. BYTE Type;
  109. BOOL pDefSelIsMem;
  110. Flags |= ParentFlags;
  111. CPSUIOPTITEM(DBGITEM_VALIDATE, pTVWnd, "Validate", 2, pItem);
  112. if (pItem->cbSize != sizeof(OPTITEM)) {
  113. return(ERR_CPSUI_INVALID_OPTITEM_CBSIZE);
  114. }
  115. //
  116. // clear the unused flags
  117. //
  118. pItem->Flags &= (OPTIF_MASK ^ OPTIF_ENTER_MASK);
  119. if ((Flags & OPTIF_HIDE) && (!(pItem->Flags & OPTIF_HIDE))) {
  120. return(ERR_CPSUI_SUBITEM_DIFF_OPTIF_HIDE);
  121. }
  122. if (Flags & OPTIF_INT_HIDE) {
  123. pItem->Flags |= OPTIF_INT_HIDE;
  124. }
  125. if (!(pItem->Flags & OPTIF_ITEM_HIDE)) {
  126. if (pOptType = pItem->pOptType) {
  127. //
  128. // Validate OPTTYPE
  129. //
  130. if (pOptType->cbSize != sizeof(OPTTYPE)) {
  131. return(ERR_CPSUI_INVALID_OPTTYPE_CBSIZE);
  132. }
  133. IconCount = 1;
  134. switch (Type = pOptType->Type) {
  135. case TVOT_CHKBOX:
  136. case TVOT_PUSHBUTTON:
  137. Count = 1;
  138. break;
  139. case TVOT_2STATES:
  140. IconCount = 2;
  141. case TVOT_EDITBOX:
  142. case TVOT_UDARROW:
  143. Count = 2;
  144. break;
  145. case TVOT_3STATES:
  146. IconCount = 3;
  147. //
  148. // Fall through
  149. //
  150. case TVOT_TRACKBAR:
  151. case TVOT_SCROLLBAR:
  152. Count = 3;
  153. break;
  154. case TVOT_LISTBOX:
  155. case TVOT_COMBOBOX:
  156. IconCount =
  157. Count = (INT)pOptType->Count;
  158. break;
  159. default:
  160. return(ERR_CPSUI_INVALID_TVOT_TYPE);
  161. }
  162. if (pOptType->Count != (WORD)Count) {
  163. return(ERR_CPSUI_INVALID_OPTTYPE_COUNT);
  164. }
  165. //
  166. // Validate OPTPARAM
  167. //
  168. if (pOptParam = pOptType->pOptParam) {
  169. cNotHide = Count;
  170. HideBits = 0;
  171. Mask = 0x01;
  172. while (Count--) {
  173. if (pOptParam->cbSize != sizeof(OPTPARAM)) {
  174. return(ERR_CPSUI_INVALID_OPTPARAM_CBSIZE);
  175. }
  176. if (pOptParam->Flags & OPTPF_HIDE) {
  177. cNotHide--;
  178. HideBits |= Mask;
  179. }
  180. Mask <<= 1;
  181. pOptParam++;
  182. }
  183. } else {
  184. return(ERR_CPSUI_NULL_POPTPARAM);
  185. }
  186. pOptParam = pOptType->pOptParam;
  187. //
  188. // for TVOT_2STATES, TVOT_3STATES, TVOT_LISTBOX and
  189. // TVOT_COMBOBOX, if all selection are hided then we will
  190. // hide this item
  191. //
  192. switch (Type) {
  193. case TVOT_PUSHBUTTON:
  194. switch (pOptParam->Style) {
  195. case PUSHBUTTON_TYPE_HTSETUP:
  196. _OI_HELPIDX(pItem) = IDH_HT_SETUP;
  197. pOptType->Flags |= OTS_PUSH_ENABLE_ALWAYS;
  198. break;
  199. case PUSHBUTTON_TYPE_HTCLRADJ:
  200. _OI_HELPIDX(pItem) = IDH_HT_CLRADJ;
  201. pOptType->Flags |= OTS_PUSH_ENABLE_ALWAYS;
  202. break;
  203. case PUSHBUTTON_TYPE_DLGPROC:
  204. case PUSHBUTTON_TYPE_CALLBACK:
  205. break;
  206. default:
  207. return(ERR_CPSUI_INVALID_PUSHBUTTON_TYPE);
  208. }
  209. break;
  210. case TVOT_3STATES:
  211. case TVOT_2STATES:
  212. _OT_FLAGS(pOptType) |= (WORD)HideBits;
  213. CPSUIINT(("States Type=%d, HideBits=0x%02x",
  214. (UINT)pOptType->Type, (UINT)HideBits));
  215. case TVOT_LISTBOX:
  216. case TVOT_COMBOBOX:
  217. if (!cNotHide) {
  218. CPSUIWARN(("Type=%ld, all OPTPARAMs are OPTPF_HIDE, hide the item"));
  219. pItem->Flags |= OPTIF_INT_HIDE;
  220. Flags |= OPTIF_INT_HIDE;
  221. }
  222. break;
  223. default:
  224. break;
  225. }
  226. //
  227. // Validate pSel
  228. //
  229. // 19-May-1998 Tue 16:38:35 updated
  230. // -by- Daniel Chou (danielc)
  231. // We allocate (memory * 2) because for new IN PLACE
  232. // treeview editing, we need to save another of undo
  233. //
  234. MinSel = 0;
  235. MaxSel = -1;
  236. pDefSelIsMem = FALSE;
  237. _OI_CBPDEFSEL(pItem) = (WORD)0;
  238. switch (Type) {
  239. case TVOT_CHKBOX:
  240. case TVOT_2STATES:
  241. MaxSel = 1;
  242. break;
  243. case TVOT_UDARROW:
  244. case TVOT_TRACKBAR:
  245. case TVOT_SCROLLBAR:
  246. MinSel = (LONG)((SHORT)pOptParam[1].IconID);
  247. MaxSel = (LONG)((SHORT)pOptParam[1].lParam);
  248. if (MinSel > MaxSel) {
  249. pOptParam[1].IconID = MaxSel;
  250. pOptParam[1].lParam = MinSel;
  251. CPSUIWARN(("Type=%d, Swap select range (%d - %d)",
  252. Type, MinSel, MaxSel));
  253. MinSel = MaxSel;
  254. MaxSel = (LONG)((SHORT)pOptParam[1].lParam);
  255. }
  256. if (Type != TVOT_UDARROW) {
  257. //
  258. // This is the multiple factor
  259. //
  260. if (!pOptParam[2].IconID) {
  261. pOptParam[2].IconID = 1;
  262. }
  263. if (!pOptParam[2].lParam) {
  264. pOptParam[2].lParam = 1;
  265. }
  266. }
  267. break;
  268. case TVOT_3STATES:
  269. MaxSel = 2;
  270. break;
  271. case TVOT_LISTBOX:
  272. case TVOT_COMBOBOX:
  273. if (pOptType->Style & OTS_LBCB_INCL_ITEM_NONE) {
  274. MinSel = -1;
  275. if (pItem->Sel < 0) {
  276. pItem->Sel = -1;
  277. }
  278. }
  279. MaxSel = (LONG)((LONG)pOptType->Count - 1);
  280. break;
  281. case TVOT_PUSHBUTTON:
  282. switch (pOptParam->Style) {
  283. case PUSHBUTTON_TYPE_HTSETUP:
  284. if (_OI_PDEFSEL(pItem) = (LPVOID)
  285. LocalAlloc(LPTR,
  286. sizeof(DEVHTINFO) * 2)) {
  287. PDEVHTADJDATA pDevHTAdjData;
  288. pDefSelIsMem = TRUE;
  289. _OI_CBPDEFSEL(pItem) = (WORD)sizeof(DEVHTINFO);
  290. pDevHTAdjData =
  291. (PDEVHTADJDATA)(pOptParam->pData);
  292. CopyMemory(_OI_PDEFSEL(pItem),
  293. pDevHTAdjData->pAdjHTInfo,
  294. sizeof(DEVHTINFO));
  295. } else {
  296. CPSUIERR(("LocalAlloc(HTSETUP/DEVHTINFO) failed"));
  297. return(ERR_CPSUI_ALLOCMEM_FAILED);
  298. }
  299. break;
  300. case PUSHBUTTON_TYPE_HTCLRADJ:
  301. if (_OI_PDEFSEL(pItem) = (LPVOID)
  302. LocalAlloc(LPTR,
  303. sizeof(COLORADJUSTMENT) * 2)) {
  304. pDefSelIsMem = TRUE;
  305. _OI_CBPDEFSEL(pItem) =
  306. (WORD)sizeof(COLORADJUSTMENT);
  307. CopyMemory(_OI_PDEFSEL(pItem),
  308. pOptParam->pData,
  309. sizeof(COLORADJUSTMENT));
  310. } else {
  311. CPSUIERR(("LocalAlloc(HTCLRADJ/COLORADJUSTMENT) failed"));
  312. return(ERR_CPSUI_ALLOCMEM_FAILED);
  313. }
  314. break;
  315. }
  316. break;
  317. case TVOT_EDITBOX:
  318. if ((!pItem->pSel) || (!VALID_PTR(pItem->pSel))) {
  319. return(ERR_CPSUI_INVALID_EDITBOX_PSEL);
  320. }
  321. if ((MaxSel = (LONG)pOptParam[1].IconID) <= 1) {
  322. return(ERR_CPSUI_INVALID_EDITBOX_BUF_SIZE);
  323. } else {
  324. --MaxSel;
  325. if (pTVWnd->Flags & TWF_ANSI_CALL) {
  326. MinSel = lstrlenA((LPSTR)pItem->pSel);
  327. if (MinSel > MaxSel) {
  328. ((LPSTR)pItem->pSel)[MaxSel] = 0;
  329. }
  330. MaxSel++;
  331. } else {
  332. MinSel = lstrlenW((LPWSTR)pItem->pSel);
  333. if (MinSel > MaxSel) {
  334. ((LPWSTR)pItem->pSel)[MaxSel] = 0;
  335. }
  336. MaxSel = (LONG)((DWORD)(MaxSel + 1) << 1);
  337. }
  338. if (_OI_PDEFSEL(pItem) =
  339. (LPVOID)LocalAlloc(LPTR, MaxSel * 2)) {
  340. pDefSelIsMem = TRUE;
  341. _OI_CBPDEFSEL(pItem) = (WORD)MaxSel;
  342. CopyMemory(_OI_PDEFSEL(pItem),
  343. pItem->pSel,
  344. MaxSel);
  345. } else {
  346. CPSUIERR(("LocalAlloc(EditBuf=%ld bytes) failed", MaxSel));
  347. return(ERR_CPSUI_ALLOCMEM_FAILED);
  348. }
  349. }
  350. //
  351. // Fall through
  352. //
  353. default:
  354. MinSel = 0;
  355. MaxSel = -1;
  356. break;
  357. }
  358. if ((MinSel < MaxSel) &&
  359. ((pItem->Sel < MinSel) ||
  360. (pItem->Sel > MaxSel))) {
  361. CPSUIWARN(("Sel=%ld (%08lx) Out of range (%ld - %ld)",
  362. pItem->Sel, pItem->pSel, MinSel, MaxSel));
  363. pItem->Flags |= OPTIF_CHANGED;
  364. pItem->Sel = MinSel;
  365. }
  366. //
  367. // Saved old selection
  368. //
  369. if (!pDefSelIsMem) {
  370. _OI_PDEFSEL(pItem) = pItem->pSel;
  371. }
  372. _OI_DEF_OPTIF(pItem) = pItem->Flags;
  373. //
  374. // Validate pExtChkBox
  375. //
  376. if ((pECB = pItem->pExtChkBox) &&
  377. (!(pItem->Flags & OPTIF_EXT_HIDE))) {
  378. if (pItem->Flags & OPTIF_EXT_IS_EXTPUSH) {
  379. PEXTPUSH pEP = (PEXTPUSH)pECB;
  380. if (pEP->cbSize != sizeof(EXTPUSH)) {
  381. return(ERR_CPSUI_INVALID_EXTPUSH_CBSIZE);
  382. }
  383. if (pEP->Flags & EPF_PUSH_TYPE_DLGPROC) {
  384. if (!(pEP->DlgProc)) {
  385. return(ERR_CPSUI_NULL_EXTPUSH_DLGPROC);
  386. }
  387. if (((pEP->Flags & EPF_USE_HDLGTEMPLATE) &&
  388. (pEP->hDlgTemplate == NULL)) ||
  389. (pEP->DlgTemplateID == 0)) {
  390. return(ERR_CPSUI_NO_EXTPUSH_DLGTEMPLATEID);
  391. }
  392. } else {
  393. if ((!(pEP->pfnCallBack)) &&
  394. (!(pTVWnd->ComPropSheetUI.pfnCallBack))) {
  395. return(ERR_CPSUI_NULL_EXTPUSH_CALLBACK);
  396. }
  397. }
  398. } else {
  399. CPSUIDBG(DBG_VALIDATE, ("ExtChkBox: cbSize=%u [%u]",
  400. pECB->cbSize, sizeof(EXTCHKBOX)));
  401. if (pECB->cbSize != sizeof(EXTCHKBOX)) {
  402. return(ERR_CPSUI_INVALID_ECB_CBSIZE);
  403. }
  404. if (!(pECB->pTitle)) {
  405. return(ERR_CPSUI_NULL_ECB_PTITLE);
  406. }
  407. if (!(pECB->pCheckedName)) {
  408. return(ERR_CPSUI_NULL_ECB_PCHECKEDNAME);
  409. }
  410. }
  411. }
  412. }
  413. //
  414. // Validate DMPubID
  415. //
  416. if ((DMPubID < DMPUB_OEM_PAPER_ITEM) &&
  417. (DMPubID != DMPUB_NONE) &&
  418. (pItem->DMPubID != DMPubID)) {
  419. return(ERR_CPSUI_INVALID_DMPUBID);
  420. }
  421. //
  422. // Validate DlgPageIdx
  423. //
  424. if (pItem->DlgPageIdx != DlgPageIdx) {
  425. return(ERR_CPSUI_SUBITEM_DIFF_DLGPAGEIDX);
  426. }
  427. if (DlgPageIdx >= pTVWnd->cMyDlgPage) {
  428. return(ERR_CPSUI_INVALID_DLGPAGEIDX);
  429. }
  430. if (pItem->Flags & OPTIF_CHANGED) {
  431. CPSUIOPTITEM(0,pTVWnd, "Validate: OPTIF_CHANGED", 2, pItem);
  432. }
  433. }
  434. }
  435. pNext = ++pItem;
  436. }
  437. CPSUIASSERT(0, "pItem != *ppItem", pItem != *ppItem, 0);
  438. *ppItem = pItem;
  439. return(cGroup);
  440. }
  441. LONG
  442. ValidatepOptItem(
  443. PTVWND pTVWnd,
  444. DWORD DMPubHideBits
  445. )
  446. /*++
  447. Routine Description:
  448. Arguments:
  449. Return Value:
  450. Author:
  451. 05-Sep-1995 Tue 18:43:47 created -by- Daniel Chou (danielc)
  452. Revision History:
  453. --*/
  454. {
  455. POPTITEM pItem;
  456. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  457. return(ValidateChildrenItems(pTVWnd, &pItem, DMPubHideBits, 0));
  458. }
  459. UINT
  460. SetOptItemNewDef(
  461. HWND hDlg,
  462. PTVWND pTVWnd,
  463. BOOL DoDef2
  464. )
  465. /*++
  466. Routine Description:
  467. This function set the new default for the OptItems
  468. Arguments:
  469. Return Value:
  470. Author:
  471. 02-Feb-1996 Fri 22:07:59 created -by- Daniel Chou (danielc)
  472. Revision History:
  473. --*/
  474. {
  475. POPTITEM pItem;
  476. POPTITEM pLastItem;
  477. POPTTYPE pOptType;
  478. LPVOID pvAlloc;
  479. LPBYTE pDefSel;
  480. UINT cSet = 0;
  481. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  482. pLastItem = pTVWnd->pLastItem;
  483. while (pItem <= pLastItem) {
  484. if ((pOptType = pItem->pOptType) &&
  485. (!(pItem->Flags & OPTIF_ITEM_HIDE)) &&
  486. ((DoDef2) || (pItem->Flags & (OPTIF_CHANGEONCE|OPTIF_CHANGED)))) {
  487. PDEVHTADJDATA pDevHTAdjData;
  488. ++cSet;
  489. pvAlloc = (LPVOID)(pDefSel = (LPBYTE)_OI_PDEFSEL(pItem));
  490. if (DoDef2) {
  491. pDefSel += _OI_CBPDEFSEL(pItem);
  492. } else {
  493. pItem->Flags |= OPTIF_CHANGED;
  494. }
  495. switch (pOptType->Type) {
  496. case TVOT_EDITBOX:
  497. if (!pvAlloc) {
  498. CPSUIASSERT(0, "SetOptItemNewDef(EDITBOX:pvAlloc=NULL)", pvAlloc, 0);
  499. break;
  500. }
  501. if (pTVWnd->Flags & TWF_ANSI_CALL) {
  502. lstrcpyA((LPSTR)pDefSel, (LPSTR)pItem->pSel);
  503. } else {
  504. lstrcpy((LPWSTR)pDefSel, (LPWSTR)pItem->pSel);
  505. }
  506. break;
  507. case TVOT_PUSHBUTTON:
  508. switch (pOptType->pOptParam->Style) {
  509. case PUSHBUTTON_TYPE_HTSETUP:
  510. if (!pvAlloc) {
  511. CPSUIASSERT(0, "SetOptItemNewDef(HTSETUP:pvAlloc=NULL)", pvAlloc, 0);
  512. break;
  513. }
  514. pDevHTAdjData = (PDEVHTADJDATA)(pOptType->pOptParam->pData);
  515. CopyMemory(pDefSel,
  516. pDevHTAdjData->pAdjHTInfo,
  517. sizeof(DEVHTINFO));
  518. break;
  519. case PUSHBUTTON_TYPE_HTCLRADJ:
  520. if (!pvAlloc) {
  521. CPSUIASSERT(0, "SetOptItemNewDef(HTCLRADJ:pvAlloc=NULL)", pvAlloc, 0);
  522. break;
  523. }
  524. CopyMemory(pDefSel,
  525. pOptType->pOptParam->pData,
  526. sizeof(COLORADJUSTMENT));
  527. break;
  528. default:
  529. if (DoDef2) {
  530. _OI_PDEFSEL2(pItem) = pItem->pSel;
  531. } else {
  532. _OI_PDEFSEL(pItem) = pItem->pSel;
  533. }
  534. break;
  535. }
  536. break;
  537. default:
  538. if (DoDef2) {
  539. _OI_PDEFSEL2(pItem) = pItem->pSel;
  540. } else {
  541. pItem->Flags &= ~OPTIF_CHANGEONCE;
  542. _OI_PDEFSEL(pItem) = pItem->pSel;
  543. }
  544. break;
  545. }
  546. if (DoDef2) {
  547. _OI_DEF_OPTIF2(pItem) = pItem->Flags;
  548. } else {
  549. _OI_DEF_OPTIF(pItem) = pItem->Flags;
  550. }
  551. }
  552. pItem++;
  553. }
  554. if ((cSet) && (!DoDef2)) {
  555. UpdateCallBackChanges(hDlg, pTVWnd, TRUE);
  556. UpdateTreeViewItem(hDlg, pTVWnd, pTVWnd->pCurTVItem, TRUE);
  557. }
  558. return(cSet);
  559. }
  560. BOOL
  561. CleanUpTVWND(
  562. PTVWND pTVWnd
  563. )
  564. /*++
  565. Routine Description:
  566. Arguments:
  567. Return Value:
  568. Author:
  569. 05-Sep-1995 Tue 19:41:45 created -by- Daniel Chou (danielc)
  570. Revision History:
  571. --*/
  572. {
  573. PMYDLGPAGE pMyDP;
  574. POPTITEM pItem;
  575. UINT cItem;
  576. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  577. cItem = (UINT)pTVWnd->ComPropSheetUI.cOptItem;
  578. while (cItem--) {
  579. POPTTYPE pOptType;
  580. LPVOID pDefSel;
  581. pItem->Flags &= (OPTIF_MASK ^ OPTIF_EXIT_MASK);
  582. pDefSel = _OI_PDEFSEL(pItem);
  583. pOptType = pItem->pOptType;
  584. if (pOptType) {
  585. switch (pOptType->Type) {
  586. case TVOT_PUSHBUTTON:
  587. switch (pOptType->pOptParam->Style) {
  588. case PUSHBUTTON_TYPE_HTSETUP:
  589. case PUSHBUTTON_TYPE_HTCLRADJ:
  590. if (pDefSel) {
  591. CPSUIOPTITEM(DBG_CLEANUP, pTVWnd, "Free Halftone pointer", 1, pItem);
  592. LocalFree((HLOCAL)pDefSel);
  593. }
  594. }
  595. break;
  596. case TVOT_EDITBOX:
  597. if (pDefSel) {
  598. CPSUIOPTITEM(DBG_CLEANUP, pTVWnd, "Free EditBuf", 1, pItem);
  599. LocalFree((HLOCAL)pDefSel);
  600. }
  601. break;
  602. }
  603. ZeroMemory(&pOptType->wReserved[0],
  604. sizeof(OPTTYPE) - FIELD_OFFSET(OPTTYPE, wReserved));
  605. }
  606. pItem->wReserved = 0;
  607. ZeroMemory(&pItem->dwReserved[0],
  608. sizeof(OPTITEM) - FIELD_OFFSET(OPTITEM, dwReserved));
  609. pItem++;
  610. }
  611. if (pMyDP = pTVWnd->pMyDlgPage) {
  612. UINT cMyDP = pTVWnd->cMyDlgPage;
  613. while (cMyDP--) {
  614. if (pMyDP->hIcon) {
  615. DestroyIcon(pMyDP->hIcon);
  616. }
  617. pMyDP++;
  618. }
  619. LocalFree((HLOCAL)pTVWnd->pMyDlgPage);
  620. pTVWnd->pMyDlgPage = NULL;
  621. }
  622. if (pTVWnd->pIcon16ID) {
  623. LocalFree((HLOCAL)pTVWnd->pIcon16ID);
  624. pTVWnd->pIcon16ID = NULL;
  625. }
  626. if (pTVWnd->himi) {
  627. ImageList_Destroy(pTVWnd->himi);
  628. pTVWnd->himi = NULL;
  629. }
  630. #if 0
  631. if (pTVWnd->hbrGray) {
  632. DeleteObject(pTVWnd->hbrGray);
  633. pTVWnd->hbrGray = NULL;
  634. }
  635. if (pTVWnd->hbmGray) {
  636. DeleteObject(pTVWnd->hbmGray);
  637. pTVWnd->hbmGray = NULL;
  638. }
  639. #endif
  640. return(TRUE);
  641. }