Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

897 lines
24 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. tvctrl.c
  5. Abstract:
  6. This module contains all procedures to paint the treeview window
  7. Author:
  8. 17-Oct-1995 Tue 16:06:50 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 DbgTVCtrl
  17. #define DBG_WM_PAINT 0x00000001
  18. #define DBG_DRAWITEM_RECT 0x00000002
  19. #define DBG_DRAWITEM_COLOR 0x00000004
  20. #define DBG_SYS_COLOR 0x00000008
  21. #define DBG_ORIGIN 0x00000010
  22. #define DBG_COMMAND 0x00000020
  23. #define DBG_EDIT_PROC 0x00000040
  24. #define DBG_SCROLL 0x00000080
  25. #define DBG_CYICON 0x00000100
  26. #define DBG_WM_SETFONT 0x00000200
  27. #define DBG_KEYS 0x00000400
  28. #define DBG_CTRLCOLOR 0x00000800
  29. DEFINE_DBGVAR(0);
  30. extern HINSTANCE hInstDLL;
  31. typedef struct _MYBMPINFO {
  32. BITMAPINFOHEADER bh;
  33. RGBQUAD clr[2];
  34. } MYBMPINFO;
  35. #define CY_LINES 9
  36. static const BYTE HLineBits[CY_LINES * 4] = {
  37. 0x00, 0x00, 0x00, 0x00,
  38. 0x00, 0x00, 0x00, 0x00,
  39. 0x00, 0x00, 0x00, 0x00,
  40. 0x00, 0x00, 0x00, 0x00,
  41. 0x00, 0x00, 0x00, 0x00,
  42. 0x00, 0x00, 0x00, 0x00,
  43. 0x00, 0x00, 0x00, 0x00,
  44. 0x00, 0x00, 0x00, 0x00,
  45. 0x55, 0x55, 0x55, 0x55
  46. };
  47. static const BYTE TLineBits[CY_LINES * 4] = {
  48. 0x00, 0x80, 0x00, 0x00,
  49. 0x00, 0x00, 0x00, 0x00,
  50. 0x00, 0x80, 0x00, 0x00,
  51. 0x00, 0x00, 0x00, 0x00,
  52. 0x00, 0x80, 0x00, 0x00,
  53. 0x00, 0x00, 0x00, 0x00,
  54. 0x00, 0x80, 0x00, 0x00,
  55. 0x00, 0x00, 0x00, 0x00,
  56. 0x55, 0x55, 0x55, 0x55
  57. };
  58. static const BITMAPINFOHEADER bhLines = {
  59. sizeof(BITMAPINFOHEADER),
  60. CXIMAGE,
  61. CY_LINES,
  62. 1,
  63. 1,
  64. BI_RGB,
  65. ALIGN_DW(CXIMAGE, 24) * CY_LINES,
  66. 0,
  67. 0,
  68. 2,
  69. 2
  70. };
  71. VOID
  72. DeleteTVFonts(
  73. PTVWND pTVWnd
  74. )
  75. /*++
  76. Routine Description:
  77. Arguments:
  78. Return Value:
  79. Author:
  80. 11-Aug-1998 Tue 14:05:24 created -by- Daniel Chou (danielc)
  81. Revision History:
  82. --*/
  83. {
  84. HDC hDC;
  85. HFONT hFont;
  86. if ((hDC = pTVWnd->hDCTVWnd) &&
  87. (hFont = pTVWnd->hTVFont[0])) {
  88. SelectObject(hDC, (HANDLE)hFont);
  89. if (hFont = pTVWnd->hTVFont[1]) {
  90. DeleteObject(hFont);
  91. pTVWnd->hTVFont[1] = NULL;
  92. }
  93. if (hFont = pTVWnd->hTVFont[2]) {
  94. DeleteObject(hFont);
  95. pTVWnd->hTVFont[2] = NULL;
  96. }
  97. if (hFont = pTVWnd->hTVFont[3]) {
  98. DeleteObject(hFont);
  99. pTVWnd->hTVFont[3] = NULL;
  100. }
  101. }
  102. }
  103. BOOL
  104. CreateTVFonts(
  105. PTVWND pTVWnd,
  106. HFONT hFont
  107. )
  108. /*++
  109. Routine Description:
  110. Arguments:
  111. Return Value:
  112. Author:
  113. 11-Aug-1998 Tue 14:04:04 created -by- Daniel Chou (danielc)
  114. Revision History:
  115. --*/
  116. {
  117. HWND hWndTV;
  118. HDC hDC;
  119. if ((hWndTV = pTVWnd->hWndTV) &&
  120. (hDC = pTVWnd->hDCTVWnd) &&
  121. (hFont)) {
  122. RECT rc;
  123. SIZEL szlText;
  124. WCHAR Buf[16];
  125. LOGFONT lf;
  126. TEXTMETRIC tm;
  127. DeleteTVFonts(pTVWnd);
  128. //
  129. // hTVFont[0] = Regular current treeview font
  130. //
  131. pTVWnd->hTVFont[0] = hFont;
  132. GetObject(hFont, sizeof(lf), &lf);
  133. //
  134. // hTVFont[1] = BOLD Font
  135. //
  136. lf.lfWeight = FW_BOLD;
  137. if (!(pTVWnd->hTVFont[1] = CreateFontIndirect(&lf))) {
  138. CPSUIERR(("CreateFontIndirect(hTVFont[1] BOLD) failed"));
  139. pTVWnd->hTVFont[1] = hFont;
  140. }
  141. //
  142. // hTVFont[2] = Underline font
  143. //
  144. GetObject(hFont, sizeof(lf), &lf);
  145. lf.lfUnderline = 1;
  146. if (!(pTVWnd->hTVFont[2] = CreateFontIndirect(&lf))) {
  147. CPSUIERR(("CreateFontIndirect(hTVFont[2] UnderLine) failed"));
  148. pTVWnd->hTVFont[2] = hFont;
  149. }
  150. //
  151. // hTVFont[3] = Bold + Underline font
  152. //
  153. lf.lfWeight = FW_BOLD;
  154. if (!(pTVWnd->hTVFont[3] = CreateFontIndirect(&lf))) {
  155. CPSUIERR(("CreateFontIndirect(hTVFont[3]) failed"));
  156. pTVWnd->hTVFont[3] = hFont;
  157. }
  158. SelectObject(hDC, (HANDLE)pTVWnd->hTVFont[0]);
  159. Buf[0] = L' ';
  160. GetTextExtentPoint(hDC, Buf, 1, &szlText);
  161. pTVWnd->cxSpace = (WORD)szlText.cx;
  162. pTVWnd->cxSelAdd = (WORD)((szlText.cx + 1) / 2);
  163. StringCchPrintfW(Buf, COUNT_ARRAY(Buf), L"-88888 ");
  164. szlText.cy = (LONG)lstrlenW(Buf);
  165. GetTextExtentPoint(hDC, Buf, szlText.cy, &szlText);
  166. pTVWnd->cxMaxUDEdit = (WORD)szlText.cx;
  167. GetTextMetrics(hDC, &tm);
  168. pTVWnd->cxAveChar = (WORD)tm.tmAveCharWidth;
  169. GetClientRect(hWndTV, &rc);
  170. pTVWnd->cxExtAdd = (WORD)(tm.tmAveCharWidth + pTVWnd->cxSelAdd);
  171. CPSUIDBG(DBG_WM_SETFONT, ("CreateTVFonts: 0=%p, 1=%p, 2=%p, 3=%p, Ave=%ld, Space=%ld",
  172. pTVWnd->hTVFont[0], pTVWnd->hTVFont[1],
  173. pTVWnd->hTVFont[2], pTVWnd->hTVFont[3],
  174. pTVWnd->cxAveChar, pTVWnd->cxSpace));
  175. return(TRUE);
  176. } else {
  177. return(FALSE);
  178. }
  179. }
  180. UINT
  181. DrawTVItems(
  182. HDC hDC,
  183. HWND hWndTV,
  184. PTVWND pTVWnd,
  185. PRECT prcUpdate
  186. )
  187. /*++
  188. Routine Description:
  189. Arguments:
  190. Return Value:
  191. Author:
  192. 17-Oct-1995 Tue 14:54:47 created -by- Daniel Chou (danielc)
  193. Revision History:
  194. --*/
  195. {
  196. HFONT hTVFont;
  197. HFONT hBoldFont;
  198. HFONT hStdFont;
  199. HFONT hChgFont;
  200. HFONT hOldFont;
  201. HTREEITEM hCurItem;
  202. DWORD OldTextClr;
  203. DWORD OldBkClr;
  204. DWORD ClrFill;
  205. RECT rcUpdate;
  206. RECT rc;
  207. TV_ITEM tvi;
  208. POINTL ptlOff;
  209. MYBMPINFO bi;
  210. LONG yIconOff = -1;
  211. UINT cUpdate = 0;
  212. UINT cxIndent;
  213. UINT OldTAMode;
  214. UINT OldBkMode;
  215. INT yLinesOff;
  216. DWORD HLState;
  217. BOOL HasFocus;
  218. WCHAR Buf[MAX_RES_STR_CHARS * 2 + 10];
  219. rcUpdate = *prcUpdate;
  220. hTVFont = pTVWnd->hTVFont[0];
  221. hBoldFont = pTVWnd->hTVFont[1];
  222. hStdFont = pTVWnd->hTVFont[2];
  223. hChgFont = pTVWnd->hTVFont[3];
  224. hOldFont = SelectObject(hDC, hTVFont);
  225. cxIndent = TreeView_GetIndent(hWndTV);
  226. HasFocus = (BOOL)(GetFocus() == hWndTV);
  227. hCurItem = (pTVWnd->pCurTVItem) ? _OI_HITEM(pTVWnd->pCurTVItem) : NULL;
  228. OldTextClr = SetTextColor(hDC, RGB(0x00, 0x00, 0x00));
  229. OldBkClr = SetBkColor(hDC, RGB(0xFF, 0xFF, 0xFF));
  230. OldBkMode = (UINT)SetBkMode(hDC, TRANSPARENT);
  231. OldTAMode = (UINT)SetTextAlign(hDC, TA_UPDATECP);
  232. tvi.mask = TVIF_CHILDREN |
  233. TVIF_HANDLE |
  234. TVIF_STATE |
  235. TVIF_PARAM |
  236. TVIF_IMAGE |
  237. TVIF_SELECTEDIMAGE |
  238. TVIF_TEXT;
  239. tvi.hItem = TreeView_GetFirstVisible(hWndTV);
  240. HLState = (DWORD)((TreeView_GetDropHilight(hWndTV)) ? TVIS_DROPHILITED :
  241. TVIS_SELECTED);
  242. bi.bh = bhLines;
  243. ClrFill = GetSysColor(COLOR_WINDOW);
  244. bi.clr[0].rgbRed = GetRValue(ClrFill);
  245. bi.clr[0].rgbGreen = GetGValue(ClrFill);
  246. bi.clr[0].rgbBlue = GetBValue(ClrFill);
  247. ClrFill = GetSysColor(COLOR_3DSHADOW);
  248. bi.clr[1].rgbRed = GetRValue(ClrFill);
  249. bi.clr[1].rgbGreen = GetGValue(ClrFill);
  250. bi.clr[1].rgbBlue = GetBValue(ClrFill);
  251. while (tvi.hItem) {
  252. tvi.pszText = Buf;
  253. tvi.cchTextMax = sizeof(Buf);
  254. if ((TreeView_GetItemRect(hWndTV, tvi.hItem, &rc, TRUE)) &&
  255. (rc.left < rcUpdate.right) &&
  256. (rc.right > rcUpdate.left) &&
  257. (rc.top < rcUpdate.bottom) &&
  258. (rc.bottom > rcUpdate.top) &&
  259. (TreeView_GetItem(hWndTV, &tvi))) {
  260. TVLP tvlp;
  261. UINT cBuf;
  262. UINT cName;
  263. RECT rcFill;
  264. DWORD ClrBk;
  265. DWORD ClrName;
  266. SIZEL szlText;
  267. INT xIcon;
  268. INT yIcon;
  269. rcFill = rc;
  270. rcFill.left = rc.right;
  271. //
  272. // Draw the Text
  273. //
  274. tvlp = GET_TVLP(tvi.lParam);
  275. cBuf = (UINT)lstrlen(Buf);
  276. cName = (UINT)tvlp.cName;
  277. SelectObject(hDC, (tvi.state & TVIS_BOLD) ? hBoldFont : hTVFont);
  278. GetTextExtentPoint(hDC, Buf, cBuf, &szlText);
  279. if (yIconOff == -1) {
  280. yIconOff = rc.bottom - rc.top;
  281. //
  282. // Currently the common control group is drawing the text left aligned, starting at
  283. // rc.left + GetSystemMetrics(SM_CXEDGE). So we are following the methods
  284. // in common control to draw the text. Though "guessing" their implementation is
  285. // not the best way to do, it's the only solution we can take. Otherwise, we need
  286. // to implement all the drawing work for the treeview text, which could be even
  287. // worse.
  288. //
  289. ptlOff.x = GetSystemMetrics(SM_CXEDGE);
  290. ptlOff.y = (yIconOff - szlText.cy) / 2;
  291. yIconOff = (yIconOff - (LONG)pTVWnd->cyImage) / 2;
  292. yLinesOff = (INT)((pTVWnd->cyImage / 2) + pTVWnd->yLinesOff);
  293. CPSUIDBG(DBG_CYICON, ("cy=%ld, cyImage=%ld, yIconOff=%ld, yLinesOff=%ld, Indent=%ld",
  294. rc.bottom - rc.top, pTVWnd->cyImage, yIconOff,
  295. yLinesOff, cxIndent));
  296. }
  297. xIcon = (INT)(rc.left - cxIndent);
  298. yIcon = (INT)(rc.top + yIconOff);
  299. rc.left += ptlOff.x;
  300. rc.top += ptlOff.y;
  301. CPSUIDBG(DBG_DRAWITEM_RECT,
  302. ("tvlp=[%04lx] (%ld, %ld)-(%ld, %ld)=%ldx%ld (%ld/%ld) <%ws>",
  303. tvlp.Flags, rc.left, rc.top, rc.right, rc.bottom,
  304. rc.right - rc.left, rc.bottom - rc.top,
  305. cName, cBuf, Buf));
  306. if (tvi.state & HLState) {
  307. //
  308. // Current item is selected
  309. //
  310. if (HasFocus) {
  311. ClrBk = COLOR_HIGHLIGHT;
  312. ClrName = (tvlp.Flags & TVLPF_DISABLED) ?
  313. COLOR_3DFACE : COLOR_HIGHLIGHTTEXT;
  314. } else {
  315. //
  316. // The COLOR_3DFACE is a text background
  317. //
  318. ClrBk = COLOR_3DFACE;
  319. ClrName = (tvlp.Flags & TVLPF_DISABLED) ? COLOR_3DSHADOW :
  320. COLOR_BTNTEXT;
  321. }
  322. } else {
  323. //
  324. // The item is not currently selected
  325. //
  326. ClrBk = COLOR_WINDOW;
  327. ClrName = (tvlp.Flags & TVLPF_DISABLED) ? COLOR_3DSHADOW :
  328. COLOR_WINDOWTEXT;
  329. }
  330. ClrFill = ClrBk + 1;
  331. ClrBk = GetSysColor((UINT)ClrBk);
  332. ClrName = GetSysColor((UINT)ClrName);
  333. CPSUIDBG(DBG_SYS_COLOR,
  334. ("ClrBk=(%3d,%3d,%3d), ClrName=(%3d,%3d,%3d), State=%08lx/%08lx, Focus=%ld, %ws",
  335. GetRValue(ClrBk), GetGValue(ClrBk), GetBValue(ClrBk),
  336. GetRValue(ClrName), GetGValue(ClrName), GetBValue(ClrName),
  337. tvi.state, HLState, (HasFocus) ? 1 : 0, Buf));
  338. CPSUIDBG(DBG_DRAWITEM_COLOR,
  339. ("COLOR: Item=(%3d,%3d,%3d)",
  340. GetRValue(ClrName), GetGValue(ClrName), GetBValue(ClrName)));
  341. if (cBuf > cName) {
  342. GetTextExtentPoint(hDC, Buf, cName, &szlText);
  343. MoveToEx(hDC, rc.left += szlText.cx, rc.top, NULL);
  344. SelectObject(hDC, (tvlp.Flags & TVLPF_CHANGEONCE) ? hChgFont :
  345. hStdFont);
  346. GetTextExtentPoint(hDC, &Buf[cName], cBuf - cName, &szlText);
  347. if ((rcFill.right = rc.left + szlText.cx) > rcFill.left) {
  348. FillRect(hDC, &rcFill, (HBRUSH)LongToHandle(ClrFill));
  349. }
  350. SetTextColor(hDC, ClrName);
  351. SetBkColor(hDC, ClrBk);
  352. SetBkMode(hDC, OPAQUE);
  353. TextOut(hDC, rc.left, rc.top, &Buf[cName], cBuf - cName);
  354. }
  355. #if DO_IN_PLACE
  356. if (tvlp.Flags & TVLPF_EMPTYICON) {
  357. #if DBG
  358. Buf[cName] = L'\0';
  359. CPSUIDBG(DBG_CYICON, ("%40ws Lines='%hs'",
  360. Buf, ((tvi.cChildren) &&
  361. (tvi.state & TVIS_EXPANDED)) ? "T" : "-"));
  362. #endif
  363. SetDIBitsToDevice(hDC,
  364. xIcon,
  365. yIcon + yLinesOff,
  366. CXIMAGE,
  367. CY_LINES,
  368. 0,
  369. 0,
  370. 0,
  371. CY_LINES,
  372. ((tvi.cChildren) &&
  373. (tvi.state & TVIS_EXPANDED)) ? TLineBits :
  374. HLineBits,
  375. (BITMAPINFO *)&bi,
  376. DIB_RGB_COLORS);
  377. }
  378. #endif
  379. if (tvlp.Flags & TVLPF_ECBICON) {
  380. POPTITEM pItem;
  381. PEXTCHKBOX pECB;
  382. pItem = GetOptions(pTVWnd, tvi.lParam);
  383. pECB = pItem->pExtChkBox;
  384. ImageList_Draw(pTVWnd->himi,
  385. GetIcon16Idx(pTVWnd,
  386. _OI_HINST(pItem),
  387. GET_ICONID(pECB,
  388. ECBF_ICONID_AS_HICON),
  389. IDI_CPSUI_EMPTY),
  390. hDC,
  391. xIcon,
  392. yIcon,
  393. ILD_TRANSPARENT);
  394. }
  395. if (tvlp.Flags & TVLPF_STOP) {
  396. ImageList_Draw(pTVWnd->himi,
  397. GetIcon16Idx(pTVWnd, NULL, 0, IDI_CPSUI_STOP),
  398. hDC,
  399. xIcon,
  400. yIcon,
  401. ILD_TRANSPARENT);
  402. }
  403. if (tvlp.Flags & TVLPF_NO) {
  404. ImageList_Draw(pTVWnd->himi,
  405. GetIcon16Idx(pTVWnd, NULL, 0, IDI_CPSUI_NO),
  406. hDC,
  407. xIcon,
  408. yIcon,
  409. ILD_TRANSPARENT);
  410. }
  411. if (tvlp.Flags & TVLPF_WARNING) {
  412. ImageList_Draw(pTVWnd->himi,
  413. GetIcon16Idx(pTVWnd,
  414. NULL,
  415. 0,
  416. IDI_CPSUI_WARNING_OVERLAY),
  417. hDC,
  418. xIcon + X_WARNOVLY_ADD,
  419. yIcon + Y_WARNOVLY_ADD,
  420. ILD_TRANSPARENT);
  421. }
  422. ++cUpdate;
  423. }
  424. tvi.hItem = TreeView_GetNextVisible(hWndTV, tvi.hItem);
  425. }
  426. SelectObject(hDC, hOldFont);
  427. SetTextColor(hDC, OldTextClr);
  428. SetBkColor(hDC, OldBkClr);
  429. SetBkMode(hDC, OldBkMode);
  430. SetTextAlign(hDC, OldTAMode);
  431. return(cUpdate);
  432. }
  433. LRESULT
  434. CALLBACK
  435. MyTVWndProc(
  436. HWND hWnd,
  437. UINT Msg,
  438. WPARAM wParam,
  439. LPARAM lParam
  440. )
  441. /*++
  442. Routine Description:
  443. Arguments:
  444. Return Value:
  445. Author:
  446. 17-Oct-1995 Tue 12:36:19 created -by- Daniel Chou (danielc)
  447. Revision History:
  448. --*/
  449. {
  450. HWND hDlg;
  451. HWND *phWndEdit;
  452. HWND hWndEdit;
  453. UINT chWndEdit;
  454. HDWP hDWP;
  455. PTVWND pTVWnd;
  456. WNDPROC TVWndProc;
  457. DWORD ClrBk;
  458. DWORD ClrText;
  459. if ((hDlg = GetParent(hWnd)) &&
  460. (pTVWnd = GET_PTVWND(hDlg)) &&
  461. (TVWndProc = pTVWnd->TVWndProc)) {
  462. HDC hDC;
  463. LRESULT lResult;
  464. RECT rcUpdate;
  465. switch (Msg) {
  466. #if DO_IN_PLACE
  467. case WM_VSCROLL:
  468. case WM_HSCROLL:
  469. CPSUIDBG(DBG_SCROLL, ("MyTVWndProc: WM_%cSCROLL, hScroll=%08lx (%08lx:%08lx:%08lx)=%ld, Pos=%ld, Code=%ld",
  470. (Msg == WM_VSCROLL) ? 'V' : 'H',
  471. lParam, pTVWnd->hWndEdit[0],
  472. pTVWnd->hWndEdit[1], pTVWnd->hWndEdit[2],
  473. pTVWnd->chWndEdit, HIWORD(wParam), LOWORD(wParam)));
  474. chWndEdit = pTVWnd->chWndEdit;
  475. phWndEdit = pTVWnd->hWndEdit;
  476. if (lParam) {
  477. while (chWndEdit--) {
  478. if ((HWND)lParam == *phWndEdit++) {
  479. PostMessage(hDlg, WM_COMMAND, wParam, lParam);
  480. break;
  481. }
  482. }
  483. return(FALSE);
  484. }
  485. break;
  486. #endif
  487. case WM_COMMAND:
  488. CPSUIDBG(DBG_COMMAND, ("MyTVWndProc: WM_COMMAND"));
  489. PostMessage(hDlg, WM_COMMAND, wParam, lParam);
  490. return(FALSE);
  491. break;
  492. case WM_CTLCOLORBTN:
  493. case WM_CTLCOLORSTATIC:
  494. switch (GetWindowLongPtr((HWND)lParam, GWLP_ID)) {
  495. case IDD_TV_CHKBOX:
  496. case IDD_TV_EXTCHKBOX:
  497. if (GetFocus() == (HWND)lParam) {
  498. CPSUIDBG(DBG_CTRLCOLOR, ("Get WM_CTLCOLOR, HAS FOCUS"));
  499. ClrText = (DWORD)COLOR_HIGHLIGHTTEXT;
  500. ClrBk = (DWORD)COLOR_HIGHLIGHT;
  501. } else {
  502. CPSUIDBG(DBG_CTRLCOLOR, ("Get WM_CTLCOLOR, NO FOCUS"));
  503. ClrText = COLOR_WINDOWTEXT;
  504. ClrBk = COLOR_WINDOW;
  505. }
  506. SetTextColor((HDC)wParam, GetSysColor(ClrText));
  507. SetBkMode((HDC)wParam, TRANSPARENT);
  508. return((LRESULT)GetSysColorBrush(ClrBk));
  509. break;
  510. }
  511. break;
  512. case WM_HELP:
  513. case WM_CONTEXTMENU:
  514. PostMessage(hDlg, Msg, wParam, lParam);
  515. break;
  516. case WM_SETFONT:
  517. CPSUIDBG(DBG_WM_SETFONT, ("MyTVWndProc: WM_SETFONT, IGNORE"));
  518. return(TRUE);
  519. break;
  520. case WM_KEYDOWN:
  521. switch (wParam) {
  522. case VK_RIGHT:
  523. if ((pTVWnd->chWndEdit) &&
  524. (pTVWnd->hWndEdit[0])) {
  525. SetFocus(pTVWnd->hWndEdit[0]);
  526. return(0);
  527. }
  528. }
  529. case WM_KEYUP:
  530. CPSUIDBG(DBG_KEYS, ("MyTVWndProc: WM_KEY%hs: VK=%ld",
  531. (Msg == WM_KEYUP) ? "UP" : "DOWN", wParam));
  532. break;
  533. case WM_PAINT:
  534. #if DO_IN_PLACE
  535. if ((pTVWnd->pCurTVItem) &&
  536. (chWndEdit = (UINT)pTVWnd->chWndEdit) &&
  537. (TreeView_GetItemRect(hWnd,
  538. _OI_HITEM(pTVWnd->pCurTVItem),
  539. &rcUpdate,
  540. TRUE)) &&
  541. ((rcUpdate.left != pTVWnd->ptCur.x) ||
  542. (rcUpdate.top != pTVWnd->ptCur.y)) &&
  543. (hDWP = BeginDeferWindowPos(chWndEdit))) {
  544. POINTL pt;
  545. phWndEdit = pTVWnd->hWndEdit;
  546. CPSUIDBG(DBG_ORIGIN, ("CurTVItem=Moved (%08lx:%08lx:%08lx)From (%4ld, %4ld) ---> (%4ld, %4ld)",
  547. pTVWnd->hWndEdit[0],
  548. pTVWnd->hWndEdit[1], pTVWnd->hWndEdit[2],
  549. pTVWnd->ptCur.x, pTVWnd->ptCur.y,
  550. rcUpdate.left, rcUpdate.top));
  551. pt.x = rcUpdate.left - pTVWnd->ptCur.x;
  552. pt.y = rcUpdate.top - pTVWnd->ptCur.y;
  553. pTVWnd->ptCur.x = rcUpdate.left;
  554. pTVWnd->ptCur.y = rcUpdate.top;
  555. while ((chWndEdit--) && (hDWP)) {
  556. if (hWndEdit = *phWndEdit++) {
  557. GetWindowRect(hWndEdit, &rcUpdate);
  558. rcUpdate.left += pt.x;
  559. rcUpdate.top += pt.y;
  560. rcUpdate.right += pt.x;
  561. rcUpdate.bottom += pt.y;
  562. MapWindowPoints(NULL, hWnd, (LPPOINT)&rcUpdate, 2);
  563. hDWP = DeferWindowPos(hDWP, hWndEdit, NULL,
  564. rcUpdate.left, rcUpdate.top, 0, 0,
  565. SWP_DRAWFRAME |
  566. SWP_FRAMECHANGED |
  567. SWP_NOSIZE |
  568. SWP_NOZORDER);
  569. }
  570. }
  571. if (hDWP) {
  572. EndDeferWindowPos(hDWP);
  573. }
  574. }
  575. #endif
  576. GetUpdateRect(hWnd, &rcUpdate, FALSE);
  577. lResult = CallWindowProc(TVWndProc, hWnd, Msg, wParam, lParam);
  578. CPSUIDBG(DBG_WM_PAINT,
  579. ("\n!! Update Rect = (%ld, %ld)-(%ld, %ld) = %ld x %ld\n\n",
  580. rcUpdate.left, rcUpdate.top,
  581. rcUpdate.right, rcUpdate.bottom,
  582. rcUpdate.right - rcUpdate.left,
  583. rcUpdate.bottom - rcUpdate.top));
  584. if (hDC = GetDC(hWnd)) {
  585. IntersectClipRect(hDC,
  586. rcUpdate.left,
  587. rcUpdate.top,
  588. rcUpdate.right,
  589. rcUpdate.bottom);
  590. DrawTVItems(hDC, hWnd, pTVWnd, &rcUpdate);
  591. ReleaseDC(hWnd, hDC);
  592. } else {
  593. CPSUIERR(("MyTVWndProc: GetDC(%08lx) FAILED", hWnd));
  594. }
  595. return(lResult);
  596. default:
  597. break;
  598. }
  599. return(CallWindowProc(TVWndProc, hWnd, Msg, wParam, lParam));
  600. } else {
  601. CPSUIERR(("MyTVWndProc: hDlg=%08lx, pTVWnd=%08lx, TVWndProc=%08lx",
  602. hDlg, pTVWnd, TVWndProc));
  603. return(TRUE);
  604. }
  605. }