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.

5094 lines
115 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. treeview.c
  5. Abstract:
  6. This module contains tree view function for the printer driver
  7. Author:
  8. 19-Jun-1995 Mon 11:50:26 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 DbgTreeView
  17. #define DBG_AI 0x00000001
  18. #define DBG_UTV 0x00000002
  19. #define DBG_MAI 0x00000004
  20. #define DBG_CTVWND 0x00000008
  21. #define DBG_AC 0x00000010
  22. #define DBG_TVPROC 0x00000020
  23. #define DBG_STVS 0x00000040
  24. #define DBG_AIG 0x00000080
  25. #define DBGITEM_INS 0x00000100
  26. #define DBGITEM_SET 0x00000200
  27. #define DBGITEM_AIG 0x00000400
  28. #define DBGITEM_SETUP 0x00000800
  29. #define DBGITEM_HIT 0x00001000
  30. #define DBGITEM_NEXTGRP 0x00002000
  31. #define DBGITEM_ADDITEM 0x00004000
  32. #define DBG_LBSIZE 0x00008000
  33. #define DBG_COTD 0x00010000
  34. #define DBG_INITDLG 0x00020000
  35. #define DBG_APG 0x00040000
  36. #define DBGITEM_SELCHG 0x00080000
  37. #define DBGITEM_UTV 0x00100000
  38. #define DBG_MSR 0x00200000
  39. #define DBGITEM_NEWICON 0x00400000
  40. #define DBG_TVHT 0x00800000
  41. #define DBGITEM_CREVERT 0x01000000
  42. #define DBGITEM_REVERT 0x02000000
  43. #define DBG_OEM_ITEM 0x04000000
  44. #define DBG_SCID 0x08000000
  45. #define DBG_KEYS 0x10000000
  46. #define DBG_ASSERT 0x80000000
  47. DEFINE_DBGVAR(0);
  48. CPSUIDBGBLK(extern LPSTR pTVOTName[])
  49. #define ICON_SIZE_ANY 0
  50. extern HINSTANCE hInstDLL;
  51. extern OPTTYPE OptTypeHdrPush;
  52. extern OPTPARAM OptParamHdrPush;
  53. static const TVDLGITEM TVDlgItem[] = {
  54. { 5, 0, IDD_3STATES_1 }, // 0 TVOT_2STATES
  55. { 5, 0, IDD_3STATES_1 }, // 1 TVOT_3STATES
  56. { 4, 0, IDD_TV_UDARROW }, // 2 TVOT_UDARROW
  57. { 3, 0, IDD_TV_TRACKBAR }, // 3 TVOT_TRACKBAR
  58. { 3, 0, IDD_TV_SB }, // 4 TVOT_SCROLLBAR
  59. { 1, 0, IDD_TV_LB }, // 5 TVOT_LISTBOX
  60. { 1, 0, IDD_TV_CB }, // 6 TVOT_COMBOBOX
  61. { 3, 0, IDD_TV_EDIT_EDIT }, // 7 TVOT_EDITBOX
  62. { 1, 0, IDD_TV_PUSH }, // 8 TVOT_PUSHBUTTON
  63. { 1, 0, IDD_TV_CHKBOX }, // 9 TVOT_CHKBOX
  64. { 1, 0, IDD_TV_EXTPUSH },
  65. { 1, 0, IDD_TV_EXTCHKBOX }
  66. };
  67. #define ITVGF_BPCL (ITVGF_BOLD | ITVGF_COLLAPSE)
  68. static const INTTVGRP IntTVGrpPaper[] = {
  69. { 1, DMPUB_HDR_PAPER },
  70. { 2, DMPUB_FORMNAME },
  71. { 2, DMPUB_ORIENTATION },
  72. { 2, DMPUB_DEFSOURCE },
  73. { 2, DMPUB_OUTPUTBIN },
  74. { 2, DMPUB_MEDIATYPE },
  75. { 2, DMPUB_COPIES_COLLATE },
  76. { 2, DMPUB_DUPLEX },
  77. { 2, DMPUB_PAGEORDER },
  78. { 2, DMPUB_NUP },
  79. { 0, DMPUB_HDR_TVROOT }
  80. };
  81. static const INTTVGRP IntTVGrpGraphic[] = {
  82. { 1, DMPUB_HDR_GRAPHIC },
  83. { 2, DMPUB_QUALITY },
  84. { 2, DMPUB_PRINTQUALITY },
  85. { 2 , DMPUB_COLOR },
  86. { 2 | ITVGF_BOLD, DMPUB_HDR_ICM },
  87. { 3, DMPUB_ICMMETHOD },
  88. { 3, DMPUB_ICMINTENT },
  89. { 2, DMPUB_SCALE },
  90. { 2, DMPUB_DITHERTYPE },
  91. { 2, DMPUB_TTOPTION },
  92. { 0, DMPUB_HDR_TVROOT }
  93. };
  94. static const WORD ChkBoxStrID[] = { IDS_CPSUI_FALSE,
  95. IDS_CPSUI_TRUE,
  96. IDS_CPSUI_NO,
  97. IDS_CPSUI_YES,
  98. IDS_CPSUI_OFF,
  99. IDS_CPSUI_ON,
  100. IDS_CPSUI_FALSE,
  101. 0,
  102. IDS_CPSUI_NO,
  103. 0,
  104. IDS_CPSUI_OFF,
  105. 0,
  106. IDS_CPSUI_NONE,
  107. 0 };
  108. #define STVS_REINIT 0x0001
  109. #define STVS_ACTIVE 0x0002
  110. POPTITEM
  111. GetOptions(
  112. PTVWND pTVWnd,
  113. LPARAM lParam
  114. )
  115. {
  116. TVLP tvlp;
  117. tvlp = GET_TVLP(lParam);
  118. if (tvlp.ItemIdx >= INTIDX_FIRST) {
  119. return(PIDX_INTOPTITEM(pTVWnd, tvlp.ItemIdx));
  120. } else if (tvlp.ItemIdx < pTVWnd->ComPropSheetUI.cOptItem) {
  121. return(pTVWnd->ComPropSheetUI.pOptItem + tvlp.ItemIdx);
  122. } else {
  123. CPSUIERR(("ERROR: GetOptions(tvlp): Idx=%04lx, cName=%ld, Flags=%02lx",
  124. (DWORD)tvlp.ItemIdx, (DWORD)tvlp.cName, (DWORD)tvlp.Flags));
  125. return(PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT));
  126. }
  127. }
  128. #if (DO_IN_PLACE == 0)
  129. VOID
  130. MoveStateRadios(
  131. HWND hDlg,
  132. PTVWND pTVWnd,
  133. POPTTYPE pOptType,
  134. WORD InitFlags
  135. )
  136. /*++
  137. Routine Description:
  138. Arguments:
  139. Return Value:
  140. Author:
  141. 02-Sep-1995 Sat 21:08:14 created -by- Daniel Chou (danielc)
  142. Revision History:
  143. --*/
  144. {
  145. HWND hCtrl;
  146. UINT x;
  147. UINT CtrlID;
  148. UINT Count;
  149. UINT HideBits;
  150. TVOTSTATESINFO TSI;
  151. x = (InitFlags & INITCF_HAS_EXT) ? 0 : 1;
  152. if ((HideBits = (UINT)(_OT_FLAGS(pOptType) & OTINTF_STATES_HIDE_MASK)) ||
  153. (pOptType->Type == TVOT_2STATES)) {
  154. TSI = pTVWnd->SI2[x];
  155. if (!HideBits) {
  156. HideBits |= 0x04;
  157. }
  158. } else {
  159. TSI = pTVWnd->SI3[x];
  160. }
  161. CPSUIDBG(DBG_MSR, ("!! %hs: TSI: Top=%d, Inc=%d, Hide=%02x",
  162. pTVOTName[pOptType->Type], TSI.Top, TSI.Inc, HideBits));
  163. x = (UINT)pTVWnd->xCtrls;
  164. Count = 3;
  165. CtrlID = IDD_3STATES_1;
  166. while (Count--) {
  167. if (hCtrl = GetDlgItem(hDlg, CtrlID)) {
  168. if (HideBits & 0x01) {
  169. ShowWindow(hCtrl, SW_HIDE);
  170. EnableWindow(hCtrl, FALSE);
  171. CPSUIDBG(DBG_MSR,
  172. ("HIDE Radio Idx=%d (%d, %d)", 3-Count, x, TSI.Top));
  173. } else {
  174. CPSUIDBG(DBG_MSR,
  175. ("SHOW Radio Idx=%d (%d, %d)", 3-Count, x, TSI.Top));
  176. SetWindowPos(hCtrl, NULL,
  177. x, TSI.Top,
  178. 0, 0,
  179. SWP_NOSIZE | SWP_NOZORDER);
  180. TSI.Top += TSI.Inc;
  181. }
  182. }
  183. CtrlID += 2;
  184. HideBits >>= 1;
  185. }
  186. }
  187. #endif
  188. VOID
  189. SetOptHeader(
  190. HWND hDlg,
  191. PTVWND pTVWnd,
  192. POPTITEM pItem,
  193. BOOL HdrPush
  194. )
  195. /*++
  196. Routine Description:
  197. This function setup the string in the TREEVIEW page change item windows
  198. group box title.
  199. Arguments:
  200. Return Value:
  201. Author:
  202. 16-Oct-1995 Mon 19:23:36 created -by- Daniel Chou (danielc)
  203. Revision History:
  204. 20-Jul-1996 Sat 00:26:33 updated -by- Daniel Chou (danielc)
  205. Fixed the internationalize problem for compsition dynamic user data
  206. --*/
  207. {
  208. POPTITEM pRootItem = PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT);
  209. UINT IntFmtStrID;
  210. GSBUF_DEF(pItem, MAX_RES_STR_CHARS + 80);
  211. if (HdrPush) {
  212. //
  213. // Root Header item: XXX Document/Advance Document/Device Settings
  214. // Other Header Item: XXX Options
  215. if (pItem == pRootItem) {
  216. GSBUF_FLAGS |= GBF_PREFIX_OK | GBF_DUP_PREFIX;
  217. IntFmtStrID = (UINT)pRootItem->UserData;
  218. } else {
  219. IntFmtStrID = (UINT)IDS_INT_CPSUI_OPTIONS;
  220. }
  221. } else {
  222. IntFmtStrID = IDS_INT_CPSUI_CHANGE_SET;
  223. }
  224. GSBUF_COMPOSE(IntFmtStrID, pItem->pName, 0, 0);
  225. SetWindowText(GetDlgItem(hDlg, IDD_TV_OPTION), GSBUF_BUF);
  226. }
  227. VOID
  228. ChangeOptTypeDisplay(
  229. HWND hDlg,
  230. PTVWND pTVWnd,
  231. POPTTYPE pOldOptType,
  232. POPTTYPE pNewOptType,
  233. BOOL NewTypeUpdatePermission
  234. )
  235. /*++
  236. Routine Description:
  237. This function hide the old type and enable the new type's option
  238. header/icon depends on the NewTypeEnable flag
  239. Arguments:
  240. hDlg - Handle to the dialog box
  241. pTVWnd - Pointer to TVWND structure of our instance data
  242. pCurItem - Pointer to OPTITEM associate with NewType
  243. pOldOptType - Pointer to the OLD OPTTYPE
  244. pNewOptType - Pointer to the NEW OPTTYPE
  245. NewTypeUpdatePermission - TRUE if new type is not disabled
  246. Return Value:
  247. VOID
  248. Author:
  249. 21-Jun-1995 Wed 20:30:53 created -by- Daniel Chou (danielc)
  250. 31-Aug-1995 Thu 18:34:16 updated -by- Daniel Chou (danielc)
  251. Updated according to the usage of DlgCtrl.c
  252. Revision History:
  253. --*/
  254. {
  255. HWND hCtrl;
  256. BOOL Enable;
  257. UINT OldType;
  258. UINT NewType;
  259. INT swMode;
  260. if ((pOldOptType != pNewOptType) &&
  261. (pOldOptType) &&
  262. ((OldType = (UINT)pOldOptType->Type) <= TVOT_LAST)) {
  263. TVDLGITEM tdi;
  264. #if DO_IN_PLACE
  265. CPSUIINT(("OldType=%ld, NewType=%ld, hWndEdit=%08lx:%08lx:%08lx",
  266. OldType,
  267. (pNewOptType) ? pNewOptType->Type : - 1,
  268. pTVWnd->hWndEdit[0], pTVWnd->hWndEdit[1], pTVWnd->hWndEdit[2]));
  269. switch (OldType) {
  270. case TVOT_2STATES:
  271. case TVOT_3STATES:
  272. case TVOT_LISTBOX:
  273. case TVOT_CHKBOX:
  274. OldType = TVOT_COMBOBOX;
  275. break;
  276. case TVOT_SCROLLBAR:
  277. case TVOT_TRACKBAR:
  278. #if 1
  279. OldType = TVOT_UDARROW;
  280. #else
  281. if (pOldOptType->pOptParam[2].IconID <= 1) {
  282. OldType = TVOT_UDARROW;
  283. }
  284. #endif
  285. break;
  286. default:
  287. break;
  288. }
  289. pTVWnd->chWndEdit = 0;
  290. #endif
  291. CPSUIINT(("OldType=%ld, NewType=%ld", OldType,
  292. (pNewOptType) ? pNewOptType->Type : - 1));
  293. tdi = TVDlgItem[OldType];
  294. while (tdi.cItem--) {
  295. if (hCtrl = GetDlgItem(hDlg, tdi.BegID++)) {
  296. EnableWindow(hCtrl, FALSE);
  297. ShowWindow(hCtrl, SW_HIDE);
  298. CPSUIINT(("Disable/Hide hCtrl=%08lx (%ld)",
  299. hCtrl, tdi.BegID - 1));
  300. }
  301. if (tdi.BegID == (IDD_TV_TRACKBAR + 1)) {
  302. tdi.BegID = IDD_TV_SB_LOW;
  303. }
  304. }
  305. }
  306. //
  307. // Display option header, icon if any
  308. //
  309. NewType = (UINT)((pNewOptType) ? pNewOptType->Type : TVOT_NONE);
  310. if (Enable = (BOOL)(NewType <= TVOT_LAST)) {
  311. swMode = SW_SHOW;
  312. if ((!NewTypeUpdatePermission) ||
  313. (!(pTVWnd->Flags & TWF_CAN_UPDATE))) {
  314. Enable = FALSE;
  315. }
  316. } else {
  317. swMode = SW_HIDE;
  318. }
  319. ShowWindow(hCtrl = GetDlgItem(hDlg, IDD_TV_OPTION), swMode);
  320. EnableWindow(hCtrl, Enable);
  321. ShowWindow(GetDlgItem(hDlg, IDD_TV_ICON), swMode);
  322. //
  323. // We only show the hdr push icon if it is not disabled
  324. //
  325. #if 0
  326. ShowWindow(GetDlgItem(hDlg, IDD_TV_HDR_PUSH_ICON),
  327. ((pNewOptType) &&
  328. (IS_HDR_PUSH(pNewOptType)) &&
  329. (!(pNewOptType->Flags & OPTTF_TYPE_DISABLED))) ? SW_SHOW :
  330. SW_HIDE);
  331. #endif
  332. CPSUIDBG(DBG_COTD, ("OldType=%ld, NewType=%ld, Enable=%ld, swMode=%ld",
  333. (LONG)OldType, (LONG)NewType, (DWORD)Enable, (DWORD)swMode));
  334. }
  335. LRESULT
  336. CALLBACK
  337. MyEditWndProc(
  338. HWND hWnd,
  339. UINT Msg,
  340. WPARAM wParam,
  341. LPARAM lParam
  342. )
  343. /*++
  344. Routine Description:
  345. This is the subclass WNDPROC for the numberical edit control, it check
  346. valid input for the number entered.
  347. Arguments:
  348. WNDPROC standard
  349. Return Value:
  350. INT (The original WNDPROC returned), if the entered keys are not valid
  351. then it return right away without processing
  352. Author:
  353. 20-Mar-1996 Wed 15:36:48 created -by- Daniel Chou (danielc)
  354. Revision History:
  355. --*/
  356. {
  357. PTVWND pTVWnd;
  358. WNDPROC OldWndProc;
  359. if (OldWndProc = (WNDPROC)GetProp(hWnd, CPSUIPROP_WNDPROC)) {
  360. switch (Msg) {
  361. case WM_KEYDOWN:
  362. if (ChkEditKEYDOWN(hWnd, wParam)) {
  363. return(0);
  364. }
  365. break;
  366. case WM_DESTROY:
  367. SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LPARAM)OldWndProc);
  368. RemoveProp(hWnd, CPSUIPROP_WNDPROC);
  369. RemoveProp(hWnd, CPSUIPROP_PTVWND);
  370. break;
  371. default:
  372. break;
  373. }
  374. return(CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam));
  375. } else {
  376. CPSUIERR(("MyEditWndProc: GetProc(%08lx) FAILED", hWnd));
  377. return(0);
  378. }
  379. }
  380. VOID
  381. DrawPushFocusRect(
  382. HWND hWnd
  383. )
  384. /*++
  385. Routine Description:
  386. Arguments:
  387. Return Value:
  388. Author:
  389. 13-Aug-1998 Thu 11:21:49 created -by- Daniel Chou (danielc)
  390. Revision History:
  391. --*/
  392. {
  393. if (GetFocus() == hWnd) {
  394. HDC hDC;
  395. RECT rc;
  396. GetClientRect(hWnd, &rc);
  397. hDC = GetWindowDC(hWnd);
  398. rc.left += 3;
  399. rc.top += 3;
  400. rc.right -= 3;
  401. rc.bottom -= 3;
  402. if (hDC) {
  403. DrawFocusRect(hDC, &rc);
  404. ReleaseDC(hWnd, hDC);
  405. }
  406. }
  407. }
  408. LRESULT
  409. CALLBACK
  410. PushWndProc(
  411. HWND hWnd,
  412. UINT Msg,
  413. WPARAM wParam,
  414. LPARAM lParam
  415. )
  416. /*++
  417. Routine Description:
  418. This is the subclass WNDPROC for the numberical edit control, it check
  419. valid input for the number entered.
  420. Arguments:
  421. WNDPROC standard
  422. Return Value:
  423. INT (The original WNDPROC returned), if the entered keys are not valid
  424. then it return right away without processing
  425. Author:
  426. 20-Mar-1996 Wed 15:36:48 created -by- Daniel Chou (danielc)
  427. Revision History:
  428. --*/
  429. {
  430. HDC hDC;
  431. PTVWND pTVWnd;
  432. WNDPROC OldWndProc;
  433. RECT rc;
  434. LRESULT Result;
  435. if (OldWndProc = (WNDPROC)GetProp(hWnd, CPSUIPROP_WNDPROC)) {
  436. switch (Msg) {
  437. case WM_KILLFOCUS:
  438. break;
  439. case WM_SETFOCUS:
  440. InvalidateRect(hWnd, NULL, FALSE);
  441. break;
  442. case WM_PAINT:
  443. case WM_NCPAINT:
  444. Result = CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam);
  445. DrawPushFocusRect(hWnd);
  446. return(Result);
  447. case WM_GETDLGCODE:
  448. return(DLGC_WANTARROWS);
  449. case WM_KEYDOWN:
  450. CPSUIDBG(DBG_KEYS,
  451. ("PushWndProc: WM_KEYDOWN, VKey=%ld", wParam));
  452. if (ChkhWndEdit0KEYDOWN(hWnd, wParam)) {
  453. return(0);
  454. }
  455. break;
  456. case WM_DESTROY:
  457. SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LPARAM)OldWndProc);
  458. RemoveProp(hWnd, CPSUIPROP_WNDPROC);
  459. RemoveProp(hWnd, CPSUIPROP_PTVWND);
  460. break;
  461. default:
  462. break;
  463. }
  464. return(CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam));
  465. } else {
  466. CPSUIERR(("PushWndProc: GetProc(%08lx) FAILED", hWnd));
  467. return(0);
  468. }
  469. }
  470. LRESULT
  471. CALLBACK
  472. ExtWndProc(
  473. HWND hWnd,
  474. UINT Msg,
  475. WPARAM wParam,
  476. LPARAM lParam
  477. )
  478. /*++
  479. Routine Description:
  480. This is the subclass WNDPROC for the numberical edit control, it check
  481. valid input for the number entered.
  482. Arguments:
  483. WNDPROC standard
  484. Return Value:
  485. INT (The original WNDPROC returned), if the entered keys are not valid
  486. then it return right away without processing
  487. Author:
  488. 20-Mar-1996 Wed 15:36:48 created -by- Daniel Chou (danielc)
  489. Revision History:
  490. --*/
  491. {
  492. HDC hDC;
  493. PTVWND pTVWnd;
  494. WNDPROC OldWndProc;
  495. RECT rc;
  496. LRESULT Result;
  497. if (OldWndProc = (WNDPROC)GetProp(hWnd, CPSUIPROP_WNDPROC)) {
  498. switch (Msg) {
  499. case WM_KILLFOCUS:
  500. break;
  501. case WM_SETFOCUS:
  502. InvalidateRect(hWnd, NULL, FALSE);
  503. break;
  504. case WM_PAINT:
  505. case WM_NCPAINT:
  506. Result = CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam);
  507. if ((GetWindowLongPtr(hWnd, GWL_STYLE) & 0x0F) == 0) {
  508. DrawPushFocusRect(hWnd);
  509. }
  510. return(Result);
  511. case WM_GETDLGCODE:
  512. return(DLGC_WANTARROWS);
  513. case WM_KEYDOWN:
  514. CPSUIDBG(DBG_KEYS,
  515. ("ExtWndProc: WM_KEYDOWN, VKey=%ld", wParam));
  516. switch (wParam) {
  517. case VK_LEFT:
  518. case VK_BACK:
  519. case VK_RIGHT:
  520. if (pTVWnd = (PTVWND)GetProp(hWnd, CPSUIPROP_PTVWND)) {
  521. switch (wParam) {
  522. case VK_LEFT:
  523. case VK_BACK:
  524. if (pTVWnd->hWndEdit[0]) {
  525. SetFocus(pTVWnd->hWndEdit[0]);
  526. return(0);
  527. }
  528. case VK_RIGHT:
  529. return(0);
  530. default:
  531. break;
  532. }
  533. }
  534. break;
  535. }
  536. break;
  537. case WM_DESTROY:
  538. SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LPARAM)OldWndProc);
  539. RemoveProp(hWnd, CPSUIPROP_WNDPROC);
  540. RemoveProp(hWnd, CPSUIPROP_PTVWND);
  541. break;
  542. default:
  543. break;
  544. }
  545. return(CallWindowProc(OldWndProc, hWnd, Msg, wParam, lParam));
  546. } else {
  547. CPSUIERR(("MyCBWndProc: GetProc(%08lx) FAILED", hWnd));
  548. return(0);
  549. }
  550. }
  551. VOID
  552. InitDlgCtrl(
  553. HWND hDlg,
  554. PTVWND pTVWnd
  555. )
  556. /*++
  557. Routine Description:
  558. Arguments:
  559. Return Value:
  560. Author:
  561. 05-Jul-1995 Wed 17:49:58 created -by- Daniel Chou (danielc)
  562. Revision History:
  563. --*/
  564. {
  565. HWND hWndTV = pTVWnd->hWndTV;
  566. HFONT hFont;
  567. HWND hCtrl;
  568. RECT rc;
  569. RECT rc2;
  570. DWORD dw;
  571. WORD tECB;
  572. WORD bECB;
  573. WORD tLB;
  574. WORD bLB;
  575. WORD cyUnit;
  576. WORD cyStates;
  577. LONG tOpt;
  578. LONG bOpt;
  579. LONG cx;
  580. LONG cy;
  581. UINT i;
  582. WORD InitItemIdx = 0xFFFE;
  583. ReCreateLBCB(hDlg, IDD_TV_LB, TRUE);
  584. dw = ReCreateLBCB(hDlg, IDD_TV_CB, FALSE);
  585. CreateTrackBar(hDlg, IDD_TV_TRACKBAR);
  586. CreateUDArrow(hDlg, IDD_TV_UDARROW_EDIT, IDD_TV_UDARROW, 0, 100, 50);
  587. #if DO_IN_PLACE
  588. CtrlIDrcWnd(hDlg, IDD_TV_UDARROW, &rc);
  589. CtrlIDrcWnd(hDlg, IDD_TV_UDARROW_EDIT, &rc2);
  590. pTVWnd->cxCBAdd = LOWORD(dw);
  591. pTVWnd->cxMaxUDEdit += LOWORD(dw);
  592. CtrlIDrcWnd(hDlg, IDD_TV_CHKBOX, &rc);
  593. pTVWnd->cxChkBoxAdd = (WORD)(rc.right - rc.left);
  594. pTVWnd->cxChkBoxAdd = (WORD)GetSystemMetrics(SM_CXSMICON);
  595. CPSUIINT(("cxCBAdd = %ld, cxChkBoxAdd=%ld",
  596. pTVWnd->cxCBAdd, pTVWnd->cxChkBoxAdd));
  597. if (hCtrl = GetDlgItem(hDlg, IDD_TV_EDIT_EDIT)) {
  598. SetProp(hCtrl,
  599. CPSUIPROP_WNDPROC,
  600. (HANDLE)GetWindowLongPtr(hCtrl, GWLP_WNDPROC));
  601. SetProp(hCtrl, CPSUIPROP_PTVWND, (HANDLE)pTVWnd);
  602. SetWindowLongPtr(hCtrl, GWLP_WNDPROC, (LPARAM)MyEditWndProc);
  603. }
  604. if (hCtrl = GetDlgItem(hDlg, IDD_TV_PUSH)) {
  605. SetProp(hCtrl,
  606. CPSUIPROP_WNDPROC,
  607. (HANDLE)GetWindowLongPtr(hCtrl, GWLP_WNDPROC));
  608. SetProp(hCtrl, CPSUIPROP_PTVWND, (HANDLE)pTVWnd);
  609. SetWindowLongPtr(hCtrl, GWLP_WNDPROC, (LPARAM)PushWndProc);
  610. }
  611. hFont = pTVWnd->hTVFont[0];
  612. #endif
  613. for (i = 0; i < COUNT_ARRAY(TVDlgItem); i++) {
  614. TVDLGITEM tdi;
  615. HWND hCtrl;
  616. tdi = TVDlgItem[i];
  617. while (tdi.cItem--) {
  618. if (hCtrl = GetDlgItem(hDlg, tdi.BegID++)) {
  619. ShowWindow(hCtrl, SW_HIDE);
  620. EnableWindow(hCtrl, FALSE);
  621. SETCTRLDATA(hCtrl, CTRLS_TV_STATIC, 0);
  622. #if DO_IN_PLACE
  623. SetParent(hCtrl, hWndTV);
  624. SendMessage(hCtrl, WM_SETFONT, (WPARAM)hFont, 0);
  625. SetWindowLongPtr(hCtrl,
  626. GWL_EXSTYLE,
  627. GetWindowLongPtr(hCtrl, GWL_EXSTYLE) |
  628. WS_EX_CONTEXTHELP);
  629. #endif
  630. if (tdi.BegID == (IDD_TV_TRACKBAR + 1)) {
  631. tdi.BegID = IDD_TV_SB_LOW;
  632. }
  633. }
  634. }
  635. }
  636. //
  637. // Set MSAA name label as a child of treeview dialog
  638. //
  639. if (hCtrl = GetDlgItem(hDlg, IDD_TV_MSAA_NAME))
  640. {
  641. SetParent(hCtrl, hWndTV);
  642. }
  643. //
  644. // Figure how to expand/shrink the listbox in the treeview page, the
  645. // maximum for non ExtChkBox/ExtPush is at bottom of Extended control
  646. // otherwise the maximu is at top of Extended control - space between
  647. // bottom of extended control and option header bottom
  648. //
  649. #if DO_IN_PLACE
  650. hCtrl = GetDlgItem(hWndTV, IDD_TV_EXTPUSH);
  651. #else
  652. hCtrl = GetDlgItem(hDlg, IDD_TV_EXTPUSH);
  653. #endif
  654. ShowWindow(hCtrl, SW_HIDE);
  655. EnableWindow(hCtrl, FALSE);
  656. SetProp(hCtrl,
  657. CPSUIPROP_WNDPROC,
  658. (HANDLE)GetWindowLongPtr(hCtrl, GWLP_WNDPROC));
  659. SetProp(hCtrl, CPSUIPROP_PTVWND, (HANDLE)pTVWnd);
  660. SetWindowLongPtr(hCtrl, GWLP_WNDPROC, (LPARAM)ExtWndProc);
  661. #if DO_IN_PLACE
  662. hCtrl = CtrlIDrcWnd(hWndTV, IDD_TV_EXTCHKBOX, &rc);
  663. #else
  664. hCtrl = CtrlIDrcWnd(hDlg, IDD_TV_EXTCHKBOX, &rc);
  665. #endif
  666. ShowWindow(hCtrl, SW_HIDE);
  667. EnableWindow(hCtrl, FALSE);
  668. SETCTRLDATA(hCtrl, CTRLS_TV_STATIC, 0);
  669. pTVWnd->yECB =
  670. tECB = (WORD)rc.top;
  671. bECB = (WORD)rc.bottom;
  672. #if DO_IN_PLACE
  673. SetProp(hCtrl,
  674. CPSUIPROP_WNDPROC,
  675. (HANDLE)GetWindowLongPtr(hCtrl, GWLP_WNDPROC));
  676. SetProp(hCtrl, CPSUIPROP_PTVWND, (HANDLE)pTVWnd);
  677. SetWindowLongPtr(hCtrl, GWLP_WNDPROC, (LPARAM)ExtWndProc);
  678. CtrlIDrcWnd(hWndTV, IDD_TV_LB, &rc);
  679. #else
  680. CtrlIDrcWnd(hDlg, IDD_TV_LB, &rc);
  681. #endif
  682. pTVWnd->xCtrls = (WORD)rc.left;
  683. pTVWnd->tLB =
  684. tLB = (WORD)rc.top;
  685. bLB = (WORD)rc.bottom;
  686. hCtrl = CtrlIDrcWnd(hDlg, IDD_TV_OPTION, &rc);
  687. ShowWindow(hCtrl, SW_HIDE);
  688. EnableWindow(hCtrl, TRUE);
  689. SETCTRLDATA(hCtrl, CTRLS_TV_STATIC, 0);
  690. pTVWnd->yLB[0] = (WORD)(tECB - (rc.bottom - bECB) - tLB);
  691. pTVWnd->yLB[1] = bECB - tLB;
  692. tOpt = tLB;
  693. bOpt = tECB;
  694. CPSUIDBG(DBG_INITDLG, ("!! yLB=(%ld / %ld) !!",
  695. pTVWnd->yLB[0], pTVWnd->yLB[1]));
  696. //
  697. // Figure how to move 2 states, and 3 states, basically this is range
  698. // in the space between top and bottom of options header
  699. //
  700. #if DO_IN_PLACE
  701. CtrlIDrcWnd(hWndTV, IDD_3STATES_1, &rc);
  702. #else
  703. CtrlIDrcWnd(hDlg, IDD_3STATES_1, &rc);
  704. #endif
  705. cyStates = (WORD)(rc.bottom - rc.top);
  706. //
  707. // For 2/3 states, there is top, increment, one with extended and one not
  708. //
  709. cy = (LONG)(bLB - tLB);
  710. cyUnit = (WORD)((cy - (cyStates * 2) + 1) / 3);
  711. pTVWnd->SI2[0].Top = tLB + (WORD)cyUnit;
  712. pTVWnd->SI2[0].Inc = (WORD)(cyStates + cyUnit);
  713. cyUnit = (WORD)((cy - (cyStates * 3) + 2) / 4);
  714. pTVWnd->SI3[0].Top = tLB + (WORD)cyUnit;
  715. pTVWnd->SI3[0].Inc = (WORD)(cyStates + cyUnit);
  716. cy = (LONG)(bOpt - tOpt);
  717. cyUnit = (WORD)((cy - (cyStates * 2) + 1) / 3);
  718. pTVWnd->SI2[1].Top = (WORD)tOpt + (WORD)cyUnit;
  719. pTVWnd->SI2[1].Inc = (WORD)(cyStates + cyUnit);
  720. cyUnit = (WORD)((cy - (cyStates * 3) + 2) / 4);
  721. pTVWnd->SI3[1].Top = (WORD)tOpt + (WORD)cyUnit;
  722. pTVWnd->SI3[1].Inc = (WORD)(cyStates + cyUnit);
  723. CPSUIINT(("SI2[0]=%d, %d, SI2[1]=%d, %d, SI3[0]=%d, %d, SI3[1]=%d, %d",
  724. pTVWnd->SI2[0].Top, pTVWnd->SI2[0].Inc,
  725. pTVWnd->SI2[1].Top, pTVWnd->SI2[1].Inc,
  726. pTVWnd->SI3[0].Top, pTVWnd->SI3[0].Inc,
  727. pTVWnd->SI3[1].Top, pTVWnd->SI3[1].Inc));
  728. //
  729. // Change the static rectangle to the static ICON style and how big the
  730. // icon will stretch to
  731. //
  732. hCtrl = CtrlIDrcWnd(hDlg, IDD_TV_ICON, &rc);
  733. dw = (DWORD)GetWindowLongPtr(hCtrl, GWL_STYLE);
  734. dw &= ~SS_TYPEMASK;
  735. dw |= (SS_ICON | SS_CENTERIMAGE);
  736. SetWindowLongPtr(hCtrl, GWL_STYLE, dw);
  737. ShowWindow(hCtrl, SW_HIDE);
  738. EnableWindow(hCtrl, TRUE);
  739. SETCTRLDATA(hCtrl, CTRLS_TV_STATIC, 0);
  740. //
  741. // We want to make sure that the cx/cy TVICON is the same size, if not
  742. // then we will correct it and adjust it to the right size
  743. //
  744. #if ICON_SIZE_ANY
  745. if ((cx = rc.right - rc.left) != (cy = rc.bottom - rc.top)) {
  746. CPSUIINT(("\nORIGINAL TVIcon=(%ld, %ld) %ld x %ld",
  747. rc.left, rc.top, cx, cy));
  748. cy = cx;
  749. }
  750. #else
  751. cx =
  752. cy = 32;
  753. #endif
  754. rc.left = rc.left + ((rc.right - rc.left - cx + 1) / 2);
  755. rc.top = (LONG)(tOpt + ((bOpt - tOpt - cy + 1) / 2));
  756. SetWindowPos(hCtrl, NULL, rc.left, rc.top, cx, cy, SWP_NOZORDER);
  757. CPSUIINT(("\nCHANGED TVIcon=(%ld, %ld) %ld x %ld",
  758. rc.left, rc.top, cx, cy));
  759. pTVWnd->cxcyTVIcon = (WORD)cx;
  760. CPSUIDBG(DBG_CTVWND, ("\nIDD_TV_ICON Style=%08lx", dw));
  761. //
  762. // now check it out ECB icon
  763. //
  764. hCtrl = CtrlIDrcWnd(hDlg, IDD_TV_ECB_ICON, &rc);
  765. dw = (DWORD)GetWindowLongPtr(hCtrl = GetDlgItem(hDlg, IDD_TV_ECB_ICON), GWL_STYLE);
  766. dw &= ~SS_TYPEMASK;
  767. dw |= (SS_ICON | SS_CENTERIMAGE);
  768. SetWindowLongPtr(hCtrl, GWL_STYLE, dw);
  769. //
  770. // We want to make sure that the cx/cy ECBICON is the same size, if not
  771. // then we will correct it and adjust it to the right size
  772. //
  773. if ((cx = rc.right - rc.left) != (cy = rc.bottom - rc.top)) {
  774. CPSUIINT(("\nORIGINAL ECBIcon=(%ld, %ld) %ld x %ld",
  775. rc.left, rc.top, cx, cy));
  776. rc.right = rc.left + (cx = cy);
  777. SetWindowPos(hCtrl, NULL, rc.left, rc.top, cx, cy, SWP_NOZORDER);
  778. CPSUIINT(("\nCHANGED ECBIcon=(%ld, %ld) %ld x %ld",
  779. rc.left, rc.top, cx, cy));
  780. }
  781. pTVWnd->cxcyECBIcon = (WORD)cx;
  782. CPSUIDBG(DBG_CTVWND,
  783. ("\nTVIcon=%ld x %ld, ECBIcon=%ld x %ld",
  784. (DWORD)pTVWnd->cxcyTVIcon, (DWORD)pTVWnd->cxcyTVIcon,
  785. (DWORD)pTVWnd->cxcyECBIcon, (DWORD)pTVWnd->cxcyECBIcon));
  786. }
  787. HTREEITEM
  788. SelectFirstVisibleOptItem(
  789. PTVWND pTVWnd,
  790. HTREEITEM hItem
  791. )
  792. /*++
  793. Routine Description:
  794. Arguments:
  795. Return Value:
  796. Author:
  797. 21-Sep-1995 Thu 14:31:01 created -by- Daniel Chou (danielc)
  798. Revision History:
  799. --*/
  800. {
  801. HWND hWndTV = pTVWnd->hWndTV;
  802. //
  803. // Do all the siblings and for each calling the child to do their work
  804. //
  805. while (hItem) {
  806. POPTITEM pItem;
  807. TV_ITEM tvi;
  808. tvi.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
  809. tvi.hItem = hItem;
  810. TreeView_GetItem(hWndTV, &tvi);
  811. //
  812. // Now check if we can do it
  813. //
  814. if ((pItem = GetOptions(pTVWnd, tvi.lParam)) &&
  815. (pItem->pOptType) &&
  816. (!IS_HDR_PUSH(pItem->pOptType)) &&
  817. (pItem->pOptType->Type <= TVOT_LAST)) {
  818. TreeView_SelectItem(hWndTV, hItem);
  819. return(hItem);
  820. }
  821. if ((tvi.cChildren) &&
  822. (tvi.state & TVIS_EXPANDED) &&
  823. (hItem = TreeView_GetChild(hWndTV, hItem)) &&
  824. (hItem = SelectFirstVisibleOptItem(pTVWnd, hItem))) {
  825. return(hItem);
  826. }
  827. hItem = TreeView_GetNextSibling(hWndTV, hItem);
  828. }
  829. return(hItem);
  830. }
  831. UINT
  832. CountRevertOptItem(
  833. PTVWND pTVWnd,
  834. POPTITEM pOptItem,
  835. HTREEITEM hItem,
  836. DWORD Flags
  837. )
  838. /*++
  839. Routine Description:
  840. Arguments:
  841. Return Value:
  842. Author:
  843. 21-Sep-1995 Thu 14:31:01 created -by- Daniel Chou (danielc)
  844. Revision History:
  845. --*/
  846. {
  847. HWND hWndTV = pTVWnd->hWndTV;
  848. POPTITEM pLastItem;
  849. UINT cRevert = 0;
  850. NM_TREEVIEW NMtv;
  851. //
  852. // Do all the siblings and for each calling the child to do their work
  853. //
  854. if ((hWndTV) && (hItem)) {
  855. pOptItem =
  856. pLastItem = NULL;
  857. } else {
  858. Flags |= CROIF_DO_SIBLING;
  859. hItem = (HTREEITEM)1;
  860. if (!pOptItem) {
  861. pOptItem = pTVWnd->ComPropSheetUI.pOptItem;
  862. pLastItem = pTVWnd->pLastItem;
  863. } else {
  864. pLastItem = pOptItem;
  865. }
  866. }
  867. while (hItem) {
  868. POPTITEM pItem;
  869. PDEVHTADJDATA pDevHTAdjData;
  870. POPTTYPE pOptType;
  871. POPTPARAM pOptParam;
  872. TV_ITEM tvi;
  873. UINT cAdd = 0;
  874. if (pOptItem) {
  875. pItem = pOptItem;
  876. } else {
  877. tvi.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
  878. tvi.hItem = hItem;
  879. TreeView_GetItem(hWndTV, &tvi);
  880. pItem = GetOptions(pTVWnd, tvi.lParam);
  881. }
  882. //
  883. // Now check if we can do it
  884. //
  885. if ((pItem) &&
  886. ((pItem->Flags & OPTIF_CHANGEONCE) ||
  887. (Flags & CROIF_REVERT_DEF2)) &&
  888. (pOptType = pItem->pOptType)) {
  889. LPBYTE pDefSelMem;
  890. LPVOID pDefSel;
  891. LPVOID pvAlloc;
  892. DWORD DefOPTIF;
  893. pvAlloc =
  894. pDefSel = (LPVOID)(pDefSelMem = (LPBYTE)_OI_PDEFSEL(pItem));
  895. if (Flags & CROIF_REVERT_DEF2) {
  896. DefOPTIF = (DWORD)_OI_DEF_OPTIF2(pItem);
  897. pDefSelMem += _OI_CBPDEFSEL(pItem);
  898. pDefSel = _OI_PDEFSEL2(pItem);
  899. } else {
  900. DefOPTIF = (DWORD)_OI_DEF_OPTIF(pItem);
  901. }
  902. switch (pOptType->Type) {
  903. case TVOT_EDITBOX:
  904. if (!pvAlloc) {
  905. CPSUIASSERT(0, "CountRevertOptItem(EDITBOX:pvAlloc=NULL)", pvAlloc, 0);
  906. break;
  907. }
  908. if (pTVWnd->Flags & TWF_ANSI_CALL) {
  909. CPSUIINT(("pEdit=%hs, pDefEdit=%hs",
  910. pItem->pSel, pDefSel));
  911. if (lstrcmpA((LPSTR)(LONG_PTR)pItem->Sel, (LPSTR)pDefSelMem)) {
  912. cAdd = 1;
  913. if (Flags & CROIF_REVERT) {
  914. lstrcpyA((LPSTR)pItem->pSel, (LPSTR)pDefSelMem);
  915. }
  916. }
  917. } else {
  918. CPSUIINT(("pEdit=%s, pDefEdit=%s",
  919. pItem->pSel, pDefSel));
  920. if (lstrcmp(pItem->pSel, (LPWSTR)pDefSelMem)) {
  921. cAdd = 1;
  922. if (Flags & CROIF_REVERT) {
  923. lstrcpy((LPWSTR)pItem->pSel, (LPWSTR)pDefSelMem);
  924. }
  925. }
  926. }
  927. break;
  928. case TVOT_PUSHBUTTON:
  929. pOptParam = pOptType->pOptParam;
  930. switch (pOptParam->Style) {
  931. case PUSHBUTTON_TYPE_HTSETUP:
  932. if (!pvAlloc) {
  933. CPSUIASSERT(0, "CountRevertOptItem(HTSETUP:pvAlloc=NULL)", pvAlloc, 0);
  934. break;
  935. }
  936. pDevHTAdjData = (PDEVHTADJDATA)(pOptParam->pData);
  937. if (memcmp(pDefSelMem,
  938. pDevHTAdjData->pAdjHTInfo,
  939. sizeof(DEVHTINFO))) {
  940. cAdd = 1;
  941. if (Flags & CROIF_REVERT) {
  942. CopyMemory(pDevHTAdjData->pAdjHTInfo,
  943. pDefSelMem,
  944. sizeof(DEVHTINFO));
  945. }
  946. }
  947. break;
  948. case PUSHBUTTON_TYPE_HTCLRADJ:
  949. if (!pvAlloc) {
  950. CPSUIASSERT(0, "CountRevertOptItem(HTCLRADJ:pvAlloc=NULL)", pvAlloc, 0);
  951. break;
  952. }
  953. if (memcmp(pDefSelMem,
  954. pOptParam->pData,
  955. sizeof(COLORADJUSTMENT))) {
  956. cAdd = 1;
  957. if (Flags & CROIF_REVERT) {
  958. CopyMemory(pOptParam->pData,
  959. pDefSelMem,
  960. sizeof(COLORADJUSTMENT));
  961. }
  962. }
  963. break;
  964. default:
  965. break;
  966. }
  967. break;
  968. default:
  969. if (pItem->pSel != (LPVOID)pDefSel) {
  970. cAdd = 1;
  971. if (Flags & CROIF_REVERT) {
  972. pItem->pSel = pDefSel;
  973. }
  974. }
  975. break;
  976. }
  977. if ((pItem->pExtChkBox) &&
  978. (!(pItem->Flags & OPTIF_EXT_IS_EXTPUSH)) &&
  979. ((pItem->Flags & OPTIF_ECB_MASK) !=
  980. (DefOPTIF & OPTIF_ECB_MASK))) {
  981. cAdd = 1;
  982. if (Flags & CROIF_REVERT) {
  983. pItem->Flags &= ~OPTIF_ECB_MASK;
  984. pItem->Flags |= (DWORD)(DefOPTIF & OPTIF_ECB_MASK);
  985. }
  986. }
  987. if (cAdd) {
  988. if (Flags & CROIF_REVERT) {
  989. pItem->Flags |= OPTIF_CHANGED;
  990. //
  991. // Call the callback function if there is one, and update the current
  992. // selected item after changing the content
  993. //
  994. DoCallBack(pTVWnd->hDlgTV,
  995. pTVWnd,
  996. pItem,
  997. pItem->pSel,
  998. NULL,
  999. NULL,
  1000. 0,
  1001. CPSUICB_REASON_SEL_CHANGED);
  1002. //
  1003. // Refresh the current selected item data, otherwise the data may
  1004. // not be consistent
  1005. //
  1006. NMtv.itemNew.hItem = TreeView_GetSelection(pTVWnd->hWndTV);
  1007. NMtv.itemNew.mask = TVIF_HANDLE | TVIF_PARAM;
  1008. if (TreeView_GetItem(pTVWnd->hWndTV, &(NMtv.itemNew))) {
  1009. NMtv.itemOld = NMtv.itemNew;
  1010. SetupTVSelect(pTVWnd->hDlgTV, &NMtv, STVS_REINIT);
  1011. }
  1012. }
  1013. CPSUIOPTITEM(DBGITEM_CREVERT,
  1014. pTVWnd,
  1015. "CountRevertOptItem",
  1016. 0,
  1017. pItem);
  1018. }
  1019. cRevert += cAdd;
  1020. }
  1021. if (pOptItem) {
  1022. if (++pOptItem > pLastItem) {
  1023. hItem = NULL;
  1024. } else {
  1025. ++(ULONG_PTR)hItem;
  1026. }
  1027. } else {
  1028. if (tvi.cChildren) {
  1029. cRevert += CountRevertOptItem(pTVWnd,
  1030. NULL,
  1031. TreeView_GetChild(hWndTV, hItem),
  1032. Flags | CROIF_DO_SIBLING);
  1033. }
  1034. hItem = (Flags & CROIF_DO_SIBLING) ?
  1035. TreeView_GetNextSibling(hWndTV, hItem) : NULL;
  1036. }
  1037. }
  1038. CPSUIDBG(DBG_CTVWND, ("hWndTV=%08lx, hItem=%08lx, pOptItem=%08lx, cRevert=%u",
  1039. hWndTV, hItem, pOptItem, cRevert));
  1040. return(cRevert);
  1041. }
  1042. CPSUICALLBACK
  1043. InternalRevertDef2(
  1044. PCPSUICBPARAM pCBParam
  1045. )
  1046. /*++
  1047. Routine Description:
  1048. Arguments:
  1049. Return Value:
  1050. Author:
  1051. 21-Sep-1995 Thu 10:50:19 created -by- Daniel Chou (danielc)
  1052. Revision History:
  1053. --*/
  1054. {
  1055. PTVWND pTVWnd;
  1056. POPTITEM pItem;
  1057. UINT cRevert;
  1058. CPSUIINT(("INTERNAL CALLBACK: GOT Internal RevertOptItem() PUSH"));
  1059. pTVWnd = GET_PTVWND(pCBParam->hDlg);
  1060. pItem = pCBParam->pCurItem;
  1061. CPSUIOPTITEM(DBGITEM_REVERT,
  1062. pTVWnd,
  1063. "InternalRevertOptItem",
  1064. 2,
  1065. pItem);
  1066. cRevert = CountRevertOptItem(pTVWnd,
  1067. NULL,
  1068. NULL,
  1069. CROIF_REVERT | CROIF_REVERT_DEF2);
  1070. //
  1071. // Now is the time to hide the push button
  1072. //
  1073. return((cRevert) ? CPSUICB_ACTION_OPTIF_CHANGED : CPSUICB_ACTION_NONE);
  1074. }
  1075. CPSUICALLBACK
  1076. InternalRevertOptItem(
  1077. PCPSUICBPARAM pCBParam
  1078. )
  1079. /*++
  1080. Routine Description:
  1081. Arguments:
  1082. Return Value:
  1083. Author:
  1084. 21-Sep-1995 Thu 10:50:19 created -by- Daniel Chou (danielc)
  1085. Revision History:
  1086. --*/
  1087. {
  1088. PTVWND pTVWnd;
  1089. POPTITEM pItem;
  1090. UINT cRevert;
  1091. CPSUIINT(("INTERNAL CALLBACK: GOT Internal RevertOptItem() PUSH"));
  1092. pTVWnd = GET_PTVWND(pCBParam->hDlg);
  1093. pItem = pCBParam->pCurItem;
  1094. CPSUIOPTITEM(DBGITEM_REVERT,
  1095. pTVWnd,
  1096. "InternalRevertOptItem",
  1097. 2,
  1098. pItem);
  1099. cRevert = CountRevertOptItem(pTVWnd,
  1100. pItem,
  1101. _OI_HITEM(pItem),
  1102. CROIF_REVERT);
  1103. //
  1104. // Now is the time to hide the push button
  1105. //
  1106. #if DO_IN_PLACE
  1107. return((cRevert) ? CPSUICB_ACTION_OPTIF_CHANGED : CPSUICB_ACTION_NONE);
  1108. #else
  1109. if (cRevert) {
  1110. if ((pItem >= pTVWnd->ComPropSheetUI.pOptItem) &&
  1111. (pItem <= pTVWnd->pLastItem)) {
  1112. pItem->Flags |= OPTIF_CHANGED;
  1113. } else {
  1114. UpdateTreeViewItem(pCBParam->hDlg, pTVWnd, pItem, TRUE);
  1115. }
  1116. return(CPSUICB_ACTION_OPTIF_CHANGED);
  1117. } else {
  1118. return(CPSUICB_ACTION_NONE);
  1119. }
  1120. #endif
  1121. }
  1122. BOOL
  1123. SetTVItemImage(
  1124. PTVWND pTVWnd,
  1125. TV_DISPINFO *ptvdi
  1126. )
  1127. /*++
  1128. Routine Description:
  1129. This function either insert a item to the tree or reset the content of
  1130. the tree item
  1131. Arguments:
  1132. pTVWnd - Pointer to the TVWND for common UI instance data
  1133. ptvi - pointer to TV_ITEM strucuture.
  1134. Return Value:
  1135. BOOLEAN
  1136. Author:
  1137. 06-Jul-1995 Thu 19:38:51 created -by- Daniel Chou (danielc)
  1138. 31-Aug-1995 Thu 12:03:32 updated -by- Daniel Chou (danielc)
  1139. Updated so it will not take pStrName anymore and it will also insert
  1140. the item at this function
  1141. Revision History:
  1142. --*/
  1143. {
  1144. TV_ITEM *ptvi = &(ptvdi->item);
  1145. if (ptvi->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) {
  1146. POPTTYPE pOptType;
  1147. POPTITEM pItem;
  1148. ULONG_PTR IconResID;
  1149. DWORD IntIconID;
  1150. pItem = GetOptions(pTVWnd, ptvi->lParam);
  1151. if (IS_HDR_PUSH(pOptType = GET_POPTTYPE(pItem))) {
  1152. IconResID = GETSELICONID(pItem);
  1153. IntIconID = IDI_CPSUI_GENERIC_OPTION;
  1154. } else {
  1155. PEXTCHKBOX pECB;
  1156. POPTPARAM pOptParam = pOptType->pOptParam;
  1157. switch (pOptType->Type) {
  1158. case TVOT_COMBOBOX:
  1159. case TVOT_LISTBOX:
  1160. if ((DWORD)pItem->Sel >= (DWORD)pOptType->Count) {
  1161. pOptParam = &pTVWnd->OptParamNone;
  1162. break;
  1163. }
  1164. case TVOT_2STATES:
  1165. case TVOT_3STATES:
  1166. pOptParam += (DWORD)pItem->Sel;
  1167. break;
  1168. case TVOT_CHKBOX:
  1169. case TVOT_TRACKBAR:
  1170. case TVOT_SCROLLBAR:
  1171. case TVOT_UDARROW:
  1172. case TVOT_PUSHBUTTON:
  1173. case TVOT_EDITBOX:
  1174. break;
  1175. }
  1176. IconResID = GET_ICONID(pOptParam, OPTPF_ICONID_AS_HICON);
  1177. IntIconID = IDI_CPSUI_GENERIC_ITEM;
  1178. }
  1179. ptvi->iSelectedImage =
  1180. ptvi->iImage = (INT)GetIcon16Idx(pTVWnd,
  1181. _OI_HINST(pItem),
  1182. IconResID,
  1183. IntIconID);
  1184. ptvi->hItem = _OI_HITEM(pItem);
  1185. ptvi->mask = (TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_HANDLE);
  1186. SendMessage(pTVWnd->hWndTV, TVM_SETITEM, 0, (LPARAM)ptvi);
  1187. CPSUIOPTITEM(DBGITEM_NEWICON, pTVWnd, "SetTVItemImage", 0, pItem);
  1188. }
  1189. return(TRUE);
  1190. }
  1191. VOID
  1192. SetTVItemState(
  1193. PTVWND pTVWnd,
  1194. TV_INSERTSTRUCT *ptvins,
  1195. POPTITEM pCurItem
  1196. )
  1197. /*++
  1198. Routine Description:
  1199. This function either insert a item to the tree or reset the content of
  1200. the tree item
  1201. Arguments:
  1202. pTVWnd - Pointer to the TVWND for common UI instance data
  1203. ptvins - pointer to TV_INSERTSTRUCT strucuture, if it is not NULL then
  1204. this item will be inserted to the tree
  1205. pCurItem - Pointer to the current OPTITEM
  1206. Return Value:
  1207. WORD - Icon resource ID
  1208. Author:
  1209. 06-Jul-1995 Thu 19:38:51 created -by- Daniel Chou (danielc)
  1210. 31-Aug-1995 Thu 12:03:32 updated -by- Daniel Chou (danielc)
  1211. Updated so it will not take pStrName anymore and it will also insert
  1212. the item at this function
  1213. 20-Jul-1996 Sat 00:26:33 updated -by- Daniel Chou (danielc)
  1214. Fixed the internationalize problem for compsition dynamic user data
  1215. Revision History:
  1216. --*/
  1217. {
  1218. POPTTYPE pOptType;
  1219. TV_INSERTSTRUCT tvins;
  1220. TVLP tvlp;
  1221. ULONG_PTR IconResID;
  1222. DWORD IntIconID;
  1223. DWORD Flags;
  1224. GSBUF_DEF(pCurItem, MAX_RES_STR_CHARS * 2);
  1225. if (ptvins) {
  1226. tvins = *ptvins;
  1227. tvins.item.mask |= TVIF_TEXT |
  1228. TVIF_PARAM |
  1229. TVIF_IMAGE |
  1230. TVIF_SELECTEDIMAGE |
  1231. TVIF_STATE;
  1232. } else {
  1233. CPSUIASSERT(0, "SetTVItemState, NULL hItem", _OI_HITEM(pCurItem),0);
  1234. if (!(tvins.item.hItem = _OI_HITEM(pCurItem))) {
  1235. CPSUIOPTITEM(DBG_ASSERT,
  1236. pTVWnd,
  1237. "SetTVItemState(NULL)", 1,
  1238. pCurItem);
  1239. return;
  1240. }
  1241. tvins.item.state =
  1242. tvins.item.stateMask = 0;
  1243. tvins.item.mask = TVIF_HANDLE |
  1244. TVIF_PARAM |
  1245. TVIF_TEXT |
  1246. TVIF_IMAGE |
  1247. TVIF_SELECTEDIMAGE |
  1248. TVIF_STATE;
  1249. }
  1250. if ((pCurItem >= pTVWnd->ComPropSheetUI.pOptItem) &&
  1251. (pCurItem <= pTVWnd->pLastItem)) {
  1252. tvlp.ItemIdx = (WORD)(pCurItem - pTVWnd->ComPropSheetUI.pOptItem);
  1253. } else if ((pCurItem >= PBEG_INTOPTITEM(pTVWnd)) &&
  1254. (pCurItem <= PEND_INTOPTITEM(pTVWnd))) {
  1255. tvlp.ItemIdx = (WORD)IIDX_INTOPTITEM(pTVWnd, pCurItem);
  1256. } else {
  1257. CPSUIERR(("ERROR: SetupTVItemState(Invalid pOptItem=%08lx)", pCurItem));
  1258. tvlp.ItemIdx = INTIDX_TVROOT;
  1259. }
  1260. tvins.item.pszText = GSBUF_BUF;
  1261. //
  1262. // Check if we need to overlay CPSUI provided icons
  1263. //
  1264. tvlp.Flags = ((Flags = pCurItem->Flags) & OPTIF_OVERLAY_WARNING_ICON) ?
  1265. TVLPF_WARNING : 0;
  1266. if (Flags & (OPTIF_OVERLAY_STOP_ICON | OPTIF_HIDE)) {
  1267. tvlp.Flags |= TVLPF_STOP;
  1268. }
  1269. if (Flags & OPTIF_OVERLAY_NO_ICON) {
  1270. tvlp.Flags |= TVLPF_NO;
  1271. }
  1272. if (IS_HDR_PUSH(pOptType = GET_POPTTYPE(pCurItem))) {
  1273. POPTITEM pRootItem = PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT);
  1274. if (pCurItem == pRootItem) {
  1275. GSBUF_FLAGS |= GBF_PREFIX_OK;
  1276. GSBUF_COMPOSE(LODWORD(pCurItem->UserData), pCurItem->pName, 0, 0);
  1277. } else if (pCurItem == PIDX_INTOPTITEM(pTVWnd, INTIDX_OPTIONS)) {
  1278. //
  1279. // Make it 'Document Options' here
  1280. //
  1281. GSBUF_GETINTSTR(IDS_INT_CPSUI_OPTIONS);
  1282. } else {
  1283. GSBUF_GETSTR(pCurItem->pName);
  1284. }
  1285. tvlp.cName = (BYTE)(GSBUF_COUNT);
  1286. CPSUIINT(("HeaderItem (%ld): '%ws'", tvlp.cName, GSBUF_BUF));
  1287. IconResID = GETSELICONID(pCurItem);
  1288. IntIconID = IDI_CPSUI_GENERIC_OPTION;
  1289. #if DO_IN_PLACE
  1290. if ((!IconResID) ||
  1291. (!GetIcon16Idx(pTVWnd,
  1292. _OI_HINST(pCurItem),
  1293. IconResID,
  1294. IDI_CPSUI_EMPTY))) {
  1295. tvins.item.mask &= ~(TVIF_IMAGE | TVIF_SELECTEDIMAGE);
  1296. tvlp.Flags |= TVLPF_EMPTYICON;
  1297. }
  1298. #endif
  1299. } else {
  1300. POPTPARAM pOptParam;
  1301. PEXTCHKBOX pECB;
  1302. LPTSTR pEndText = NULL;
  1303. UINT Idx;
  1304. BOOL RealECBChecked;
  1305. BOOL EndTextAddSpace;
  1306. #if DO_IN_PLACE
  1307. tvins.item.mask &= ~(TVIF_IMAGE | TVIF_SELECTEDIMAGE);
  1308. tvlp.Flags |= TVLPF_EMPTYICON;
  1309. #endif
  1310. GSBUF_GETSTR(pCurItem->pName);
  1311. pOptParam = pOptType->pOptParam;
  1312. if (RealECBChecked = REAL_ECB_CHECKED(pCurItem, pECB)) {
  1313. if (pECB->Flags & ECBF_OVERLAY_ECBICON_IF_CHECKED) {
  1314. tvlp.Flags |= TVLPF_ECBICON;
  1315. if (pECB->Flags & ECBF_OVERLAY_WARNING_ICON) {
  1316. tvlp.Flags |= TVLPF_WARNING;
  1317. }
  1318. if (pECB->Flags & ECBF_OVERLAY_STOP_ICON) {
  1319. tvlp.Flags |= TVLPF_STOP;
  1320. }
  1321. if (pECB->Flags & ECBF_OVERLAY_NO_ICON) {
  1322. tvlp.Flags |= TVLPF_NO;
  1323. }
  1324. }
  1325. }
  1326. if ((RealECBChecked) &&
  1327. ((!(Flags & OPTIF_EXT_DISABLED)) ||
  1328. (!(pECB->Flags & ECBF_CHECKNAME_ONLY_ENABLED)))) {
  1329. NULL;
  1330. } else {
  1331. pECB = NULL;
  1332. }
  1333. //
  1334. // PUSHBUTTON: PusName... <pCheckedName>
  1335. //
  1336. if (pOptType->Type == TVOT_PUSHBUTTON) {
  1337. if (!(pOptType->Style & OTS_PUSH_NO_DOT_DOT_DOT)) {
  1338. GSBUF_GETSTR(IDS_CPSUI_MORE);
  1339. }
  1340. } else {
  1341. GSBUF_GETSTR(IDS_CPSUI_COLON_SEP);
  1342. }
  1343. tvlp.cName = (BYTE)(GSBUF_COUNT);
  1344. CPSUIINT(("TreeviewItem (%ld): '%ws'", tvlp.cName, GSBUF_BUF));
  1345. if ((pECB) && (pECB->Flags & ECBF_CHECKNAME_ONLY)){
  1346. GSBUF_GETSTR(pECB->pCheckedName);
  1347. pECB = NULL;
  1348. } else {
  1349. if ((pECB) && (pECB->Flags & ECBF_CHECKNAME_AT_FRONT)) {
  1350. //
  1351. // pName: <pCheckedName SEP pSelection>
  1352. //
  1353. GSBUF_GETSTR(pECB->pCheckedName);
  1354. GSBUF_GETSTR(pECB->pSeparator);
  1355. pECB = NULL;
  1356. }
  1357. EndTextAddSpace = (!(pOptType->Flags & OPTTF_NOSPACE_BEFORE_POSTFIX));
  1358. switch (pOptType->Type) {
  1359. case TVOT_CHKBOX:
  1360. Idx = (UINT)(pCurItem->Sel + (pOptParam->Style << 1));
  1361. if (!(pEndText = (LPTSTR)ChkBoxStrID[Idx])) {
  1362. pEndText = pOptParam->pData;
  1363. }
  1364. GSBUF_GETSTR(pEndText);
  1365. pEndText = NULL;
  1366. break;
  1367. case TVOT_COMBOBOX:
  1368. case TVOT_LISTBOX:
  1369. if ((DWORD)pCurItem->Sel >= (DWORD)pOptType->Count) {
  1370. pOptParam = &pTVWnd->OptParamNone;
  1371. } else {
  1372. pOptParam += (DWORD)pCurItem->Sel;
  1373. }
  1374. GSBUF_GETSTR(pOptParam->pData);
  1375. break;
  1376. case TVOT_2STATES:
  1377. case TVOT_3STATES:
  1378. pOptParam += pCurItem->Sel;
  1379. GSBUF_GETSTR(pOptParam->pData);
  1380. break;
  1381. case TVOT_TRACKBAR:
  1382. case TVOT_SCROLLBAR:
  1383. GSBUF_ADDNUM(pCurItem->Sel * (LONG)pOptParam[2].IconID, TRUE);
  1384. pEndText = pOptParam->pData;
  1385. break;
  1386. case TVOT_UDARROW:
  1387. GSBUF_ADDNUM(pCurItem->Sel, TRUE);
  1388. pEndText = pOptParam->pData;
  1389. break;
  1390. case TVOT_PUSHBUTTON:
  1391. Flags &= ~OPTIF_CHANGEONCE;
  1392. break;
  1393. case TVOT_EDITBOX:
  1394. GSBUF_GETSTR(pCurItem->pSel);
  1395. pEndText = pOptParam->pData;
  1396. break;
  1397. }
  1398. if (pEndText) {
  1399. LPWSTR pwBuf;
  1400. if (EndTextAddSpace) {
  1401. GSBUF_ADD_SPACE(1);
  1402. }
  1403. pwBuf = GSBUF_PBUF;
  1404. GSBUF_GETSTR(pEndText);
  1405. if ((GSBUF_PBUF == pwBuf) &&
  1406. (EndTextAddSpace)) {
  1407. GSBUF_SUB_SIZE(1);
  1408. }
  1409. }
  1410. }
  1411. if (pECB) {
  1412. GSBUF_GETSTR(pECB->pSeparator);
  1413. GSBUF_GETSTR(pECB->pCheckedName);
  1414. }
  1415. IconResID = GET_ICONID(pOptParam, OPTPF_ICONID_AS_HICON);
  1416. IntIconID = IDI_CPSUI_GENERIC_ITEM;
  1417. if (pOptParam->Flags & OPTPF_OVERLAY_WARNING_ICON) {
  1418. tvlp.Flags |= TVLPF_WARNING;
  1419. }
  1420. if (pOptParam->Flags & OPTPF_OVERLAY_STOP_ICON) {
  1421. tvlp.Flags |= TVLPF_STOP;
  1422. }
  1423. if (pOptParam->Flags & OPTPF_OVERLAY_NO_ICON) {
  1424. tvlp.Flags |= TVLPF_NO;
  1425. }
  1426. }
  1427. if (ptvins) {
  1428. tvins.item.iImage =
  1429. tvins.item.iSelectedImage = -1;
  1430. } else {
  1431. tvins.item.iSelectedImage =
  1432. tvins.item.iImage = (INT)GetIcon16Idx(pTVWnd,
  1433. _OI_HINST(pCurItem),
  1434. IconResID,
  1435. IntIconID);
  1436. }
  1437. tvins.item.cchTextMax = GSBUF_COUNT;
  1438. #if DO_IN_PLACE
  1439. if (tvins.item.mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) {
  1440. tvins.item.state |= TVIS_OVERLAYMASK | TVIS_STATEIMAGEMASK;
  1441. } else {
  1442. tvins.item.state &= ~(TVIS_OVERLAYMASK | TVIS_STATEIMAGEMASK);
  1443. }
  1444. #endif
  1445. tvins.item.stateMask |= TVIS_OVERLAYMASK | TVIS_STATEIMAGEMASK;
  1446. //
  1447. // Change the overlay mask
  1448. //
  1449. if ((!(pTVWnd->Flags & TWF_CAN_UPDATE)) ||
  1450. (pCurItem->Flags & OPTIF_DISABLED)) {
  1451. tvlp.Flags |= TVLPF_DISABLED;
  1452. }
  1453. if (Flags & OPTIF_CHANGEONCE) {
  1454. tvlp.Flags |= TVLPF_CHANGEONCE;
  1455. }
  1456. tvins.item.lParam = TVLP2LP(tvlp);
  1457. if (ptvins) {
  1458. _OI_HITEM(pCurItem) = TreeView_InsertItem(pTVWnd->hWndTV, &tvins);
  1459. CPSUIOPTITEM(DBGITEM_INS, pTVWnd, "SetTVItemState(INSERT)", 1, pCurItem);
  1460. } else {
  1461. if (_OI_INTFLAGS(pCurItem) & OIDF_ZERO_SEL_LEN) {
  1462. UINT cSpace;
  1463. //
  1464. // Do not update string while is selected
  1465. //
  1466. if (pTVWnd->cxItem > pTVWnd->cxMaxItem) {
  1467. cSpace = (UINT)(((DWORD)pTVWnd->cxEdit +
  1468. (DWORD)pTVWnd->cxSpace - 1) /
  1469. (DWORD)pTVWnd->cxSpace) + 1;
  1470. GSBUF_PBUF = GSBUF_BUF + tvlp.cName;
  1471. GSBUF_ADD_SPACE(cSpace);
  1472. CPSUIINT(("!! ZERO_SEL_LEN Item: %ld GREATER Than %ld, cName=%ld, cSpace=%ld",
  1473. pTVWnd->cxItem, pTVWnd->cxMaxItem, tvlp.cName, cSpace));
  1474. pTVWnd->cxMaxItem = pTVWnd->cxItem;
  1475. TreeView_SetItem(pTVWnd->hWndTV, &(tvins.item));
  1476. } else {
  1477. CPSUIINT(("!! ZERO_SEL_LEN Item: %ld Less than %ld, cName=%ld",
  1478. pTVWnd->cxItem, pTVWnd->cxMaxItem, tvlp.cName));
  1479. }
  1480. GSBUF_BUF[tvlp.cName] = L'\0';
  1481. CPSUIINT(("!! ZERO_SEL_LEN Item pszText='%ws'",
  1482. tvins.item.pszText));
  1483. }
  1484. TreeView_SetItem(pTVWnd->hWndTV, &(tvins.item));
  1485. CPSUIOPTITEM(DBGITEM_SET, pTVWnd, "SetTVItemState(SET)", 1, pCurItem);
  1486. }
  1487. }
  1488. POPTITEM
  1489. SetupTVSelect(
  1490. HWND hDlg,
  1491. NM_TREEVIEW *pNMTV,
  1492. DWORD STVSMode
  1493. )
  1494. /*++
  1495. Routine Description:
  1496. Arguments:
  1497. Return Value:
  1498. Author:
  1499. 21-Jun-1995 Wed 15:14:54 created -by- Daniel Chou (danielc)
  1500. Revision History:
  1501. --*/
  1502. {
  1503. HWND hParent;
  1504. HWND hCtrl;
  1505. HWND hWndTV;
  1506. PTVWND pTVWnd = GET_PTVWND(hDlg);
  1507. POPTTYPE pOldOptType;
  1508. POPTITEM pOldItem;
  1509. POPTTYPE pOptType;
  1510. POPTITEM pNewItem;
  1511. POPTPARAM pOptParam;
  1512. TVLP tvlp;
  1513. WORD InitFlags;
  1514. WORD InitItemIdx;
  1515. WORD IconMode = 0;
  1516. BYTE NewType;
  1517. BOOL CanUpdate;
  1518. hWndTV = pTVWnd->hWndTV;
  1519. pNewItem = GetOptions(pTVWnd, pNMTV->itemNew.lParam);
  1520. tvlp = GET_TVLP(pNMTV->itemNew.lParam);
  1521. InitItemIdx = tvlp.ItemIdx;
  1522. if (!pTVWnd->pCurTVItem) {
  1523. pOldItem = NULL;
  1524. pOldOptType = NULL;
  1525. } else {
  1526. pOldItem = GetOptions(pTVWnd, pNMTV->itemOld.lParam);
  1527. pOldOptType = GET_POPTTYPE(pOldItem);
  1528. }
  1529. CPSUIOPTITEM(DBGITEM_SETUP, pTVWnd, "Setup OLD", 0, pOldItem);
  1530. CPSUIOPTITEM(DBGITEM_SETUP, pTVWnd, "Setup New", 0, pNewItem);
  1531. pOptType = GET_POPTTYPE(pNewItem);
  1532. #if DO_IN_PLACE
  1533. hParent = hWndTV;
  1534. switch (NewType = pOptType->Type) {
  1535. case TVOT_2STATES:
  1536. case TVOT_3STATES:
  1537. case TVOT_LISTBOX:
  1538. NewType = TVOT_COMBOBOX;
  1539. break;
  1540. case TVOT_SCROLLBAR:
  1541. case TVOT_TRACKBAR:
  1542. #if 1
  1543. NewType = TVOT_UDARROW;
  1544. #else
  1545. if (pOptType->pOptParam[2].IconID <= 1) {
  1546. NewType = TVOT_UDARROW;
  1547. }
  1548. #endif
  1549. break;
  1550. default:
  1551. break;
  1552. }
  1553. #else
  1554. hParent = hDlg;
  1555. NewType = pOptType->Type;
  1556. #endif
  1557. //
  1558. // If we have push button, and it said we always can call it then update
  1559. // is true
  1560. //
  1561. if ((STVSMode & STVS_ACTIVE) &&
  1562. (pOldItem != pNewItem) &&
  1563. (pNewItem->Flags & OPTIF_CALLBACK) &&
  1564. (InitItemIdx < pTVWnd->ComPropSheetUI.cOptItem)) {
  1565. //
  1566. // Callback back ONLY for the user item which has CALLBACK
  1567. //
  1568. DoCallBack(hDlg,
  1569. pTVWnd,
  1570. pNewItem,
  1571. pNewItem->pSel,
  1572. NULL,
  1573. NULL,
  1574. 0,
  1575. CPSUICB_REASON_OPTITEM_SETFOCUS);
  1576. }
  1577. if ((pNewItem == PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT)) ||
  1578. ((NewType == TVOT_PUSHBUTTON) &&
  1579. (pOptType->Flags & OTS_PUSH_ENABLE_ALWAYS))) {
  1580. CanUpdate = TRUE;
  1581. } else {
  1582. CanUpdate = (BOOL)(pTVWnd->Flags & TWF_CAN_UPDATE);
  1583. }
  1584. pTVWnd->Flags &= ~TWF_TVITEM_NOTYPE;
  1585. if (IS_HDR_PUSH(pOptType)) {
  1586. #if DO_IN_PLACE
  1587. pOptType = NULL;
  1588. NewType = TVOT_NONE;
  1589. #else
  1590. HTREEITEM hItem;
  1591. UINT cRevert;
  1592. if ((!CanUpdate) ||
  1593. (!(cRevert = CountRevertOptItem(pTVWnd,
  1594. pNewItem,
  1595. _OI_HITEM(pNewItem),
  1596. 0)))) {
  1597. CPSUIINT(("CountRevertOptItem=0, NOT REVERT"));
  1598. //
  1599. // We always enable the ROOT
  1600. //
  1601. if ((InitItemIdx == INTIDX_TVROOT) ||
  1602. ((pNewItem->pExtChkBox) &&
  1603. (!(pNewItem->Flags & OPTIF_EXT_HIDE)))) {
  1604. pTVWnd->Flags |= TWF_ONE_REVERT_ITEM;
  1605. pOptType->Flags |= OPTTF_TYPE_DISABLED;
  1606. } else {
  1607. pTVWnd->Flags |= TWF_TVITEM_NOTYPE;
  1608. pOptType = NULL;
  1609. NewType = TVOT_NONE;
  1610. }
  1611. } else {
  1612. pOptType->Flags &= ~OPTTF_TYPE_DISABLED;
  1613. if (cRevert == 1) {
  1614. pTVWnd->Flags |= TWF_ONE_REVERT_ITEM;
  1615. } else {
  1616. pTVWnd->Flags &= ~TWF_ONE_REVERT_ITEM;
  1617. }
  1618. CPSUIINT(("CountRevertOptItem=%d, Let's do the PUSH", cRevert));
  1619. }
  1620. #endif
  1621. }
  1622. if ((pNewItem->Flags & OPTIF_DISABLED) || (!CanUpdate)) {
  1623. InitFlags = INITCF_TVDLG;
  1624. } else {
  1625. InitFlags = INITCF_ENABLE | INITCF_TVDLG;
  1626. }
  1627. if ((STVSMode & STVS_REINIT) || (pOldItem != pNewItem)) {
  1628. InitFlags |= (INITCF_INIT | INITCF_SETCTRLDATA);
  1629. ChangeOptTypeDisplay(hParent,
  1630. pTVWnd,
  1631. pOldOptType,
  1632. pOptType,
  1633. InitFlags & INITCF_ENABLE);
  1634. }
  1635. //
  1636. // The extended check box will also looked at TWF_CAN_UPDATE flags to
  1637. // disable the ECB if the flag is clear
  1638. //
  1639. if (pOptType) {
  1640. if (INIT_EXTENDED(pTVWnd,
  1641. hParent,
  1642. pNewItem,
  1643. IDD_TV_EXTCHKBOX,
  1644. IDD_TV_EXTPUSH,
  1645. IDD_TV_ECB_ICON,
  1646. InitItemIdx,
  1647. InitFlags)) {
  1648. InitFlags |= INITCF_HAS_EXT;
  1649. }
  1650. } else if (InitFlags & INITCF_INIT) {
  1651. if (hCtrl = GetDlgItem(hParent, IDD_TV_EXTPUSH)) {
  1652. CPSUIINT(("!! DISABLE/HIDE HEADER EXTPUSH !!!"));
  1653. EnableWindow(hCtrl, FALSE);
  1654. ShowWindow(hCtrl, SW_HIDE);
  1655. }
  1656. if (hCtrl = GetDlgItem(hParent, IDD_TV_EXTCHKBOX)) {
  1657. CPSUIINT(("!! DISABLE/HIDE HEADER EXTCHKBOX !!"));
  1658. EnableWindow(hCtrl, FALSE);
  1659. ShowWindow(hCtrl, SW_HIDE);
  1660. }
  1661. }
  1662. if (pOptType) {
  1663. LONG Select;
  1664. UINT IDSetCurSel = CB_SETCURSEL;
  1665. UINT idLBCB = IDD_TV_CB;
  1666. UINT cyLBMax = 0;
  1667. ULONG_PTR IconResID;
  1668. WORD BegCtrlID;
  1669. WORD IntIconID = IDI_CPSUI_GENERIC_ITEM;
  1670. if (pNewItem->Flags & OPTIF_OVERLAY_WARNING_ICON) {
  1671. IconMode |= MIM_WARNING_OVERLAY;
  1672. }
  1673. if (pNewItem->Flags & (OPTIF_OVERLAY_STOP_ICON | OPTIF_HIDE)) {
  1674. IconMode |= MIM_STOP_OVERLAY;
  1675. }
  1676. if (pNewItem->Flags & OPTIF_OVERLAY_NO_ICON) {
  1677. IconMode |= MIM_NO_OVERLAY;
  1678. }
  1679. if (pOptType->Flags & OPTTF_TYPE_DISABLED) {
  1680. InitFlags &= ~INITCF_ENABLE;
  1681. }
  1682. //
  1683. // We have something to do here, if we have same option type
  1684. // with the old one then we need not to re-create them
  1685. // and if we have same select then we do not need to re-draw
  1686. //
  1687. // Now set the option text to reflect the changes
  1688. //
  1689. pOptParam = pOptType->pOptParam;
  1690. //
  1691. // Compose '&Change xxxx Option' or
  1692. // 'xxxxx Option"
  1693. //
  1694. #if (DO_IN_PLACE == 0)
  1695. if (InitFlags & INITCF_INIT) {
  1696. SetOptHeader(hDlg, pTVWnd, pNewItem, IS_HDR_PUSH(pOptType));
  1697. }
  1698. #endif
  1699. Select = pNewItem->Sel;
  1700. BegCtrlID = pOptType->BegCtrlID;
  1701. CPSUIDBG(DBG_STVS,
  1702. ("TVOT_TYPE=%hs, InitFlags=%04lx, InitItemIdx = %ld, Select=%ld [%08lx]",
  1703. (LPTSTR)pTVOTName[NewType],
  1704. (DWORD)InitFlags, (DWORD)InitItemIdx, Select, Select));
  1705. switch(NewType) {
  1706. case TVOT_2STATES:
  1707. case TVOT_3STATES:
  1708. #if (DO_IN_PLACE == 0)
  1709. if (InitFlags & INITCF_INIT) {
  1710. MoveStateRadios(hDlg, pTVWnd, pOptType, InitFlags);
  1711. }
  1712. #endif
  1713. #if DO_IN_PLACE
  1714. cyLBMax = pTVWnd->yLB[(InitFlags & INITCF_HAS_EXT) ? 0 : 1];
  1715. InitLBCB(pTVWnd,
  1716. hParent,
  1717. pNewItem,
  1718. idLBCB,
  1719. IDSetCurSel,
  1720. pOptType,
  1721. InitItemIdx,
  1722. Select,
  1723. InitFlags,
  1724. cyLBMax);
  1725. #else
  1726. InitStates(pTVWnd,
  1727. hParent,
  1728. pNewItem,
  1729. pOptType,
  1730. IDD_3STATES_1,
  1731. InitItemIdx,
  1732. Select,
  1733. InitFlags);
  1734. #endif
  1735. pOptParam += Select;
  1736. break;
  1737. case TVOT_UDARROW:
  1738. InitUDArrow(pTVWnd,
  1739. hParent,
  1740. pNewItem,
  1741. pOptParam,
  1742. IDD_TV_UDARROW,
  1743. IDD_TV_UDARROW_EDIT,
  1744. IDD_TV_UDARROW_ENDTEXT,
  1745. IDD_TV_UDARROW_HELP,
  1746. InitItemIdx,
  1747. Select,
  1748. InitFlags);
  1749. break;
  1750. case TVOT_SCROLLBAR:
  1751. case TVOT_TRACKBAR:
  1752. CPSUIINT(("hParent=%08lx, NewType=%ld, hCtrl=%08lx",
  1753. hParent, NewType,
  1754. GetDlgItem(hParent, (NewType == TVOT_TRACKBAR) ?
  1755. IDD_TV_TRACKBAR : IDD_TV_SB)));
  1756. InitTBSB(pTVWnd,
  1757. hParent,
  1758. pNewItem,
  1759. GetDlgItem(hParent, (NewType == TVOT_TRACKBAR) ?
  1760. IDD_TV_TRACKBAR : IDD_TV_SB),
  1761. pOptType,
  1762. 0,
  1763. IDD_TV_SB_LOW,
  1764. IDD_TV_SB_HIGH,
  1765. InitItemIdx,
  1766. Select,
  1767. InitFlags);
  1768. break;
  1769. case TVOT_LISTBOX:
  1770. //
  1771. // If we only has one item then make it combo box
  1772. //
  1773. cyLBMax = pTVWnd->yLB[(InitFlags & INITCF_HAS_EXT) ? 0 : 1];
  1774. IDSetCurSel = LB_SETCURSEL;
  1775. idLBCB = IDD_TV_LB;
  1776. //
  1777. // Fall through
  1778. //
  1779. case TVOT_COMBOBOX:
  1780. InitLBCB(pTVWnd,
  1781. hParent,
  1782. pNewItem,
  1783. idLBCB,
  1784. IDSetCurSel,
  1785. pOptType,
  1786. InitItemIdx,
  1787. Select,
  1788. InitFlags,
  1789. cyLBMax);
  1790. if ((DWORD)Select >= (DWORD)pOptType->Count) {
  1791. CPSUIDBG(DBG_STVS, ("Get NONE type of select=%ld", Select));
  1792. pOptParam = &pTVWnd->OptParamNone;
  1793. } else {
  1794. pOptParam += (DWORD)Select;
  1795. }
  1796. break;
  1797. case TVOT_EDITBOX:
  1798. InitEditBox(pTVWnd,
  1799. hParent,
  1800. pNewItem,
  1801. pOptParam,
  1802. IDD_TV_EDIT_EDIT,
  1803. IDD_TV_EDIT_ENDTEXT,
  1804. IDD_TV_EDIT_HELP,
  1805. InitItemIdx,
  1806. pNewItem->pSel,
  1807. InitFlags);
  1808. break;
  1809. case TVOT_PUSHBUTTON:
  1810. InitPushButton(pTVWnd,
  1811. hParent,
  1812. pNewItem,
  1813. IDD_TV_PUSH,
  1814. InitItemIdx,
  1815. InitFlags);
  1816. break;
  1817. case TVOT_CHKBOX:
  1818. #if DO_IN_PLACE
  1819. #if 0
  1820. InitChkBox(pTVWnd,
  1821. hParent,
  1822. pNewItem,
  1823. IDD_TV_CHKBOX,
  1824. pNewItem->pName,
  1825. InitItemIdx,
  1826. (BOOL)Select,
  1827. InitFlags);
  1828. #else
  1829. {
  1830. OPTTYPE ChkBoxOT;
  1831. OPTPARAM ChkBoxOP[2];
  1832. UINT Idx;
  1833. ChkBoxOT = *pOptType;
  1834. ChkBoxOT.Type = TVOT_COMBOBOX;
  1835. ChkBoxOT.Count = 2;
  1836. ChkBoxOT.pOptParam = ChkBoxOP;
  1837. ChkBoxOP[0] =
  1838. ChkBoxOP[1] = *pOptParam;
  1839. ChkBoxOP[0].Style =
  1840. ChkBoxOP[1].Style = 0;
  1841. ChkBoxOP[0].IconID =
  1842. ChkBoxOP[1].IconID = 0;
  1843. Idx = (UINT)(pOptParam->Style << 1);
  1844. if (ChkBoxStrID[Idx]) {
  1845. ChkBoxOP[0].pData = (LPTSTR)ChkBoxStrID[Idx];
  1846. }
  1847. if (ChkBoxStrID[Idx + 1]) {
  1848. ChkBoxOP[1].pData = (LPTSTR)ChkBoxStrID[Idx + 1];
  1849. }
  1850. cyLBMax = pTVWnd->yLB[(InitFlags & INITCF_HAS_EXT) ? 0 : 1];
  1851. InitLBCB(pTVWnd,
  1852. hParent,
  1853. pNewItem,
  1854. idLBCB,
  1855. IDSetCurSel,
  1856. &ChkBoxOT,
  1857. InitItemIdx,
  1858. Select,
  1859. InitFlags,
  1860. cyLBMax);
  1861. }
  1862. #endif
  1863. #else
  1864. InitChkBox(pTVWnd,
  1865. hParent,
  1866. pNewItem,
  1867. IDD_TV_CHKBOX,
  1868. pNewItem->pName,
  1869. InitItemIdx,
  1870. (BOOL)Select,
  1871. InitFlags);
  1872. #endif
  1873. break;
  1874. }
  1875. if (IS_HDR_PUSH(pOptType)) {
  1876. IconResID = GETSELICONID(pNewItem);
  1877. IntIconID = IDI_CPSUI_GENERIC_OPTION;
  1878. } else {
  1879. IconResID = GET_ICONID(pOptParam, OPTPF_ICONID_AS_HICON);
  1880. if (pOptParam->Flags & OPTPF_OVERLAY_WARNING_ICON) {
  1881. IconMode |= MIM_WARNING_OVERLAY;
  1882. }
  1883. if (pOptParam->Flags & OPTPF_OVERLAY_STOP_ICON) {
  1884. IconMode |= MIM_STOP_OVERLAY;
  1885. }
  1886. if (pOptParam->Flags & OPTPF_OVERLAY_NO_ICON) {
  1887. IconMode |= MIM_NO_OVERLAY;
  1888. }
  1889. }
  1890. #if (DO_IN_PLACE == 0)
  1891. SetIcon(_OI_HINST(pNewItem),
  1892. GetDlgItem(hParent, IDD_TV_ICON),
  1893. IconResID,
  1894. MK_INTICONID(IntIconID, IconMode),
  1895. pTVWnd->cxcyTVIcon);
  1896. #endif
  1897. }
  1898. #if DO_IN_PLACE
  1899. #if 0
  1900. EnableWindow(GetDlgItem(hDlg, IDD_PRE_EDIT), (BOOL)pTVWnd->chWndEdit);
  1901. EnableWindow(GetDlgItem(hDlg, IDD_POST_EDIT), (BOOL)pTVWnd->chWndEdit);
  1902. #endif
  1903. #endif
  1904. return(pNewItem);
  1905. }
  1906. LONG
  1907. UpdateTreeViewItem(
  1908. HWND hDlg,
  1909. PTVWND pTVWnd,
  1910. POPTITEM pItem,
  1911. BOOL ReInit
  1912. )
  1913. /*++
  1914. Routine Description:
  1915. This function update a single item in the treeview, and reset the bottom
  1916. option change controls if this item also the current selected one
  1917. Arguments:
  1918. hDlg - Handle to the dialog box
  1919. pTVWnd - Handle to common UI instance data
  1920. pItem - Pointer to OPTITEM to be updated
  1921. Return Value:
  1922. LONG
  1923. Author:
  1924. 01-Sep-1995 Fri 01:05:56 created -by- Daniel Chou (danielc)
  1925. Revision History:
  1926. --*/
  1927. {
  1928. if ((pItem) && (!(pItem->Flags & OPTIF_INT_HIDE))) {
  1929. SetTVItemState(pTVWnd, NULL, pItem);
  1930. if (pItem == pTVWnd->pCurTVItem) {
  1931. NM_TREEVIEW NMtv;
  1932. NMtv.itemNew.hItem = _OI_HITEM(pItem);
  1933. NMtv.itemNew.mask = TVIF_HANDLE | TVIF_PARAM;
  1934. if (IS_HDR_PUSH(GET_POPTTYPE(pItem))) {
  1935. ReInit = TRUE;
  1936. }
  1937. if (TreeView_GetItem(pTVWnd->hWndTV, &(NMtv.itemNew))) {
  1938. NMtv.itemOld = NMtv.itemNew;
  1939. SetupTVSelect(hDlg, &NMtv, (ReInit) ? STVS_REINIT : 0);
  1940. CPSUIDBG(DBG_UTV, ("*UpdateTreeViewItem: Item=Current Selection"));
  1941. }
  1942. }
  1943. return(1);
  1944. } else {
  1945. return(0);
  1946. }
  1947. }
  1948. LONG
  1949. UpdateTreeView(
  1950. HWND hDlg,
  1951. PMYDLGPAGE pCurMyDP
  1952. )
  1953. /*++
  1954. Routine Description:
  1955. Arguments:
  1956. Return Value:
  1957. Author:
  1958. 08-Aug-1995 Tue 15:37:16 created -by- Daniel Chou (danielc)
  1959. Revision History:
  1960. --*/
  1961. {
  1962. INT cUpdated = 0;
  1963. if (pCurMyDP->Flags & (MYDPF_CHANGED | MYDPF_REINIT)) {
  1964. PTVWND pTVWnd;
  1965. POPTITEM pItem;
  1966. UINT cItem;
  1967. BOOL ReInit;
  1968. BOOL TVByPush;
  1969. BYTE TVPageIdx;
  1970. pTVWnd = (PTVWND)pCurMyDP->pTVWnd;
  1971. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  1972. cItem = (UINT)pTVWnd->ComPropSheetUI.cOptItem;
  1973. ReInit = (pCurMyDP->Flags & MYDPF_REINIT);
  1974. TVByPush = (BOOL)(pTVWnd->Flags & TWF_TV_BY_PUSH);
  1975. TVPageIdx = pTVWnd->TVPageIdx;
  1976. CPSUIASSERT(0, "UpdateTreeView: DlgPage not treevie page (%ld)",
  1977. ((pCurMyDP->DlgPage.DlgTemplateID == DP_STD_TREEVIEWPAGE) ||
  1978. (pCurMyDP->DlgPage.DlgTemplateID == DP_STD_INT_TVPAGE))
  1979. && ((BYTE)pCurMyDP->PageIdx == TVPageIdx),
  1980. (BYTE)pCurMyDP->PageIdx);
  1981. CPSUIDBG(DBGITEM_UTV, ("UpdateTreeView (OPTIF_INT_TV_CHANGED)"));
  1982. while (cItem--) {
  1983. if (pItem->Flags & OPTIF_INT_TV_CHANGED) {
  1984. if ((!TVByPush) || (pItem->DlgPageIdx == TVPageIdx)) {
  1985. CPSUIOPTITEM(DBGITEM_UTV, pTVWnd, "UpdateTreeView",
  1986. 1, pItem);
  1987. UpdateTreeViewItem(hDlg, pTVWnd, pItem, ReInit);
  1988. ++cUpdated;
  1989. }
  1990. pItem->Flags &= ~OPTIF_INT_TV_CHANGED;
  1991. }
  1992. pItem++;
  1993. }
  1994. pCurMyDP->Flags &= ~(MYDPF_CHANGED | MYDPF_REINIT);
  1995. }
  1996. return((LONG)cUpdated);
  1997. }
  1998. POPTITEM
  1999. TreeViewHitTest(
  2000. PTVWND pTVWnd,
  2001. LONG MousePos,
  2002. UINT TVHTMask
  2003. )
  2004. /*++
  2005. Routine Description:
  2006. Arguments:
  2007. Return Value:
  2008. Author:
  2009. 07-Sep-1995 Thu 22:32:04 created -by- Daniel Chou (danielc)
  2010. Revision History:
  2011. --*/
  2012. {
  2013. HWND hWndTV = pTVWnd->hWndTV;
  2014. TV_HITTESTINFO ht;
  2015. //
  2016. // Find out the mouse cursor location if on the state icon/bmp
  2017. //
  2018. if (MousePos != -1) {
  2019. ht.pt.x = (LONG)LOWORD(MousePos);
  2020. ht.pt.y = (LONG)HIWORD(MousePos);
  2021. } else {
  2022. GetCursorPos(&ht.pt);
  2023. }
  2024. ScreenToClient(hWndTV, &ht.pt);
  2025. TreeView_HitTest(hWndTV, &ht);
  2026. CPSUIDBG(DBG_TVHT,
  2027. ("TreeViewHitTest: pt=(%ld, %ld), HitTest=%04lx, TVHT_xx=%ld",
  2028. (DWORD)ht.pt.x, (DWORD)ht.pt.y, TVHTMask, (DWORD)ht.flags));
  2029. if (ht.flags & TVHTMask) {
  2030. POPTTYPE pOptType;
  2031. POPTITEM pItem;
  2032. TV_ITEM tvi;
  2033. tvi.hItem = ht.hItem;
  2034. tvi.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
  2035. tvi.stateMask = TVIS_STATEIMAGEMASK;
  2036. if (TreeView_GetItem(hWndTV, &tvi)) {
  2037. return(GetOptions(pTVWnd, tvi.lParam));
  2038. }
  2039. }
  2040. return(NULL);
  2041. }
  2042. VOID
  2043. TreeViewChangeMode(
  2044. PTVWND pTVWnd,
  2045. POPTITEM pItem,
  2046. UINT Mode
  2047. )
  2048. /*++
  2049. Routine Description:
  2050. Arguments:
  2051. Return Value:
  2052. Author:
  2053. 07-Sep-1995 Thu 22:56:05 created -by- Daniel Chou (danielc)
  2054. Revision History:
  2055. --*/
  2056. {
  2057. HWND hWndTV = pTVWnd->hWndTV;
  2058. POPTTYPE pOptType;
  2059. TV_ITEM tvi;
  2060. tvi.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
  2061. if ((!pItem) ||
  2062. (!(tvi.hItem = _OI_HITEM(pItem))) ||
  2063. (!TreeView_GetItem(hWndTV, &tvi))) {
  2064. return;
  2065. }
  2066. switch (Mode) {
  2067. case TVCM_TOGGLE:
  2068. if (tvi.cChildren) {
  2069. PostMessage(hWndTV,
  2070. TVM_EXPAND,
  2071. (WPARAM)TVE_TOGGLE,
  2072. (LPARAM)tvi.hItem);
  2073. }
  2074. break;
  2075. case TVCM_SELECT:
  2076. PostMessage(hWndTV,
  2077. TVM_SELECTITEM,
  2078. (WPARAM)TVGN_CARET,
  2079. (LPARAM)tvi.hItem);
  2080. //
  2081. // We will go to the next control only if the item is not disabled
  2082. // and has an update permisson (push button always has one).
  2083. //
  2084. #if DO_IN_PLACE
  2085. if ((!tvi.cChildren) &&
  2086. (!(pItem->Flags & OPTIF_DISABLED)) &&
  2087. (pOptType = GET_POPTTYPE(pItem)) &&
  2088. (!IS_HDR_PUSH(pOptType)) &&
  2089. ((pTVWnd->Flags & TWF_CAN_UPDATE) ||
  2090. (pOptType->Flags & OTS_PUSH_ENABLE_ALWAYS))) {
  2091. if (pOptType->Type == TVOT_PUSHBUTTON) {
  2092. PostMessage(pTVWnd->hDlgTV,
  2093. WM_COMMAND,
  2094. MAKEWPARAM(IDD_TV_PUSH, BN_CLICKED),
  2095. (LPARAM)GetDlgItem(pTVWnd->hWndTV, IDD_TV_PUSH));
  2096. } else if (pTVWnd->chWndEdit) {
  2097. PostMessage(pTVWnd->hDlgTV,
  2098. WM_NEXTDLGCTL,
  2099. (WPARAM)pTVWnd->hWndEdit[0],
  2100. (LPARAM)1);
  2101. }
  2102. }
  2103. #else
  2104. if ((!tvi.cChildren) &&
  2105. (!(pItem->Flags & OPTIF_DISABLED)) &&
  2106. (pOptType = GET_POPTTYPE(pItem)) &&
  2107. (pOptType->Type == TVOT_PUSHBUTTON) &&
  2108. (!IS_HDR_PUSH(pOptType)) &&
  2109. ((pTVWnd->Flags & TWF_CAN_UPDATE) ||
  2110. (pOptType->Flags & OTS_PUSH_ENABLE_ALWAYS))) {
  2111. PostMessage(pTVWnd->hDlgTV,
  2112. WM_COMMAND,
  2113. MAKEWPARAM(IDD_TV_PUSH, BN_CLICKED),
  2114. (LPARAM)GetDlgItem(pTVWnd->hDlgTV, IDD_TV_PUSH));
  2115. }
  2116. #endif
  2117. break;
  2118. }
  2119. }
  2120. VOID
  2121. MouseSelectItem(
  2122. HWND hDlg,
  2123. PTVWND pTVWnd
  2124. )
  2125. /*++
  2126. Routine Description:
  2127. Arguments:
  2128. Return Value:
  2129. Author:
  2130. 22-Jun-1995 Thu 13:44:18 created -by- Daniel Chou (danielc)
  2131. Revision History:
  2132. --*/
  2133. {
  2134. POPTITEM pItem;
  2135. //
  2136. // Find out the mouse cursor location if on the state icon/bmp
  2137. //
  2138. if (pItem = TreeViewHitTest(pTVWnd, -1, TVHT_ONITEM)) {
  2139. TreeViewChangeMode(pTVWnd, pItem, TVCM_SELECT);
  2140. }
  2141. }
  2142. #if 0
  2143. BOOL
  2144. CreateTVCtrls(
  2145. HWND hDlg
  2146. )
  2147. /*++
  2148. Routine Description:
  2149. This function create any treeview change control that not in the static
  2150. template
  2151. Arguments:
  2152. Return Value:
  2153. Author:
  2154. 06-Feb-1998 Fri 15:57:42 created -by- Daniel Chou (danielc)
  2155. Revision History:
  2156. --*/
  2157. {
  2158. HWND hCtrl;
  2159. //
  2160. // Create TrackBar Control
  2161. //
  2162. if (hCtrl = CreateTrackBar(hDlg, IDD_TV_TRACKBAR)) {
  2163. EnableWindow(hCtrl, FALSE);
  2164. ShowWindow(hCtrl, SW_HIDE);
  2165. //
  2166. // Create Up/Down Control
  2167. //
  2168. if (hCtrl = CreateUDArrow(hDlg, IDD_TV_UDARROW_EDIT, IDD_TV_UDARROW)) {
  2169. ShowWindow(hCtrl, SW_HIDE);
  2170. EnableWindow(hCtrl, FALSE);
  2171. return(TRUE);
  2172. }
  2173. }
  2174. return(FALSE);
  2175. }
  2176. #endif
  2177. HWND
  2178. CreatehWndTV(
  2179. HWND hDlg,
  2180. PTVWND pTVWnd
  2181. )
  2182. /*++
  2183. Routine Description:
  2184. This function create TREE VIEW window
  2185. Arguments:
  2186. hDlg - Handle to the dialog for the treeview to be created, it must
  2187. have item identify as IDD_TV_WND for the treeview window location
  2188. Return Value:
  2189. HWND for the treeview window
  2190. Author:
  2191. 21-Jun-1995 Wed 13:33:29 created -by- Daniel Chou (danielc)
  2192. Revision History:
  2193. --*/
  2194. {
  2195. HWND hWndTV = NULL;
  2196. HWND hCtrl;
  2197. DWORD dw;
  2198. RECT rc;
  2199. WORD InitItemIdx = 0xFFFE;
  2200. #if 0
  2201. if (!CreateTVCtrls(hDlg)) {
  2202. return(NULL);
  2203. }
  2204. #endif
  2205. //
  2206. // Create TreeView Window, Get the window size for the treeview
  2207. //
  2208. hCtrl = CtrlIDrcWnd(hDlg, IDD_TV_WND, &rc);
  2209. if (hCtrl)
  2210. {
  2211. SETCTRLDATA(hCtrl, CTRLS_TV_STATIC, 0);
  2212. ShowWindow(hCtrl, SW_HIDE);
  2213. CPSUIDBG(DBG_CTVWND,
  2214. ("\nINIT DEV DLG, CLIENT rc=(%ld, %ld) - (%ld, %ld) = %ld x %ld",
  2215. rc.left, rc.top, rc.right, rc.bottom,
  2216. rc.right - rc.left, rc.bottom - rc.top));
  2217. if (hWndTV = CreateWindowEx(WS_EX_NOPARENTNOTIFY |
  2218. WS_EX_CLIENTEDGE,
  2219. WC_TREEVIEW,
  2220. L"",
  2221. WS_VISIBLE |
  2222. TVS_HASBUTTONS |
  2223. TVS_SHOWSELALWAYS |
  2224. TVS_DISABLEDRAGDROP |
  2225. // TVS_LINESATROOT |
  2226. TVS_HASLINES |
  2227. WS_CLIPCHILDREN |
  2228. WS_CHILD |
  2229. WS_BORDER |
  2230. WS_TABSTOP |
  2231. WS_CLIPSIBLINGS |
  2232. WS_GROUP,
  2233. rc.left,
  2234. rc.top,
  2235. rc.right - rc.left,
  2236. rc.bottom - rc.top,
  2237. hDlg,
  2238. (HMENU)(IDD_TV_WND + 0),
  2239. hInstDLL,
  2240. 0)) {
  2241. DestroyWindow(hCtrl);
  2242. pTVWnd->hWndTV = hWndTV;
  2243. SetWindowPos(hWndTV, GetDlgItem(hDlg, IDD_TV_WND), 0, 0, 0, 0,
  2244. SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  2245. InitItemIdx = 0xFFFF;
  2246. SETCTRLDATA(hWndTV, CTRLS_TV_WND, 0);
  2247. #if DO_IN_PLACE
  2248. #if 1
  2249. #if 0
  2250. if (hCtrl = GetDlgItem(hDlg, IDD_PRE_EDIT)) {
  2251. ShowWindow(hCtrl, SW_HIDE);
  2252. EnableWindow(hCtrl, FALSE);
  2253. }
  2254. if (hCtrl = GetDlgItem(hDlg, IDD_POST_EDIT)) {
  2255. ShowWindow(hCtrl, SW_HIDE);
  2256. EnableWindow(hCtrl, FALSE);
  2257. }
  2258. #endif
  2259. #else
  2260. if (hCtrl = GetDlgItem(hDlg, IDD_PRE_EDIT)) {
  2261. SetWindowPos(hWndTV,
  2262. hCtrl,
  2263. 0, 0, 0, 0,
  2264. SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
  2265. SetProp(hCtrl,
  2266. CPSUIPROP_WNDPROC,
  2267. (HANDLE)GetWindowLongPtr(hCtrl, GWLP_WNDPROC));
  2268. SetWindowLongPtr(hCtrl, GWLP_WNDPROC, (LPARAM)FocusCtrlProc);
  2269. SetWindowPos(hCtrl, NULL,
  2270. -10000, -10000, 0, 0,
  2271. SWP_NOSIZE | SWP_NOZORDER);
  2272. }
  2273. //
  2274. // Doing Post window
  2275. //
  2276. if (hCtrl = GetDlgItem(hDlg, IDD_POST_EDIT)) {
  2277. SetWindowPos(hCtrl, hWndTV,
  2278. -9000, -9000, 0, 0,
  2279. SWP_NOSIZE | SWP_NOREDRAW);
  2280. SetProp(hCtrl,
  2281. CPSUIPROP_WNDPROC,
  2282. (HANDLE)GetWindowLongPtr(hCtrl, GWLP_WNDPROC));
  2283. SetWindowLongPtr(hCtrl, GWLP_WNDPROC, (LPARAM)FocusCtrlProc);
  2284. }
  2285. #endif
  2286. if (pTVWnd->hDCTVWnd = GetWindowDC(hWndTV)) {
  2287. CreateTVFonts(pTVWnd,
  2288. (HANDLE)SendMessage(hWndTV, WM_GETFONT, 0, 0));
  2289. }
  2290. #endif
  2291. pTVWnd->TVWndProc = (WNDPROC)SetWindowLongPtr(hWndTV,
  2292. GWLP_WNDPROC,
  2293. (LPARAM)MyTVWndProc);
  2294. }
  2295. CPSUIDBG(DBG_CTVWND, ("\nINIT DLG (%08lx), hWndTV = %08lx",
  2296. hDlg, hWndTV));
  2297. }
  2298. return(hWndTV);
  2299. }
  2300. HTREEITEM
  2301. AddItem(
  2302. PTVWND pTVWnd,
  2303. HTREEITEM hParent,
  2304. POPTITEM pItem,
  2305. UINT DefTVIS,
  2306. UINT TVLevel
  2307. )
  2308. /*++
  2309. Routine Description:
  2310. This function add a item to the end of list of treeview specified by
  2311. Arguments:
  2312. hParent - handle to the parent item for the item to be added
  2313. pItem - Pointer to the OPTITEM to be added
  2314. ItemIdx - Index to the pOptItem
  2315. DefTVIS - default TVIS_xxxx
  2316. Return Value:
  2317. HTREEITEM of the item added or NULL if nothing added
  2318. Author:
  2319. 19-Jun-1995 Mon 16:38:27 created -by- Daniel Chou (danielc)
  2320. 08-Sep-1995 Fri 13:43:34 updated -by- Daniel Chou (danielc)
  2321. Re-write to make it more compact
  2322. Revision History:
  2323. --*/
  2324. {
  2325. WORD ItemIdx;
  2326. DWORD Flags;
  2327. if ((VALID_PTR(pItem)) &&
  2328. (pItem >= pTVWnd->ComPropSheetUI.pOptItem) &&
  2329. (pItem <= pTVWnd->pLastItem)) {
  2330. ItemIdx = (WORD)(pItem - pTVWnd->ComPropSheetUI.pOptItem);
  2331. } else {
  2332. ItemIdx = LOWORD(LODWORD(pItem));
  2333. pItem = PIDX_INTOPTITEM(pTVWnd, ItemIdx);
  2334. if ((ItemIdx == INTIDX_PAPER) ||
  2335. (ItemIdx == INTIDX_GRAPHIC)) {
  2336. if (pTVWnd->Flags & TWF_ADVDOCPROP) {
  2337. DefTVIS &= ~TVIS_EXPANDED;
  2338. } else {
  2339. DefTVIS |= TVIS_EXPANDED;
  2340. }
  2341. }
  2342. }
  2343. CPSUIDBG(DBG_AI, ("ItemIdx = %ld (%08lx)", ItemIdx, ItemIdx));
  2344. CPSUIOPTITEM(DBG_AI, pTVWnd, "AddItem", 1, pItem);
  2345. if (!(pItem->Flags & (OPTIF_INT_ADDED | OPTIF_ITEM_HIDE))) {
  2346. TV_INSERTSTRUCT tvins;
  2347. //
  2348. // Set to internal added if this item is a user item
  2349. //
  2350. _OI_TVLEVEL(pItem) = (BYTE)TVLevel;
  2351. tvins.item.state = DefTVIS;
  2352. tvins.item.stateMask = TVIS_EXPANDED; // | TVIS_BOLD;
  2353. tvins.item.mask = TVIF_TEXT |
  2354. TVIF_STATE |
  2355. TVIF_IMAGE |
  2356. TVIF_SELECTEDIMAGE;
  2357. tvins.hInsertAfter = TVI_LAST;
  2358. tvins.hParent = hParent;
  2359. SetTVItemState(pTVWnd, &tvins, pItem);
  2360. if ((pItem->Flags |= OPTIF_INT_ADDED) & OPTIF_INITIAL_TVITEM) {
  2361. if (pTVWnd->pCurTVItem) {
  2362. CPSUIWARN(("Treeview: More than one OPTIF_INITIAL_TVITEM, OverRide"));
  2363. }
  2364. pTVWnd->pCurTVItem = pItem;
  2365. }
  2366. return(_OI_HITEM(pItem));
  2367. }
  2368. return(NULL);
  2369. }
  2370. UINT
  2371. AddItemGroup(
  2372. PTVWND pTVWnd,
  2373. HTREEITEM hParent,
  2374. POPTITEM *ppItem,
  2375. UINT TVLevel,
  2376. UINT BegDMPubID,
  2377. UINT EndDMPubID
  2378. )
  2379. /*++
  2380. Routine Description:
  2381. This function add items starting from the *ppItem, the item added includes
  2382. item's sibling and all theirs children until end of the the pOptItem array.
  2383. It also skip all the OPTIF_INT_ADDED and OPTIF_ITEM_HIDE items
  2384. and its children
  2385. Arguments:
  2386. pTVWnd - Pointer to the TVWND instance data
  2387. hParent - Parent of the starting item
  2388. ppItem - Pointer to POPTITEM for the starting item in the pOptItem array
  2389. at return this pointer is updated to the next item which either
  2390. at end of array or the parent's sibling
  2391. Return Value:
  2392. UINT, count of item added to the treeview, it also update ppItem pointer
  2393. Author:
  2394. 27-Jun-1995 Tue 18:44:16 created -by- Daniel Chou (danielc)
  2395. Revision History:
  2396. --*/
  2397. {
  2398. POPTITEM pItem;
  2399. HTREEITEM hCurGrp;
  2400. POPTITEM pLastItem;
  2401. BYTE GrpLevel;
  2402. BYTE CurLevel;
  2403. UINT cAdd;
  2404. pItem = *ppItem;
  2405. pLastItem = pTVWnd->pLastItem;
  2406. GrpLevel = pItem->Level;
  2407. hCurGrp = hParent;
  2408. cAdd = 0;
  2409. while (pItem <= pLastItem) {
  2410. if ((CurLevel = pItem->Level) < GrpLevel) {
  2411. //
  2412. // Finished the group level
  2413. //
  2414. break;
  2415. } else if (pItem->Flags & (OPTIF_ITEM_HIDE | OPTIF_INT_ADDED)) {
  2416. //
  2417. // Skip this item and all its children
  2418. //
  2419. CPSUIOPTITEM(DBGITEM_AIG, pTVWnd, "Skip HIDE/INT_ADDED Item", 1, pItem);
  2420. while ((++pItem <= pLastItem) && (pItem->Level > CurLevel));
  2421. } else if (CurLevel > GrpLevel) {
  2422. //
  2423. // Adding its children only if this item is not OPTIF_INT_ADDED and
  2424. // OPTIF_ITEM_HIDE
  2425. //
  2426. CPSUIOPTITEM(DBG_AIG, pTVWnd, "AddItemGroup", 1, pItem);
  2427. cAdd += AddItemGroup(pTVWnd,
  2428. hCurGrp,
  2429. &pItem,
  2430. TVLevel + 1,
  2431. 0,
  2432. 0xFFFF);
  2433. } else if (((UINT)pItem->DMPubID < BegDMPubID) ||
  2434. ((UINT)pItem->DMPubID > EndDMPubID)) {
  2435. //
  2436. // Skip this item and all its children
  2437. //
  2438. CPSUIOPTITEM(DBGITEM_AIG, pTVWnd, "Skip DMPubID Item", 1, pItem);
  2439. CPSUIDBG(DBGITEM_AIG, ("Skip %ld (ONLY DMPubID=%ld-%ld Items)",
  2440. pItem->DMPubID, BegDMPubID, EndDMPubID));
  2441. while ((++pItem <= pLastItem) && (pItem->Level > CurLevel));
  2442. } else {
  2443. HTREEITEM hAdd;
  2444. UINT DefTVIS = 0;
  2445. //
  2446. // Adding its sibling, checking if we could have children, if
  2447. // we do then add the TVIS_BOLD flag to it, at return we want to
  2448. // know if did add the item, if we do then this is his childrern's
  2449. // parent handle
  2450. //
  2451. DefTVIS = (pItem->Flags & OPTIF_COLLAPSE) ? 0 : TVIS_EXPANDED;
  2452. if ((pItem < pLastItem) && ((pItem + 1)->Level > CurLevel)) {
  2453. DefTVIS |= TVIS_BOLD;
  2454. }
  2455. if (hAdd = AddItem(pTVWnd, hParent, pItem, DefTVIS, TVLevel)) {
  2456. hCurGrp = hAdd;
  2457. cAdd++;
  2458. }
  2459. pItem++;
  2460. }
  2461. }
  2462. *ppItem = pItem;
  2463. return(cAdd);
  2464. }
  2465. UINT
  2466. AddPubGroup(
  2467. PTVWND pTVWnd,
  2468. HTREEITEM hParent,
  2469. PINTTVGRP *ppitvg,
  2470. UINT TVLevel,
  2471. UINT DMPubIDAdd
  2472. )
  2473. /*++
  2474. Routine Description:
  2475. Arguments:
  2476. Return Value:
  2477. Author:
  2478. 09-Sep-1995 Sat 11:58:59 created -by- Daniel Chou (danielc)
  2479. Revision History:
  2480. --*/
  2481. {
  2482. POPTITEM pItem = NULL;
  2483. HTREEITEM hLastGrp;
  2484. HTREEITEM hCurGrp;
  2485. PINTTVGRP pitvg;
  2486. LPWORD pDMPubIdx;
  2487. UINT cAdd;
  2488. WORD Idx;
  2489. BYTE GrpLevel;
  2490. BYTE CurLevel;
  2491. pitvg = *ppitvg;
  2492. pDMPubIdx = pTVWnd->DMPubIdx;
  2493. GrpLevel = (BYTE)(pitvg->LevelFlags & ITVG_LEVEL_MASK);
  2494. hLastGrp = NULL;
  2495. hCurGrp = hParent;
  2496. cAdd = 0;
  2497. while ((CurLevel = (pitvg->LevelFlags & ITVG_LEVEL_MASK)) >= GrpLevel) {
  2498. if (CurLevel > GrpLevel) {
  2499. //
  2500. // Adding its children
  2501. //
  2502. PINTTVGRP pParentitvg = pitvg - 1;
  2503. CPSUIASSERT(0, "AddPubGroup: Internal ERROR, no parent=%ld",
  2504. (cAdd) && (hCurGrp), UIntToPtr(cAdd));
  2505. if (Idx = (WORD)AddPubGroup(pTVWnd,
  2506. hCurGrp,
  2507. &pitvg,
  2508. TVLevel + 1,
  2509. DMPubIDAdd)) {
  2510. cAdd += (UINT)Idx;
  2511. } else {
  2512. CPSUIDBG(DBG_APG,
  2513. ("AddPubGroup(Level=%02lx, ID=%ld), pItem=%08lx",
  2514. pParentitvg->LevelFlags, pParentitvg->DMPubID, pItem));
  2515. if ((pParentitvg->DMPubID >= DMPUB_HDR_FIRST) ||
  2516. ((pItem) && (pItem->pOptType == NULL))) {
  2517. //
  2518. // Nothing added for this group, if this is the internal
  2519. // group item then delete otherwise do not delete user's
  2520. // item if the item has OPTTYPE
  2521. //
  2522. CPSUIINT(("0 Added, DELETE its Parent"));
  2523. TreeView_DeleteItem(pTVWnd->hWndTV, hCurGrp);
  2524. --cAdd;
  2525. hCurGrp = hLastGrp;
  2526. hLastGrp = NULL;
  2527. } else {
  2528. //
  2529. // We need to take out the BOLD status
  2530. //
  2531. TV_ITEM tvi;
  2532. tvi.mask = TVIF_STATE;
  2533. tvi.hItem = hCurGrp;
  2534. tvi.state = 0;
  2535. tvi.stateMask = TVIS_BOLD;
  2536. CPSUIINT(("0 Added, Remove pItem's BOLD"));
  2537. TreeView_SetItem(pTVWnd->hWndTV, &tvi);
  2538. }
  2539. }
  2540. } else {
  2541. HTREEITEM hAdd = NULL;
  2542. UINT DefTVIS;
  2543. BYTE DMPubID;
  2544. BOOL IsHdr;
  2545. //
  2546. // Adding its sibling, checking if we could have children, if
  2547. // we do then add the TVIS_BOLD flag to it, at return we want to
  2548. // know if did add the item, if we do then this is his childrern's
  2549. // parent handle
  2550. //
  2551. if (pitvg->LevelFlags & ITVGF_COLLAPSE) {
  2552. DefTVIS = 0;
  2553. } else {
  2554. DefTVIS = TVIS_EXPANDED;
  2555. }
  2556. if (pitvg->LevelFlags & ITVGF_BOLD) {
  2557. DefTVIS |= TVIS_BOLD;
  2558. }
  2559. if ((DMPubID = pitvg->DMPubID) >= DMPUB_HDR_FIRST) {
  2560. pItem = (POPTITEM)UIntToPtr(DMPubID - DMPUB_HDR_FIRST + INTIDX_FIRST);
  2561. DefTVIS |= TVIS_BOLD;
  2562. } else if ((Idx = pDMPubIdx[DMPubID - DMPUB_FIRST]) != 0xFFFF) {
  2563. pItem = pTVWnd->ComPropSheetUI.pOptItem + Idx;
  2564. } else {
  2565. pItem = NULL;
  2566. }
  2567. if ((pItem) &&
  2568. (hAdd = AddItem(pTVWnd, hParent, pItem, DefTVIS, TVLevel))) {
  2569. hLastGrp = hCurGrp;
  2570. hCurGrp = hAdd;
  2571. cAdd++;
  2572. //
  2573. // If this item has children, add the children
  2574. //
  2575. if ((VALID_PTR(pItem)) &&
  2576. (++pItem <= pTVWnd->pLastItem) &&
  2577. (pItem->Level > (pItem-1)->Level)) {
  2578. cAdd += AddItemGroup(pTVWnd,
  2579. hAdd,
  2580. &pItem,
  2581. TVLevel + 1,
  2582. 0,
  2583. 0xFFFF);
  2584. }
  2585. pitvg++;
  2586. } else {
  2587. //
  2588. // Skip all the childrens belongs to him
  2589. //
  2590. CPSUIDBG(DBG_APG,
  2591. ("Eiter pItem=NULL(%08lx) or AddItem()=NULL(%08lx)",
  2592. pItem, hAdd));
  2593. while (((++pitvg)->LevelFlags & ITVG_LEVEL_MASK) > CurLevel) {
  2594. //
  2595. // We need to skip all the internal header and hide all
  2596. // the real user items
  2597. //
  2598. if ((DMPubID = pitvg->DMPubID) &&
  2599. (DMPubID <= DMPUB_LAST) &&
  2600. ((Idx = pDMPubIdx[DMPubID - DMPUB_FIRST]) != 0xFFFF)) {
  2601. POPTITEM pLastItem;
  2602. BYTE ItemLevel;
  2603. pItem = pTVWnd->ComPropSheetUI.pOptItem + Idx;
  2604. pLastItem = pTVWnd->pLastItem;
  2605. ItemLevel = pItem->Level;
  2606. CPSUIOPTITEM(DBG_APG, pTVWnd, "Skip ITVG", 1, pItem);
  2607. SKIP_CHILDREN_ORFLAGS(pItem,
  2608. pLastItem,
  2609. ItemLevel,
  2610. OPTIF_INT_ADDED);
  2611. }
  2612. }
  2613. }
  2614. }
  2615. }
  2616. if ((GrpLevel == 1) && (hCurGrp)) {
  2617. CPSUIDBG(DBG_OEM_ITEM,
  2618. ("Add OEM Item Group, DMPubID=%ld", DMPubIDAdd));
  2619. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2620. cAdd += AddItemGroup(pTVWnd,
  2621. hCurGrp,
  2622. &pItem,
  2623. TVLevel,
  2624. DMPubIDAdd,
  2625. DMPubIDAdd);
  2626. }
  2627. *ppitvg = pitvg;
  2628. return(cAdd);
  2629. }
  2630. BOOL
  2631. AddOptItemToTreeView(
  2632. PTVWND pTVWnd
  2633. )
  2634. /*++
  2635. Routine Description:
  2636. Arguments:
  2637. Return Value:
  2638. Author:
  2639. 18-Aug-1995 Fri 14:39:32 created -by- Daniel Chou (danielc)
  2640. Revision History:
  2641. 30-Jul-1997 Wed 14:02:36 updated -by- Daniel Chou (danielc)
  2642. Added codes that allowed DMPubID 0 to be added to Root
  2643. --*/
  2644. {
  2645. HTREEITEM hParent;
  2646. HTREEITEM hRoot;
  2647. POPTITEM pItem;
  2648. UINT DefTVIS = TVIS_EXPANDED;
  2649. UINT TVLevel = 0;
  2650. //
  2651. // Adding the header to it as Icon: CallerName XXXX
  2652. //
  2653. hRoot =
  2654. hParent = AddItem(pTVWnd,
  2655. TVI_ROOT,
  2656. (POPTITEM)INTIDX_TVROOT,
  2657. DefTVIS | TVIS_BOLD,
  2658. TVLevel);
  2659. TVLevel += 1;
  2660. if (pTVWnd->Flags & TWF_TVPAGE_CHK_DMPUB) {
  2661. if (pTVWnd->Flags & TWF_TVPAGE_NODMPUB) {
  2662. POPTITEM pLastItem = pTVWnd->pLastItem;
  2663. //
  2664. // Mark all the DMPUB_xxx to OPTIF_INT_ADDED
  2665. //
  2666. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2667. while (pItem <= pLastItem) {
  2668. BYTE CurLevel = pItem->Level;
  2669. if ((pItem->DMPubID != DMPUB_NONE) &&
  2670. (pItem->DMPubID < DMPUB_USER)) {
  2671. SKIP_CHILDREN_ORFLAGS(pItem,
  2672. pLastItem,
  2673. CurLevel,
  2674. OPTIF_INT_ADDED);
  2675. } else {
  2676. SKIP_CHILDREN(pItem, pLastItem, CurLevel);
  2677. }
  2678. }
  2679. } else {
  2680. HTREEITEM hHdrGrp;
  2681. PINTTVGRP pitvg;
  2682. pitvg = (PINTTVGRP)IntTVGrpPaper;
  2683. AddPubGroup(pTVWnd,
  2684. hRoot,
  2685. &pitvg,
  2686. TVLevel,
  2687. DMPUB_OEM_PAPER_ITEM);
  2688. pitvg = (PINTTVGRP)IntTVGrpGraphic;
  2689. AddPubGroup(pTVWnd,
  2690. hRoot,
  2691. &pitvg,
  2692. TVLevel,
  2693. DMPUB_OEM_GRAPHIC_ITEM);
  2694. DefTVIS = 0;
  2695. }
  2696. }
  2697. if (pTVWnd->IntTVOptIdx) {
  2698. pItem = PIDX_INTOPTITEM(pTVWnd, pTVWnd->IntTVOptIdx);
  2699. if (pTVWnd->Flags & (TWF_ADVDOCPROP | TWF_TV_BY_PUSH)) {
  2700. pItem->Flags &= ~OPTIF_COLLAPSE;
  2701. }
  2702. if (pItem->Flags & OPTIF_COLLAPSE) {
  2703. DefTVIS &= ~TVIS_EXPANDED;
  2704. } else {
  2705. DefTVIS |= TVIS_EXPANDED;
  2706. }
  2707. hParent = AddItem(pTVWnd,
  2708. hRoot,
  2709. (POPTITEM)pTVWnd->IntTVOptIdx,
  2710. DefTVIS | TVIS_BOLD,
  2711. TVLevel);
  2712. //
  2713. // Add OEM items that under the TVROOT
  2714. //
  2715. CPSUIDBG(DBG_OEM_ITEM,
  2716. ("Add OEM Item Group, DMPubID=%ld", DMPUB_OEM_ROOT_ITEM));
  2717. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2718. AddItemGroup(pTVWnd,
  2719. hRoot,
  2720. &pItem,
  2721. TVLevel,
  2722. DMPUB_OEM_ROOT_ITEM,
  2723. DMPUB_OEM_ROOT_ITEM);
  2724. TVLevel += 1;
  2725. }
  2726. //
  2727. // Add rest of the OPTITEMS
  2728. //
  2729. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2730. if ((!AddItemGroup(pTVWnd, hParent, &pItem, TVLevel, 0, 0xFFFF)) &&
  2731. (hParent != hRoot)) {
  2732. //
  2733. // Since we did not add any item, s delete the Options header if any
  2734. //
  2735. CPSUIINT(("There is NO 'Options' items, delete the header"));
  2736. TreeView_DeleteItem(pTVWnd->hWndTV, hParent);
  2737. }
  2738. return(TRUE);
  2739. }
  2740. HWND
  2741. CreateTVOption(
  2742. HWND hDlg,
  2743. PTVWND pTVWnd
  2744. )
  2745. /*++
  2746. Routine Description:
  2747. Arguments:
  2748. Return Value:
  2749. Author:
  2750. 19-Jun-1995 Mon 16:18:43 created -by- Daniel Chou (danielc)
  2751. Revision History:
  2752. --*/
  2753. {
  2754. HWND hWndTV;
  2755. HTREEITEM hRoot;
  2756. POPTITEM pItem;
  2757. POPTITEM pCurTVItem;
  2758. POPTITEM pLastItem;
  2759. BYTE TVPageIdx;
  2760. pTVWnd->hDlgTV = hDlg;
  2761. pCurTVItem = pTVWnd->pCurTVItem;
  2762. if (hWndTV = CreatehWndTV(hDlg, pTVWnd)) {
  2763. pItem = &(pTVWnd->IntOptItem[0]);
  2764. pLastItem = &(pTVWnd->IntOptItem[INTIDX_TOTAL - 1]);
  2765. TVPageIdx = (BYTE)(pTVWnd->cMyDlgPage - 1);
  2766. while (pItem <= pLastItem) {
  2767. _OI_HITEM(pItem) = NULL;
  2768. pItem->Flags &= ~(OPTIF_INT_ADDED | OPTIF_INITIAL_TVITEM);
  2769. pItem->DlgPageIdx = TVPageIdx;
  2770. if (pItem == pCurTVItem) {
  2771. pItem->Flags |= OPTIF_INITIAL_TVITEM;
  2772. }
  2773. ++pItem;
  2774. }
  2775. pItem = pTVWnd->ComPropSheetUI.pOptItem;
  2776. pLastItem = pTVWnd->pLastItem;
  2777. while (pItem <= pLastItem) {
  2778. _OI_HITEM(pItem) = NULL;
  2779. pItem->Flags &= ~(OPTIF_INT_ADDED | OPTIF_INITIAL_TVITEM);
  2780. if ((pTVWnd->Flags & TWF_TV_BY_PUSH) &&
  2781. (pItem->DlgPageIdx != TVPageIdx)) {
  2782. pItem->Flags |= OPTIF_INT_ADDED;
  2783. }
  2784. if (pItem == pCurTVItem) {
  2785. pItem->Flags |= OPTIF_INITIAL_TVITEM;
  2786. }
  2787. ++pItem;
  2788. }
  2789. pTVWnd->pCurTVItem = NULL;
  2790. InitDlgCtrl(hDlg, pTVWnd);
  2791. SendMessage(pTVWnd->hWndTV,
  2792. TVM_SETIMAGELIST,
  2793. (WPARAM)TVSIL_NORMAL,
  2794. (LPARAM)pTVWnd->himi);
  2795. AddOptItemToTreeView(pTVWnd);
  2796. } else {
  2797. CPSUIERR(("\nCreatehWndTV() failed"));
  2798. }
  2799. return(hWndTV);
  2800. }
  2801. #if DBG
  2802. #if 0
  2803. LRESULT
  2804. CALLBACK
  2805. ShowChildWndProc(
  2806. HWND hWnd,
  2807. LPARAM lParam
  2808. )
  2809. {
  2810. HWND hParent = (HWND)hWnd;
  2811. DWORD dw;
  2812. WCHAR Buf[64];
  2813. dw = 0;
  2814. while ((HWND)lParam != hParent) {
  2815. Buf[dw++] = L' ';
  2816. Buf[dw++] = L' ';
  2817. hParent = GetParent(hParent);
  2818. }
  2819. Buf[dw++] = L'\0';
  2820. CPSUIDBG(DBG_SCID, ("%wshWnd=%08lx, hParent=%08lx, ID=%5ld",
  2821. Buf, hWnd, GetParent(hWnd),
  2822. GetWindowLongPtr(hWnd, GWLP_ID)));
  2823. return(TRUE);
  2824. }
  2825. #endif
  2826. #endif
  2827. INT_PTR
  2828. CALLBACK
  2829. TreeViewProc(
  2830. HWND hDlg,
  2831. UINT Msg,
  2832. WPARAM wParam,
  2833. LPARAM lParam
  2834. )
  2835. /*++
  2836. Routine Description:
  2837. Arguments:
  2838. Return Value:
  2839. Author:
  2840. 28-Jun-1995 Wed 17:00:44 created -by- Daniel Chou (danielc)
  2841. Revision History:
  2842. --*/
  2843. {
  2844. POPTITEM pItem;
  2845. HWND hWndTV;
  2846. HWND *phWnd;
  2847. HICON hIcon;
  2848. PTVWND pTVWnd;
  2849. PMYDLGPAGE pCurMyDP;
  2850. NM_TREEVIEW *pNMTV;
  2851. DWORD dw;
  2852. HTREEITEM hItem;
  2853. if (Msg == WM_INITDIALOG) {
  2854. CPSUIINT(("Treeview WM_INITDIALOG: hDlg=%08lx, pPSP=%08lx", hDlg, lParam));
  2855. pCurMyDP = (PMYDLGPAGE)(((LPPROPSHEETPAGE)lParam)->lParam);
  2856. pTVWnd = (PTVWND)pCurMyDP->pTVWnd;
  2857. pCurMyDP->pPSPInfo = PPSPINFO_FROM_WM_INITDIALOG_LPARAM(lParam);
  2858. pCurMyDP->hDlgChild = NULL;
  2859. pTVWnd->Flags |= TWF_IN_TVPAGE;
  2860. SetWindowLongPtr(hDlg,
  2861. GWL_EXSTYLE,
  2862. GetWindowLongPtr(hDlg, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
  2863. if (!ADD_PMYDLGPAGE(hDlg, pCurMyDP)) {
  2864. return(FALSE);
  2865. }
  2866. if (pTVWnd->Flags & TWF_TV_BY_PUSH) {
  2867. SetWindowText(hDlg, ((LPPROPSHEETPAGE)lParam)->pszTitle);
  2868. }
  2869. CreateImageList(hDlg, pTVWnd);
  2870. CreateTVOption(hDlg, pTVWnd);
  2871. SetUniqChildID(hDlg);
  2872. CommonPropSheetUIHelpSetup(NULL, pTVWnd);
  2873. UpdateCallBackChanges(hDlg, pTVWnd, TRUE);
  2874. if (pItem = pTVWnd->pCurTVItem) {
  2875. pTVWnd->pCurTVItem = NULL;
  2876. if (!TreeView_SelectItem(pTVWnd->hWndTV, _OI_HITEM(pItem))) {
  2877. pItem = NULL;
  2878. }
  2879. }
  2880. if ((!pItem) &&
  2881. (hItem = TreeView_GetRoot(pTVWnd->hWndTV)) &&
  2882. (!SelectFirstVisibleOptItem(pTVWnd, hItem))) {
  2883. TreeView_SelectItem(pTVWnd->hWndTV, hItem);
  2884. }
  2885. if (pTVWnd->Flags & TWF_TV_BY_PUSH) {
  2886. SetOptItemNewDef(hDlg, pTVWnd, TRUE);
  2887. }
  2888. SetFocus(pTVWnd->hWndTV);
  2889. return(FALSE);
  2890. }
  2891. if (pCurMyDP = GET_PMYDLGPAGE(hDlg)) {
  2892. pTVWnd = pCurMyDP->pTVWnd;
  2893. hWndTV = pTVWnd->hWndTV;
  2894. switch(Msg) {
  2895. case WM_GETDLGCODE:
  2896. CPSUIINT(("TreeViewProc: WM_GETDLGCODE"));
  2897. break;
  2898. case WM_NEXTDLGCTL:
  2899. CPSUIINT(("TreeViewProc: WM_NEXTDLGCTL: flHandle=%ld, wParam=%08lx",
  2900. LOWORD(lParam), wParam));
  2901. break;
  2902. case WM_DRAWITEM:
  2903. return(DrawLBCBItem(pTVWnd, (LPDRAWITEMSTRUCT)lParam));
  2904. case WM_COMMAND:
  2905. if (pTVWnd->Flags & TWF_TV_BY_PUSH) {
  2906. switch (LOWORD(wParam)) {
  2907. case IDCANCEL:
  2908. pItem = PIDX_INTOPTITEM(pTVWnd, INTIDX_TVROOT);
  2909. DoCallBack(hDlg,
  2910. pTVWnd,
  2911. pItem,
  2912. pItem->pSel,
  2913. (_CPSUICALLBACK)InternalRevertDef2,
  2914. NULL,
  2915. 0,
  2916. CPSUICB_REASON_SEL_CHANGED);
  2917. UpdateCallBackChanges(hDlg, pTVWnd, TRUE);
  2918. EndDialog(hDlg, 0);
  2919. return(TRUE);
  2920. case IDOK:
  2921. UpdateCallBackChanges(hDlg, pTVWnd, TRUE);
  2922. EndDialog(hDlg, 1);
  2923. return(TRUE);
  2924. default:
  2925. break;
  2926. }
  2927. }
  2928. //
  2929. // Fall though
  2930. //
  2931. case WM_HSCROLL:
  2932. if (pItem = DlgHScrollCommand(hDlg, pTVWnd, (HWND)lParam, wParam)) {
  2933. UpdateTreeViewItem(hDlg, pTVWnd, pItem, FALSE);
  2934. }
  2935. break;
  2936. case WM_ACTIVATE:
  2937. if (LOWORD(wParam) != WA_INACTIVE) {
  2938. CPSUIINT(("!! WM_SETACTIVE: cEdit=%ld !!", pTVWnd->chWndEdit));
  2939. InvalidateRect(hWndTV, NULL, FALSE);
  2940. if (dw = (DWORD)pTVWnd->chWndEdit) {
  2941. phWnd = pTVWnd->hWndEdit;
  2942. while (dw--) {
  2943. if (hWndTV = *phWnd++) {
  2944. SetWindowPos(hWndTV, NULL,
  2945. 0, 0, 0, 0,
  2946. SWP_NOSIZE | SWP_NOZORDER |
  2947. SWP_NOMOVE | SWP_FRAMECHANGED);
  2948. InvalidateRect(hWndTV, NULL, FALSE);
  2949. }
  2950. }
  2951. }
  2952. }
  2953. break;
  2954. case WM_HELP:
  2955. wParam = (WPARAM)((LPHELPINFO)lParam)->hItemHandle;
  2956. lParam = (LPARAM)MAKELONG(((LPHELPINFO)lParam)->MousePos.x,
  2957. ((LPHELPINFO)lParam)->MousePos.y);
  2958. case WM_CONTEXTMENU:
  2959. if (lParam == 0xFFFFFFFF) {
  2960. RECT rc;
  2961. if ((HWND)(wParam = (WPARAM)GetFocus()) == hWndTV) {
  2962. pTVWnd->VKeyTV = VK_F1;
  2963. if (TreeView_GetItemRect(hWndTV,
  2964. _OI_HITEM(pTVWnd->pCurTVItem),
  2965. &rc,
  2966. TRUE)) {
  2967. ClientToScreen(hWndTV, (LPPOINT)&rc.left);
  2968. ClientToScreen(hWndTV, (LPPOINT)&rc.right);
  2969. } else {
  2970. GetWindowRect((HWND)wParam, &rc);
  2971. }
  2972. } else {
  2973. GetWindowRect((HWND)wParam, &rc);
  2974. }
  2975. CPSUIINT(("MousePos=0xFFFFFFFF, GetFocus=%08lx, rc=(%ld, %ld)-(%ld, %ld)",
  2976. (HWND)wParam, rc.left, rc.top, rc.right, rc.bottom));
  2977. rc.left += ((rc.right - rc.left) / 2);
  2978. rc.top += ((rc.bottom - rc.top) / 2);
  2979. lParam = (LPARAM)MAKELONG(rc.left, rc.top);
  2980. }
  2981. CPSUIINT(("--- WM_%ws --hWndTV=%08lx, wParam=%08lx. Mouse=(%ld, %ld)----",
  2982. (Msg == WM_HELP) ? L"HELP" : L"CONTEXTMENU",
  2983. hWndTV, wParam, LOWORD(lParam), HIWORD(lParam)));
  2984. if ((HWND)wParam == hWndTV) {
  2985. pItem = (pTVWnd->VKeyTV == VK_F1) ?
  2986. pTVWnd->pCurTVItem : TreeViewHitTest(pTVWnd,
  2987. (LONG)lParam,
  2988. TVHT_ONITEM);
  2989. if (!pItem) {
  2990. CPSUIINT(("pItem=NULL, hWnd=%08lx, ID=%ld",
  2991. wParam, GetWindowLongPtr((HWND)wParam, GWLP_ID)));
  2992. pItem = pItemFromhWnd(hWndTV, pTVWnd, NULL, (LONG)lParam);
  2993. }
  2994. } else {
  2995. pItem = pItemFromhWnd(hDlg, pTVWnd, (HWND)wParam, (LONG)lParam);
  2996. }
  2997. //
  2998. // Reset key now
  2999. //
  3000. pTVWnd->VKeyTV = 0;
  3001. if (Msg == WM_CONTEXTMENU) {
  3002. DoContextMenu(pTVWnd, hDlg, pItem, lParam);
  3003. } else if (pItem) {
  3004. CommonPropSheetUIHelp(hDlg,
  3005. pTVWnd,
  3006. (HWND)hWndTV,
  3007. (DWORD)lParam,
  3008. pItem,
  3009. HELP_WM_HELP);
  3010. }
  3011. break;
  3012. case WM_NOTIFY:
  3013. pNMTV = (NM_TREEVIEW *)lParam;
  3014. dw = 0;
  3015. switch (pNMTV->hdr.code) {
  3016. case NM_DBLCLK:
  3017. TreeViewChangeMode(pTVWnd, pTVWnd->pCurTVItem, TVCM_SELECT);
  3018. break;
  3019. case NM_SETFOCUS:
  3020. case NM_CLICK:
  3021. case NM_RDBLCLK:
  3022. case NM_RCLICK:
  3023. break;
  3024. case TVN_ITEMEXPANDING:
  3025. CPSUIDBG(DBG_TVPROC, ("TVN_ITEMEXPANDING:"));
  3026. break;
  3027. case TVN_ITEMEXPANDED:
  3028. CPSUIDBG(DBG_TVPROC, ("TVN_ITEMEXPANDED:"));
  3029. if ((pTVWnd->IntTVOptIdx) &&
  3030. (pItem = PIDX_INTOPTITEM(pTVWnd, pTVWnd->IntTVOptIdx)) &&
  3031. (_OI_HITEM(pItem) == pNMTV->itemNew.hItem)) {
  3032. if (pNMTV->itemNew.state & TVIS_EXPANDED) {
  3033. CPSUIINT(("Internal OPTIONS Expanded"));
  3034. pItem->Flags &= ~OPTIF_COLLAPSE;
  3035. } else {
  3036. CPSUIINT(("Internal OPTIONS Collapse"));
  3037. pItem->Flags |= OPTIF_COLLAPSE;
  3038. }
  3039. }
  3040. break;
  3041. case TVN_KEYDOWN:
  3042. pTVWnd->VKeyTV = ((TV_KEYDOWN *)lParam)->wVKey;
  3043. CPSUIDBG(DBG_KEYS, ("TVN_KEYDOWN: VKey=%ld", pTVWnd->VKeyTV));
  3044. if ((pItem = pTVWnd->pCurTVItem) &&
  3045. (hItem = _OI_HITEM(pItem))) {
  3046. switch (pTVWnd->VKeyTV) {
  3047. case VK_LEFT:
  3048. case VK_BACK:
  3049. if ((!TreeView_GetChild(hWndTV, hItem)) &&
  3050. (hItem = TreeView_GetParent(hWndTV, hItem))) {
  3051. PostMessage(hWndTV,
  3052. TVM_SELECTITEM,
  3053. (WPARAM)TVGN_CARET,
  3054. (LPARAM)hItem);
  3055. }
  3056. break;
  3057. case VK_RIGHT:
  3058. if ((pTVWnd->chWndEdit) &&
  3059. (pTVWnd->hWndEdit[0])) {
  3060. SetFocus(pTVWnd->hWndEdit[0]);
  3061. }
  3062. break;
  3063. }
  3064. }
  3065. break;
  3066. case TVN_GETDISPINFO:
  3067. SetTVItemImage(pTVWnd, (TV_DISPINFO *)lParam);
  3068. break;
  3069. case TVN_SELCHANGED:
  3070. #if DO_IN_PLACE
  3071. if (pItem = pTVWnd->pCurTVItem) {
  3072. _OI_INTFLAGS(pItem) &= ~OIDF_ZERO_SEL_LEN;
  3073. SetTVItemState(pTVWnd, NULL, pItem);
  3074. }
  3075. if ((pItem = GetOptions(pTVWnd, pNMTV->itemNew.lParam)) &&
  3076. (!(pItem->Flags & OPTIF_INT_HIDE))) {
  3077. CPSUIINT(("pOldItem=%08lx, pNewItem=%08lx, cxItem=%ld/%ld",
  3078. pTVWnd->pCurTVItem, pItem, pTVWnd->cxItem, pTVWnd->cxMaxItem));
  3079. _OI_INTFLAGS(pItem) |= OIDF_ZERO_SEL_LEN;
  3080. SetTVItemState(pTVWnd, NULL, pItem);
  3081. }
  3082. pTVWnd->pCurTVItem = (POPTITEM)~0;
  3083. #endif
  3084. pTVWnd->pCurTVItem = SetupTVSelect(hDlg,
  3085. pNMTV,
  3086. STVS_REINIT | STVS_ACTIVE);
  3087. #if DO_IN_PLACE
  3088. if (pTVWnd->cxItem > pTVWnd->cxMaxItem) {
  3089. CPSUIINT(("pCurTVItem=%08lx, cxItem=%ld <= %ld, Redo SetTVItemState()",
  3090. pTVWnd->pCurTVItem, pTVWnd->cxItem, pTVWnd->cxMaxItem));
  3091. SetTVItemState(pTVWnd, NULL, pTVWnd->pCurTVItem);
  3092. }
  3093. #endif
  3094. CPSUIOPTITEM(DBGITEM_SELCHG, pTVWnd, "TVN_SELCHANGED", 1, pTVWnd->pCurTVItem);
  3095. CPSUIDBG(DBG_SCID, ("\n-----EnumChild of (%08lx)-----",
  3096. GetParent(hDlg)));
  3097. #if DBG
  3098. #if 0
  3099. EnumChildWindows(GetParent(hDlg),
  3100. ShowChildWndProc,
  3101. (LPARAM)GetParent(hDlg));
  3102. #endif
  3103. #endif
  3104. break;
  3105. case PSN_SETACTIVE:
  3106. CPSUIDBG(DBG_TVPROC,
  3107. ("\nTreeView: Got PSN_SETACTIVE, pTVWnd=%08lx (%ld), Page=%u -> %u\n",
  3108. pTVWnd, pTVWnd->cMyDlgPage,
  3109. (UINT)pTVWnd->ActiveDlgPage, (UINT)pCurMyDP->PageIdx));
  3110. pCurMyDP->Flags |= MYDPF_PAGE_ACTIVE;
  3111. pTVWnd->ActiveDlgPage = pCurMyDP->PageIdx;
  3112. pTVWnd->Flags |= TWF_IN_TVPAGE;
  3113. DoCallBack(hDlg,
  3114. pTVWnd,
  3115. pTVWnd->ComPropSheetUI.pOptItem,
  3116. (LPVOID)-1,
  3117. NULL,
  3118. NULL,
  3119. 0,
  3120. CPSUICB_REASON_SETACTIVE);
  3121. if ((pTVWnd->pCurTVItem) &&
  3122. (IS_HDR_PUSH(GET_POPTTYPE(pTVWnd->pCurTVItem)))) {
  3123. UpdateTreeViewItem(hDlg, pTVWnd, pTVWnd->pCurTVItem, TRUE);
  3124. }
  3125. UpdateTreeView(hDlg, pCurMyDP);
  3126. CPSUIINT(("!! WM_SETACTIVE: cEdit=%ld", pTVWnd->chWndEdit));
  3127. InvalidateRect(hWndTV, NULL, FALSE);
  3128. if (dw = (DWORD)pTVWnd->chWndEdit) {
  3129. phWnd = pTVWnd->hWndEdit;
  3130. while (dw--) {
  3131. if (hWndTV = *phWnd++) {
  3132. InvalidateRect(hWndTV, NULL, FALSE);
  3133. }
  3134. }
  3135. }
  3136. dw = 0;
  3137. break;
  3138. case PSN_KILLACTIVE:
  3139. CPSUIDBG(DBG_TVPROC, ("TreeView: Got PSN_KILLACTIVE, pTVWnd=%08lx (%ld)",
  3140. pTVWnd, pTVWnd->cMyDlgPage));
  3141. if (pCurMyDP) {
  3142. pCurMyDP->hWndFocus = GetFocus();
  3143. pCurMyDP->Flags &= ~MYDPF_PAGE_ACTIVE;
  3144. DoCallBack(hDlg,
  3145. pTVWnd,
  3146. pTVWnd->ComPropSheetUI.pOptItem,
  3147. (LPVOID)-1,
  3148. NULL,
  3149. NULL,
  3150. 0,
  3151. CPSUICB_REASON_KILLACTIVE);
  3152. pTVWnd->Flags &= ~TWF_IN_TVPAGE;
  3153. }
  3154. break;
  3155. case PSN_APPLY:
  3156. if ((pTVWnd->Flags & TWF_CAN_UPDATE) &&
  3157. (pTVWnd->ActiveDlgPage == pCurMyDP->PageIdx)) {
  3158. CPSUIDBG(DBG_TVPROC,
  3159. ("\nTreeViewPage: Do PSN_APPLY(%ld), Page: Cur=%u, Active=%u, Flags=%04lx, CALLBACK",
  3160. (pTVWnd->Flags & TWF_APPLY_NO_NEWDEF) ? 1 : 0,
  3161. (UINT)pCurMyDP->PageIdx, (UINT)pTVWnd->ActiveDlgPage,
  3162. pTVWnd->Flags));
  3163. if (DoCallBack(hDlg,
  3164. pTVWnd,
  3165. (pTVWnd->Flags & TWF_APPLY_NO_NEWDEF) ?
  3166. NULL : pTVWnd->ComPropSheetUI.pOptItem,
  3167. (LPVOID)-1,
  3168. NULL,
  3169. NULL,
  3170. 0,
  3171. CPSUICB_REASON_APPLYNOW) ==
  3172. CPSUICB_ACTION_NO_APPLY_EXIT) {
  3173. // send a PSN_SETACTIVE message to treeview page so that we will set the
  3174. // flags like TWF_IN_TVPAGE
  3175. HWND hParent;
  3176. if (hParent = GetParent(pTVWnd->hDlgTV)) {
  3177. PropSheet_SetCurSelByID(hParent, pCurMyDP->DlgPage.DlgTemplateID);
  3178. }
  3179. dw = PSNRET_INVALID_NOCHANGEPAGE;
  3180. }
  3181. } else {
  3182. CPSUIDBG(DBG_TVPROC,
  3183. ("\nTreeViewPage: Ignore PSN_APPLY, Page: Cur=%u, Active=%u, Flags=%04lx, DO NOTHING",
  3184. (UINT)pCurMyDP->PageIdx, (UINT)pTVWnd->ActiveDlgPage,
  3185. pTVWnd->Flags));
  3186. }
  3187. break;
  3188. case PSN_RESET:
  3189. CPSUIDBG(DBG_TVPROC, ("\nTreeView: Got PSN_RESET (Cancel)\n"));
  3190. break;
  3191. case PSN_HELP:
  3192. CPSUIDBG(DBG_TVPROC, ("\nTreeView: Got PSN_HELP (Help)\n"));
  3193. CommonPropSheetUIHelp(hDlg,
  3194. pTVWnd,
  3195. hWndTV,
  3196. 0,
  3197. NULL,
  3198. HELP_CONTENTS);
  3199. break;
  3200. default:
  3201. CPSUIDBG(DBG_TVPROC,
  3202. ("*TVProc: Unknow WM_NOTIFY=%08lx, id=%ld, hWnd=%08lx",
  3203. (DWORD)pNMTV->hdr.code, pNMTV->hdr.idFrom, pNMTV->hdr.hwndFrom));
  3204. break;
  3205. }
  3206. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, (LPARAM)dw);
  3207. return(TRUE);
  3208. break;
  3209. case WM_DESTROY:
  3210. CPSUIINT(("TreeViewProc: Get WM_DESTROY Message"));
  3211. SetWindowLongPtr(hWndTV, GWLP_WNDPROC, (LPARAM)pTVWnd->TVWndProc);
  3212. CommonPropSheetUIHelpSetup(hDlg, pTVWnd);
  3213. DeleteTVFonts(pTVWnd);
  3214. if (pTVWnd->hDCTVWnd) {
  3215. ReleaseDC(hWndTV, pTVWnd->hDCTVWnd);
  3216. pTVWnd->hDCTVWnd = NULL;
  3217. }
  3218. if (hIcon = (HICON)SendDlgItemMessage(hDlg,
  3219. IDD_TV_ICON,
  3220. STM_SETIMAGE,
  3221. (WPARAM)IMAGE_ICON,
  3222. (LPARAM)NULL)) {
  3223. DestroyIcon(hIcon);
  3224. }
  3225. if (hIcon = (HICON)SendDlgItemMessage(hDlg,
  3226. IDD_TV_ECB_ICON,
  3227. STM_SETIMAGE,
  3228. (WPARAM)IMAGE_ICON,
  3229. (LPARAM)NULL)) {
  3230. DestroyIcon(hIcon);
  3231. }
  3232. #if 0
  3233. if (hIcon = (HICON)SendDlgItemMessage(hDlg,
  3234. IDD_TV_HDR_PUSH_ICON,
  3235. STM_SETIMAGE,
  3236. (WPARAM)IMAGE_ICON,
  3237. (LPARAM)NULL)) {
  3238. DestroyIcon(hIcon);
  3239. }
  3240. #endif
  3241. SendMessage(hWndTV,
  3242. TVM_SETIMAGELIST,
  3243. (WPARAM)TVSIL_NORMAL,
  3244. (LPARAM)NULL);
  3245. DEL_PMYDLGPAGE(hDlg);
  3246. pTVWnd->hWndTV = NULL;
  3247. pTVWnd->Flags &= ~TWF_IN_TVPAGE;
  3248. break;
  3249. }
  3250. }
  3251. return(FALSE);
  3252. #undef pPSPInfo
  3253. }