QListCtrl.cpp 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. // QListCtrl.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CP_Main.h"
  5. #include "QListCtrl.h"
  6. #include "ProcessPaste.h"
  7. #include "BitmapHelper.h"
  8. #include "MainTableFunctions.h"
  9. #include "DittoCopyBuffer.h"
  10. #include <atlbase.h>
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. #define ROW_BOTTOM_BORDER 2
  17. #define ROW_LEFT_BORDER 3
  18. #define COLOR_SHADOW RGB(245, 245, 245)
  19. #define DUMMY_COL_WIDTH 1
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CQListCtrl
  22. CQListCtrl::CQListCtrl()
  23. {
  24. m_pchTip = NULL;
  25. m_pwchTip = NULL;
  26. LOGFONT lf;
  27. lf.lfHeight = -9;
  28. lf.lfWidth = 0;
  29. lf.lfEscapement = 0;
  30. lf.lfOrientation = 0;
  31. lf.lfWeight = FW_LIGHT;
  32. lf.lfItalic = FALSE;
  33. lf.lfUnderline = FALSE;
  34. lf.lfStrikeOut = FALSE;
  35. lf.lfCharSet = ANSI_CHARSET;
  36. lf.lfOutPrecision = OUT_STRING_PRECIS;
  37. lf.lfClipPrecision = CLIP_STROKE_PRECIS;
  38. lf.lfQuality = DEFAULT_QUALITY;
  39. lf.lfPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE;
  40. lstrcpy(lf.lfFaceName, _T("Small Font"));
  41. m_SmallFont = ::CreateFontIndirect(&lf);
  42. m_bShowTextForFirstTenHotKeys = true;
  43. m_bStartTop = true;
  44. m_pToolTip = NULL;
  45. m_pFormatter = NULL;
  46. }
  47. CQListCtrl::~CQListCtrl()
  48. {
  49. if(m_pchTip != NULL)
  50. delete m_pchTip;
  51. if(m_pwchTip != NULL)
  52. delete m_pwchTip;
  53. if( m_SmallFont )
  54. ::DeleteObject( m_SmallFont );
  55. m_Font.DeleteObject();
  56. if(m_pFormatter)
  57. {
  58. delete m_pFormatter;
  59. m_pFormatter = NULL;
  60. }
  61. }
  62. // returns the position 1-10 if the index is in the FirstTen block else -1
  63. int CQListCtrl::GetFirstTenNum( int index )
  64. {
  65. // set firstTenNum to the first ten number (1-10) corresponding to the given index
  66. int firstTenNum = -1; // -1 means that nItem is not in the FirstTen block.
  67. int count = GetItemCount();
  68. if( m_bStartTop )
  69. {
  70. if( 0 <= index && index <= 9 )
  71. firstTenNum = index + 1;
  72. }
  73. else // we are starting at the bottom and going up
  74. {
  75. int idxStartFirstTen = count-10; // start of the FirstTen block
  76. // if index is within the FirstTen block
  77. if( idxStartFirstTen <= index && index < count )
  78. firstTenNum = count - index;
  79. }
  80. return firstTenNum;
  81. }
  82. // returns the list index corresponding to the given FirstTen position number.
  83. // (ret < 0) means that "num" is not in the FirstTen block
  84. int CQListCtrl::GetFirstTenIndex( int num )
  85. {
  86. if( num <= 0 || num > 10 )
  87. return -1;
  88. if( m_bStartTop )
  89. return num-1;
  90. // else we are starting at the bottom and going up
  91. int count = GetItemCount();
  92. return count - num;
  93. }
  94. BEGIN_MESSAGE_MAP(CQListCtrl, CListCtrl)
  95. //{{AFX_MSG_MAP(CQListCtrl)
  96. ON_NOTIFY_REFLECT(LVN_KEYDOWN, OnKeydown)
  97. ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
  98. ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomdrawList)
  99. ON_WM_SYSKEYDOWN()
  100. ON_WM_ERASEBKGND()
  101. ON_WM_CREATE()
  102. ON_WM_HSCROLL()
  103. ON_WM_TIMER()
  104. ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnSelectionChange)
  105. ON_WM_VSCROLL()
  106. ON_WM_WINDOWPOSCHANGED()
  107. ON_WM_MOUSEWHEEL()
  108. //}}AFX_MSG_MAP
  109. ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
  110. ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
  111. ON_WM_KILLFOCUS()
  112. END_MESSAGE_MAP()
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CQListCtrl message handlers
  115. void CQListCtrl::OnKeydown(NMHDR* pNMHDR, LRESULT* pResult)
  116. {
  117. LV_KEYDOWN* pLVKeyDown = (LV_KEYDOWN*)pNMHDR;
  118. switch (pLVKeyDown->wVKey)
  119. {
  120. case VK_RETURN:
  121. {
  122. ARRAY arr;
  123. GetSelectionIndexes(arr);
  124. SendSelection(arr);
  125. }
  126. break;
  127. case VK_ESCAPE:
  128. GetParent()->SendMessage(NM_END, 0, 0);
  129. break;
  130. case VK_RIGHT:
  131. {
  132. int nItem = GetNextItem(-1, LVNI_SELECTED);
  133. if (nItem != -1)
  134. GetParent()->SendMessage(NM_RIGHT, nItem, 0);
  135. }
  136. break;
  137. case VK_LEFT:
  138. GetParent()->SendMessage(NM_LEFT, 0, 0);
  139. break;
  140. case VK_DELETE:
  141. GetParent()->SendMessage(NM_DELETE, 0, 0);
  142. break;
  143. }
  144. *pResult = 0;
  145. }
  146. void CQListCtrl::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
  147. {
  148. LPNMITEMACTIVATE lpnmItem = (LPNMITEMACTIVATE) pNMHDR;
  149. UINT Flags;
  150. int nItem = -1;
  151. if ((nItem = HitTest(lpnmItem->ptAction, &Flags)) != -1)
  152. {
  153. if (Flags | LVHT_ONITEM)
  154. SendSelection(nItem);
  155. }
  156. *pResult = 0;
  157. }
  158. void CQListCtrl::SendSelection(int nItem)
  159. {
  160. GetParent()->SendMessage(NM_SELECT, 1, (LPARAM) &nItem);
  161. }
  162. void CQListCtrl::SendSelection(ARRAY &arrItems)
  163. {
  164. GetParent()->SendMessage(NM_SELECT, arrItems.GetSize(), (LPARAM) arrItems.GetData());
  165. }
  166. void CQListCtrl::GetSelectionIndexes(ARRAY &arr)
  167. {
  168. arr.RemoveAll();
  169. POSITION pos = GetFirstSelectedItemPosition();
  170. while (pos)
  171. {
  172. arr.Add(GetNextSelectedItem(pos));
  173. }
  174. }
  175. bool CQListCtrl::PutSelectedItemOnDittoCopyBuffer(long lBuffer)
  176. {
  177. bool bRet = false;
  178. ARRAY arr;
  179. GetSelectionItemData(arr);
  180. int nCount = arr.GetSize();
  181. if(nCount > 0 && arr[0])
  182. {
  183. CDittoCopyBuffer::PutClipOnDittoCopyBuffer(arr[0], lBuffer);
  184. bRet = true;
  185. }
  186. return bRet;
  187. }
  188. void CQListCtrl::GetSelectionItemData(ARRAY &arr)
  189. {
  190. DWORD dwData;
  191. int i;
  192. arr.RemoveAll();
  193. POSITION pos = GetFirstSelectedItemPosition();
  194. while (pos)
  195. {
  196. i = GetNextSelectedItem(pos);
  197. dwData = GetItemData(i);
  198. arr.Add( dwData );
  199. }
  200. }
  201. void CQListCtrl::RemoveAllSelection()
  202. {
  203. POSITION pos = GetFirstSelectedItemPosition();
  204. while (pos)
  205. {
  206. SetSelection(GetNextSelectedItem(pos), FALSE);
  207. }
  208. }
  209. BOOL CQListCtrl::SetSelection(int nRow, BOOL bSelect)
  210. {
  211. if(bSelect)
  212. return SetItemState(nRow, LVIS_SELECTED, LVIS_SELECTED);
  213. else
  214. return SetItemState(nRow, ~LVIS_SELECTED, LVIS_SELECTED);
  215. }
  216. BOOL CQListCtrl::SetText(int nRow, int nCol, CString cs)
  217. {
  218. return SetItemText(nRow, nCol, cs);
  219. }
  220. BOOL CQListCtrl::SetCaret(int nRow, BOOL bFocus)
  221. {
  222. if(bFocus)
  223. return SetItemState(nRow, LVIS_FOCUSED, LVIS_FOCUSED);
  224. else
  225. return SetItemState(nRow, ~LVIS_FOCUSED, LVIS_FOCUSED);
  226. }
  227. long CQListCtrl::GetCaret()
  228. {
  229. return GetNextItem(-1, LVNI_FOCUSED);
  230. }
  231. // moves the caret to the given index, selects it, and ensures it is visible.
  232. BOOL CQListCtrl::SetListPos( int index )
  233. {
  234. if( index < 0 || index >= GetItemCount() )
  235. return FALSE;
  236. RemoveAllSelection();
  237. SetCaret(index);
  238. SetSelection(index);
  239. EnsureVisible(index,FALSE);
  240. //similutate a click on the selected item
  241. //I was having a problem with the previous selection still be there
  242. //when you shift selected it would still have the previous selection as the anchor
  243. CWnd *pFocus = GetFocus();
  244. if(pFocus == NULL || pFocus == this)
  245. {
  246. CRect rect;
  247. if(GetItemRect(index, rect, LVIR_BOUNDS))
  248. {
  249. CPoint pt(rect.TopLeft());
  250. pt.x += 2;
  251. pt.y += 2;
  252. PostMessage(WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pt.x, pt.y));
  253. PostMessage(WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(pt.x, pt.y));
  254. }
  255. }
  256. return TRUE;
  257. }
  258. BOOL CQListCtrl::SetFormattedText(int nRow, int nCol, LPCTSTR lpszFormat,...)
  259. {
  260. CString csText;
  261. va_list vlist;
  262. ASSERT(AfxIsValidString(lpszFormat));
  263. va_start(vlist,lpszFormat);
  264. csText.FormatV(lpszFormat,vlist);
  265. va_end(vlist);
  266. return SetText(nRow,nCol,csText);
  267. }
  268. void CQListCtrl::SetNumberOfLinesPerRow(int nLines)
  269. {
  270. CDC *pDC = GetDC();
  271. CRect crRect(0, 0, 0, 0);
  272. CFont *pOldFont = pDC->SelectObject(GetFont());
  273. //Get the height to draw one character
  274. pDC->DrawText("W", crRect, DT_VCENTER | DT_EXPANDTABS | DT_CALCRECT);
  275. pDC->SelectObject(pOldFont);
  276. //Get the total height of each row
  277. int nHeight = (crRect.Height() * nLines) + ROW_BOTTOM_BORDER;
  278. //Create a image list of that height and set it to the list box
  279. CImageList imglist;
  280. imglist.Create(DUMMY_COL_WIDTH, nHeight, ILC_COLOR16 | ILC_MASK, 1, 1);
  281. SetImageList(&imglist, LVSIL_SMALL );
  282. ReleaseDC(pDC);
  283. }
  284. void CQListCtrl::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
  285. {
  286. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  287. *pResult = 0;
  288. // Request item-specific notifications if this is the
  289. // beginning of the paint cycle.
  290. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  291. {
  292. *pResult = CDRF_NOTIFYITEMDRAW;
  293. }
  294. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  295. {
  296. LVITEM rItem;
  297. int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
  298. CDC* pDC = CDC::FromHandle ( pLVCD->nmcd.hdc );
  299. COLORREF crBkgnd;
  300. BOOL bListHasFocus;
  301. CRect rcItem;
  302. bListHasFocus = ( GetSafeHwnd() == ::GetFocus() );
  303. // Get the image index and selected/focused state of the
  304. // item being drawn.
  305. ZeroMemory ( &rItem, sizeof(LVITEM) );
  306. rItem.mask = LVIF_STATE;
  307. rItem.iItem = nItem;
  308. rItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
  309. GetItem(&rItem);
  310. // Get the rect that bounds the text label.
  311. GetItemRect(nItem, rcItem, LVIR_LABEL);
  312. rcItem.left -= DUMMY_COL_WIDTH;
  313. COLORREF OldColor = -1;
  314. int nOldBKMode = -1;
  315. // Draw the background of the list item. Colors are selected
  316. // according to the item's state.
  317. if(rItem.state & LVIS_SELECTED)
  318. {
  319. if(bListHasFocus)
  320. {
  321. crBkgnd = g_Opt.m_Theme.ListBoxSelectedBG();
  322. OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxSelectedText());
  323. }
  324. else
  325. {
  326. crBkgnd = g_Opt.m_Theme.ListBoxSelectedNoFocusBG();
  327. OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxSelectedNoFocusText());
  328. }
  329. }
  330. else
  331. {
  332. //Shade alternating Rows
  333. if((nItem % 2) == 0)
  334. {
  335. crBkgnd = g_Opt.m_Theme.ListBoxOddRowsBG();
  336. OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxOddRowsText());
  337. }
  338. else
  339. {
  340. crBkgnd = g_Opt.m_Theme.ListBoxEvenRowsBG();
  341. OldColor = pDC->SetTextColor(g_Opt.m_Theme.ListBoxEvenRowsText());
  342. }
  343. }
  344. pDC->FillSolidRect(rcItem, crBkgnd);
  345. nOldBKMode = pDC->SetBkMode(TRANSPARENT);
  346. CRect rcText = rcItem;
  347. rcText.left += ROW_LEFT_BORDER;
  348. rcText.top++;
  349. // Draw the text.
  350. //CString csText = GetItemText(nItem, 0);
  351. CString csText;
  352. LPTSTR lpszText = csText.GetBufferSetLength(g_Opt.m_bDescTextSize);
  353. GetItemText(nItem, 0, lpszText, g_Opt.m_bDescTextSize);
  354. csText.ReleaseBuffer();
  355. // extract symbols
  356. CString strSymbols;
  357. int nSymEnd = csText.Find('|');
  358. if( nSymEnd >= 0 )
  359. {
  360. strSymbols = csText.Left(nSymEnd);
  361. csText = csText.Mid(nSymEnd+1);
  362. }
  363. // set firstTenNum to the first ten number (1-10) corresponding to
  364. // the current nItem.
  365. // -1 means that nItem is not in the FirstTen block.
  366. int firstTenNum = GetFirstTenNum(nItem);
  367. if( m_bShowTextForFirstTenHotKeys && firstTenNum > 0 )
  368. {
  369. rcText.left += 12;
  370. }
  371. // if we are inside a group, don't display the "in group" flag
  372. if( theApp.m_GroupID > 0 )
  373. {
  374. int nFlag = strSymbols.Find(_T("!"));
  375. if( nFlag >= 0 )
  376. strSymbols.Delete(nFlag);
  377. }
  378. DrawBitMap(nItem, rcText, pDC);
  379. // draw the symbol box
  380. if( strSymbols.GetLength() > 0 )
  381. {
  382. strSymbols = " " + strSymbols + " "; // leave space for box
  383. // add spaces to leave room for the symbols
  384. CRect rectSym(rcText.left, rcText.top+1, rcText.left, rcText.top+1);
  385. CRect rectSpace(0,0,0,0);
  386. //Get text bounds
  387. pDC->DrawText(" ", &rectSpace, DT_VCENTER | DT_EXPANDTABS | DT_CALCRECT);
  388. pDC->DrawText(strSymbols, &rectSym, DT_VCENTER | DT_EXPANDTABS | DT_CALCRECT);
  389. VERIFY( rectSpace.Width() > 0 );
  390. // int numSpaces = rectSym.Width() / rectSpace.Width();
  391. // numSpaces++;
  392. // csText = CString(' ',numSpaces) + csText;
  393. // draw the symbols
  394. pDC->FillSolidRect( rectSym, GetSysColor(COLOR_ACTIVECAPTION) );
  395. //pDC->FillSolidRect( rectSym, RGB(0,255,255) );
  396. pDC->Draw3dRect(rectSym, GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_3DDKSHADOW));
  397. // COLORREF crOld = pDC->SetTextColor(GetSysColor(COLOR_INFOTEXT));
  398. COLORREF crOld = pDC->SetTextColor(RGB(255, 255, 255));
  399. pDC->DrawText(strSymbols, rectSym, DT_VCENTER|DT_EXPANDTABS|DT_NOPREFIX);
  400. pDC->SetTextColor(crOld);
  401. rcText.left += rectSym.Width() + 2;
  402. }
  403. if(DrawText(nItem, rcText, pDC) == FALSE)
  404. pDC->DrawText(csText, rcText, DT_VCENTER|DT_EXPANDTABS|DT_NOPREFIX);
  405. // Draw a focus rect around the item if necessary.
  406. if(bListHasFocus && (rItem.state & LVIS_FOCUSED))
  407. pDC->DrawFocusRect(rcItem);
  408. if( m_bShowTextForFirstTenHotKeys && firstTenNum > 0 )
  409. {
  410. CString cs;
  411. if( firstTenNum == 10 )
  412. cs = "0";
  413. else
  414. cs.Format(_T("%d"), firstTenNum);
  415. CRect crClient;
  416. GetWindowRect(crClient);
  417. ScreenToClient(crClient);
  418. CRect crHotKey = rcItem;
  419. crHotKey.right = crHotKey.left + 11;
  420. crHotKey.left += 2;
  421. crHotKey.top += 2;
  422. HFONT hOldFont = (HFONT)pDC->SelectObject(m_SmallFont);
  423. pDC->DrawText(cs, crHotKey, DT_BOTTOM);
  424. pDC->MoveTo(CPoint(rcItem.left + 11, rcItem.top));
  425. pDC->LineTo(CPoint(rcItem.left + 11, rcItem.bottom));
  426. pDC->SelectObject(hOldFont);
  427. }
  428. // restore the previous values
  429. if(OldColor > -1)
  430. pDC->SetTextColor(OldColor);
  431. if(nOldBKMode > -1)
  432. pDC->SetBkMode(nOldBKMode);
  433. *pResult = CDRF_SKIPDEFAULT; // We've painted everything.
  434. }
  435. }
  436. BOOL CQListCtrl::DrawText(int nItem, CRect &crRect, CDC *pDC)
  437. {
  438. if(g_Opt.m_bDrawRTF == FALSE)
  439. return FALSE;
  440. static CLIPFORMAT clFormat = GetFormatID(_T("Rich Text Format"));
  441. BOOL bRet = FALSE;
  442. long lDatabaseID = GetItemData(nItem);
  443. CClipFormat* pThumbnail = &(m_RTFData[lDatabaseID]);
  444. if(pThumbnail == NULL)
  445. return FALSE;
  446. //If it has not been read in
  447. if(pThumbnail->m_cfType != clFormat)
  448. {
  449. pThumbnail->m_cfType = clFormat;
  450. //Get the data from the database
  451. GetClipData(nItem, *pThumbnail);
  452. }
  453. // if there's no data, then we're done.
  454. if( pThumbnail->m_hgData == NULL )
  455. return FALSE;
  456. if(m_pFormatter == NULL)
  457. {
  458. m_pFormatter = new CFormattedTextDraw;
  459. m_pFormatter->Create();
  460. }
  461. if(m_pFormatter)
  462. {
  463. char *pData = (char*)GlobalLock(pThumbnail->m_hgData);
  464. if(pData)
  465. {
  466. CComBSTR bStr(pData);
  467. m_pFormatter->put_RTFText(bStr);
  468. m_pFormatter->Draw(pDC->m_hDC, crRect);
  469. GlobalUnlock(pThumbnail->m_hgData);
  470. bRet = TRUE;
  471. }
  472. }
  473. return bRet;
  474. }
  475. // DrawBitMap loads a DIB from the DB, draws a crRect thumbnail of the image
  476. // to pDC and caches that thumbnail as a DIB in m_ThumbNails[ ItemID ].
  477. // ALL items are cached in m_ThumbNails (those without images are cached with NULL m_hgData)
  478. BOOL CQListCtrl::DrawBitMap(int nItem, CRect &crRect, CDC *pDC)
  479. {
  480. if(g_Opt.m_bDrawThumbnail == FALSE)
  481. return FALSE;
  482. bool bFromDB = false;
  483. long lDatabaseID = GetItemData(nItem);
  484. CClipFormat* pThumbnail = &(m_ThumbNails[lDatabaseID]);
  485. if(pThumbnail == NULL)
  486. return FALSE;
  487. //If it has not been read in
  488. if(pThumbnail->m_cfType != CF_DIB)
  489. {
  490. pThumbnail->m_cfType = CF_DIB;
  491. //Get the data from the database
  492. GetClipData(nItem, *pThumbnail);
  493. //convert to a small bitmap
  494. CBitmap Bitmap;
  495. if( !CBitmapHelper::GetCBitmap(pThumbnail, pDC, &Bitmap, crRect.Height()) )
  496. {
  497. Bitmap.DeleteObject();
  498. // the data is useless, so free it.
  499. pThumbnail->Free();
  500. return FALSE;
  501. }
  502. // delete the large image data loaded from the db
  503. pThumbnail->Free();
  504. pThumbnail->m_cfType = CF_DIB;
  505. //Convert the smaller bitmap back to a dib
  506. HPALETTE hPal = NULL;
  507. pThumbnail->m_hgData = CBitmapHelper::hBitmapToDIB( (HBITMAP)Bitmap, BI_RGB, hPal );
  508. ASSERT( pThumbnail->m_autoDeleteData ); // the map owns the data.
  509. Bitmap.DeleteObject();
  510. }
  511. // if there's no data, then we're done.
  512. if( pThumbnail->m_hgData == NULL )
  513. return TRUE;
  514. //Will return the width of the bitmap in nWidth
  515. int nWidth = 0;
  516. if(CBitmapHelper::DrawDIB(pDC, pThumbnail->m_hgData, crRect.left, crRect.top, nWidth))
  517. {
  518. // adjust the rect so other information can be drawn next to the thumbnail
  519. crRect.left += nWidth + 3;
  520. }
  521. return TRUE;
  522. }
  523. void CQListCtrl::RefreshVisibleRows()
  524. {
  525. int nTopIndex = GetTopIndex();
  526. int nLastIndex = nTopIndex + GetCountPerPage();
  527. RedrawItems(nTopIndex, nLastIndex);
  528. ::UpdateWindow(m_hWnd);
  529. }
  530. void CQListCtrl::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  531. {
  532. if(GetKeyState(VK_RETURN) & 0x800)
  533. GetParent()->SendMessage(NM_PROPERTIES, 0, 0);
  534. else
  535. CListCtrl::OnSysKeyDown(nChar, nRepCnt, nFlags);
  536. }
  537. BOOL CQListCtrl::OnEraseBkgnd(CDC* pDC)
  538. {
  539. // Simply returning TRUE seems OK since we do custom item
  540. // painting. However, there is a pixel buffer around the
  541. // border of this control (not within the item rects)
  542. // which becomes visually corrupt if it is not erased.
  543. // In most cases, I do not notice the erasure, so I have kept
  544. // the call to CListCtrl::OnEraseBkgnd(pDC);
  545. // However, for some reason, bulk erasure is very noticeable when
  546. // shift-scrolling the page to select a block of items, so
  547. // I made a special case for that:
  548. if( GetSelectedCount() >= 2 )
  549. return TRUE;
  550. return CListCtrl::OnEraseBkgnd(pDC);
  551. }
  552. BOOL CQListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  553. {
  554. // need to handle both ANSI and UNICODE versions of the message
  555. TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
  556. TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
  557. CString strTipText;
  558. UINT nID = pNMHDR->idFrom;
  559. if(nID == 0) // Notification in NT from automatically
  560. return FALSE; // created tooltip
  561. ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500);
  562. // Use Item's name as the tool tip. Change this for something different.
  563. // Like use its file size, etc.
  564. GetToolTipText(nID-1, strTipText);
  565. //Replace the tabs with spaces, the tooltip didn't like the \t s
  566. strTipText.Replace(_T("\t"), _T(" "));
  567. int nLength = strTipText.GetLength()+2;
  568. #ifndef _UNICODE
  569. if (pNMHDR->code == TTN_NEEDTEXTA)
  570. {
  571. if(m_pchTip != NULL)
  572. delete m_pchTip;
  573. m_pchTip = new TCHAR[nLength];
  574. lstrcpyn(m_pchTip, strTipText, nLength-1);
  575. m_pchTip[nLength-1] = 0;
  576. pTTTW->lpszText = (WCHAR*)m_pchTip;
  577. }
  578. else
  579. {
  580. if(m_pwchTip != NULL)
  581. delete m_pwchTip;
  582. m_pwchTip = new WCHAR[nLength];
  583. _mbstowcsz(m_pwchTip, strTipText, nLength-1);
  584. m_pwchTip[nLength-1] = 0; // end of text
  585. pTTTW->lpszText = (WCHAR*)m_pwchTip;
  586. }
  587. #else
  588. if(pNMHDR->code == TTN_NEEDTEXTA)
  589. {
  590. if(m_pchTip != NULL)
  591. delete m_pchTip;
  592. m_pchTip = new TCHAR[nLength];
  593. STRNCPY(m_pchTip, strTipText, nLength-1);
  594. m_pchTip[nLength-1] = 0; // end of text
  595. pTTTW->lpszText = (LPTSTR)m_pchTip;
  596. }
  597. else
  598. {
  599. if(m_pwchTip != NULL)
  600. delete m_pwchTip;
  601. m_pwchTip = new WCHAR[nLength];
  602. lstrcpyn(m_pwchTip, strTipText, nLength-1);
  603. m_pwchTip[nLength-1] = 0;
  604. pTTTW->lpszText = (LPTSTR) m_pwchTip;
  605. }
  606. #endif
  607. *pResult = 0;
  608. return TRUE; // message was handled
  609. }
  610. int CQListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
  611. {
  612. CRect rect;
  613. GetClientRect(&rect);
  614. if(rect.PtInRect(point))
  615. {
  616. if(GetItemCount())
  617. {
  618. int nTopIndex = GetTopIndex();
  619. int nBottomIndex = nTopIndex + GetCountPerPage();
  620. if(nBottomIndex > GetItemCount()) nBottomIndex = GetItemCount();
  621. for(int nIndex = nTopIndex; nIndex <= nBottomIndex; nIndex++)
  622. {
  623. GetItemRect(nIndex, rect, LVIR_BOUNDS);
  624. if(rect.PtInRect(point))
  625. {
  626. pTI->hwnd = m_hWnd;
  627. pTI->uId = (UINT)(nIndex+1);
  628. pTI->lpszText = LPSTR_TEXTCALLBACK;
  629. pTI->rect = rect;
  630. return pTI->uId;
  631. }
  632. }
  633. }
  634. }
  635. return -1;
  636. }
  637. int CQListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
  638. {
  639. if (CListCtrl::OnCreate(lpCreateStruct) == -1)
  640. return -1;
  641. EnableToolTips();
  642. m_pToolTip = new CToolTipEx;
  643. m_pToolTip->Create(this);
  644. m_pToolTip->SetNotifyWnd(GetParent());
  645. return 0;
  646. }
  647. BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
  648. {
  649. DWORD dID;
  650. if(m_Accels.OnMsg(pMsg, dID))
  651. {
  652. switch(dID)
  653. {
  654. case COPY_BUFFER_HOT_KEY_1_ID:
  655. PutSelectedItemOnDittoCopyBuffer(0);
  656. break;
  657. case COPY_BUFFER_HOT_KEY_2_ID:
  658. PutSelectedItemOnDittoCopyBuffer(1);
  659. break;
  660. case COPY_BUFFER_HOT_KEY_3_ID:
  661. PutSelectedItemOnDittoCopyBuffer(2);
  662. break;
  663. default:
  664. GetParent()->SendMessage(NM_SELECT_DB_ID, dID, 0);
  665. }
  666. return TRUE;
  667. }
  668. if(m_pToolTip)
  669. {
  670. if(m_pToolTip->OnMsg(pMsg))
  671. return TRUE;
  672. }
  673. switch(pMsg->message)
  674. {
  675. case WM_KEYDOWN:
  676. if(HandleKeyDown(pMsg->wParam, pMsg->lParam))
  677. return TRUE;
  678. break; // end case WM_KEYDOWN
  679. case WM_VSCROLL:
  680. ASSERT(FALSE);
  681. break;
  682. } // end switch(pMsg->message)
  683. return CListCtrl::PreTranslateMessage(pMsg);
  684. }
  685. BOOL CQListCtrl::HandleKeyDown(WPARAM wParam, LPARAM lParam)
  686. {
  687. if(m_pToolTip)
  688. {
  689. MSG Msg;
  690. Msg.lParam = lParam;
  691. Msg.wParam = wParam;
  692. Msg.message = WM_KEYDOWN;
  693. if(m_pToolTip->OnMsg(&Msg))
  694. return TRUE;
  695. }
  696. WPARAM vk = wParam;
  697. // if a number key was pressed
  698. if('0' <= vk && vk <= '9')
  699. {
  700. // if <Ctrl> is required but is absent, then break
  701. if(g_Opt.m_bUseCtrlNumAccel && !(GetKeyState(VK_CONTROL) & 0x8000))
  702. return FALSE;
  703. int index = vk - '0';
  704. // '0' is actually 10 in the ditto window
  705. if(index == 0)
  706. index = 10;
  707. // translate num 1-10 into the actual index (based upon m_bStartTop)
  708. index = GetFirstTenIndex(index);
  709. GetParent()->SendMessage(NM_SELECT_INDEX, index, 0);
  710. return TRUE;
  711. }
  712. if(VK_NUMPAD0 <= vk && vk <= VK_NUMPAD9)
  713. {
  714. // if <Ctrl> is required but is absent, then break
  715. if( g_Opt.m_bUseCtrlNumAccel && !(GetKeyState(VK_CONTROL) & 0x8000) )
  716. return FALSE;
  717. int index = vk - VK_NUMPAD0;
  718. // '0' is actually 10 in the ditto window
  719. if(index == 0)
  720. index = 10;
  721. // translate num 1-10 into the actual index (based upon m_bStartTop)
  722. index = GetFirstTenIndex(index);
  723. GetParent()->SendMessage(NM_SELECT_INDEX, index, 0);
  724. return TRUE;
  725. }
  726. switch( vk )
  727. {
  728. case 'X': // Ctrl-X = Cut (prepare for moving the items into a Group)
  729. if(GetKeyState(VK_CONTROL) & 0x8000)
  730. {
  731. LoadCopyOrCutToClipboard();
  732. theApp.IC_Cut(); // uses selection
  733. return TRUE;
  734. }
  735. break;
  736. case 'C': // Ctrl-C = Copy (prepare for copying the items into a Group)
  737. if(GetKeyState(VK_CONTROL) & 0x8000)
  738. {
  739. LoadCopyOrCutToClipboard();
  740. theApp.IC_Copy(); // uses selection
  741. return TRUE;
  742. }
  743. break;
  744. case 'V': // Ctrl-V = Paste (actually performs the copy or move of items into the current Group)
  745. if(GetKeyState(VK_CONTROL) & 0x8000)
  746. {
  747. theApp.IC_Paste();
  748. return TRUE;
  749. }
  750. break;
  751. case 'A': // Ctrl-A = Select All
  752. if(GetKeyState(VK_CONTROL) & 0x8000)
  753. {
  754. int nCount = GetItemCount();
  755. for(int i = 0; i < nCount; i++)
  756. {
  757. SetSelection(i);
  758. }
  759. return TRUE;
  760. }
  761. break;
  762. case VK_F3:
  763. {
  764. ShowFullDescription();
  765. return TRUE;
  766. }
  767. case VK_BACK:
  768. theApp.EnterGroupID( theApp.m_GroupParentID );
  769. return TRUE;
  770. case VK_SPACE:
  771. if(GetKeyState(VK_CONTROL) & 0x8000)
  772. {
  773. theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
  774. return TRUE;
  775. }
  776. break;
  777. } // end switch(vk)
  778. return FALSE;
  779. }
  780. void CQListCtrl::LoadCopyOrCutToClipboard()
  781. {
  782. ARRAY arr;
  783. GetSelectionItemData(arr);
  784. int nCount = arr.GetSize();
  785. if(nCount <= 0)
  786. return;
  787. CProcessPaste paste;
  788. //Don't send the paste just load it into memory
  789. paste.m_bSendPaste = false;
  790. if(nCount > 1)
  791. paste.GetClipIDs().Copy(arr);
  792. else
  793. paste.GetClipIDs().Add(arr[0]);
  794. //Don't move these to the top
  795. BOOL bItWas = g_Opt.m_bUpdateTimeOnPaste;
  796. g_Opt.m_bUpdateTimeOnPaste = FALSE;
  797. paste.DoPaste();
  798. g_Opt.m_bUpdateTimeOnPaste = bItWas;
  799. }
  800. void CQListCtrl::ShowFullDescription(bool bFromAuto)
  801. {
  802. int nItem = GetCaret();
  803. CRect rc, crWindow;
  804. GetWindowRect(&crWindow);
  805. GetItemRect(nItem, rc, LVIR_BOUNDS);
  806. ClientToScreen(rc);
  807. CPoint pt;
  808. if(bFromAuto == false)
  809. {
  810. pt = CPoint(rc.left, rc.bottom);
  811. }
  812. else
  813. pt = CPoint((crWindow.left + (crWindow.right - crWindow.left)/2), rc.bottom);
  814. CString csDescription;
  815. GetToolTipText(nItem, csDescription);
  816. m_pToolTip->DestroyWindow();
  817. m_pToolTip = new CToolTipEx;
  818. m_pToolTip->Create(this);
  819. m_pToolTip->SetNotifyWnd(GetParent());
  820. if(m_pToolTip)
  821. {
  822. m_pToolTip->SetToolTipText(_T(""));
  823. m_pToolTip->SetRTFText(" ");
  824. bool bSetPlainText = false;
  825. CClipFormat Clip;
  826. Clip.m_cfType = CF_UNICODETEXT;
  827. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  828. {
  829. LPVOID pvData = GlobalLock(Clip.m_hgData);
  830. if(pvData)
  831. {
  832. CString csText = (WCHAR*)pvData;
  833. m_pToolTip->SetToolTipText(csText);
  834. bSetPlainText = true;
  835. }
  836. GlobalUnlock(Clip.m_hgData);
  837. Clip.Free();
  838. Clip.Clear();
  839. }
  840. if(bSetPlainText == false)
  841. {
  842. Clip.m_cfType = CF_TEXT;
  843. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  844. {
  845. LPVOID pvData = GlobalLock(Clip.m_hgData);
  846. if(pvData)
  847. {
  848. CString csText = (char*)pvData;
  849. m_pToolTip->SetToolTipText(csText);
  850. bSetPlainText = true;
  851. }
  852. GlobalUnlock(Clip.m_hgData);
  853. Clip.Free();
  854. Clip.Clear();
  855. }
  856. }
  857. if(bSetPlainText == false)
  858. {
  859. m_pToolTip->SetToolTipText(csDescription);
  860. }
  861. Clip.m_cfType = RegisterClipboardFormat(CF_RTF);
  862. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  863. {
  864. LPVOID pvData = GlobalLock(Clip.m_hgData);
  865. if(pvData)
  866. {
  867. m_pToolTip->SetRTFText((char*)pvData);
  868. }
  869. GlobalUnlock(Clip.m_hgData);
  870. Clip.Free();
  871. Clip.Clear();
  872. }
  873. Clip.m_cfType = CF_DIB;
  874. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  875. {
  876. CBitmap *pBitMap = new CBitmap;
  877. if(pBitMap)
  878. {
  879. CRect rcItem;
  880. GetWindowRect(rcItem);
  881. CDC *pDC = GetDC();;
  882. CBitmapHelper::GetCBitmap(&Clip, pDC, pBitMap, (rcItem.Width() * 2));
  883. ReleaseDC(pDC);
  884. //Tooltip wnd will release
  885. m_pToolTip->SetBitmap(pBitMap);
  886. }
  887. Clip.Free();
  888. Clip.Clear();
  889. }
  890. m_pToolTip->Show(pt);
  891. }
  892. }
  893. void CQListCtrl::GetToolTipText(int nItem, CString &csText)
  894. {
  895. CWnd* pParent=GetParent();
  896. if(pParent && (pParent->GetSafeHwnd() != NULL))
  897. {
  898. CQListToolTipText info;
  899. memset(&info, 0, sizeof(info));
  900. info.hdr.code = NM_GETTOOLTIPTEXT;
  901. info.hdr.hwndFrom = GetSafeHwnd();
  902. info.hdr.idFrom = GetDlgCtrlID();
  903. info.lItem = nItem;
  904. //plus 100 for extra info - shortcut and such
  905. info.cchTextMax = g_Opt.m_bDescTextSize + 100;
  906. info.pszText = csText.GetBufferSetLength(info.cchTextMax);
  907. pParent->SendMessage(WM_NOTIFY,(WPARAM)info.hdr.idFrom,(LPARAM)&info);
  908. csText.ReleaseBuffer();
  909. }
  910. }
  911. BOOL CQListCtrl::GetClipData(int nItem, CClipFormat &Clip)
  912. {
  913. return theApp.GetClipData(GetItemData(nItem), Clip);
  914. }
  915. DWORD CQListCtrl::GetItemData(int nItem)
  916. {
  917. if((GetStyle() & LVS_OWNERDATA))
  918. {
  919. CWnd* pParent=GetParent();
  920. if(pParent && (pParent->GetSafeHwnd() != NULL))
  921. {
  922. LV_DISPINFO info;
  923. memset(&info, 0, sizeof(info));
  924. info.hdr.code = LVN_GETDISPINFO;
  925. info.hdr.hwndFrom = GetSafeHwnd();
  926. info.hdr.idFrom = GetDlgCtrlID();
  927. info.item.iItem = nItem;
  928. info.item.lParam = -1;
  929. info.item.mask = LVIF_PARAM;
  930. pParent->SendMessage(WM_NOTIFY,(WPARAM)info.hdr.idFrom,(LPARAM)&info);
  931. return info.item.lParam;
  932. }
  933. }
  934. return CListCtrl::GetItemData(nItem);
  935. }
  936. void CQListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  937. {
  938. CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
  939. }
  940. void CQListCtrl::DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db)
  941. {
  942. m_Accels.m_Map.RemoveAll();
  943. if(bCreate)
  944. {
  945. CMainTableFunctions::LoadAcceleratorKeys(m_Accels, db);
  946. LoadDittoCopyBufferHotkeys();
  947. }
  948. }
  949. void CQListCtrl::LoadDittoCopyBufferHotkeys()
  950. {
  951. CCopyBufferItem Item;
  952. CAccel a;
  953. g_Opt.GetCopyBufferItem(0, Item);
  954. if(Item.m_lCopyHotKey > 0)
  955. {
  956. a.Cmd = COPY_BUFFER_HOT_KEY_1_ID;
  957. a.Key = Item.m_lCopyHotKey;
  958. m_Accels.AddAccel(a);
  959. }
  960. g_Opt.GetCopyBufferItem(1, Item);
  961. if(Item.m_lCopyHotKey > 0)
  962. {
  963. a.Cmd = COPY_BUFFER_HOT_KEY_2_ID;
  964. a.Key = Item.m_lCopyHotKey;
  965. m_Accels.AddAccel(a);
  966. }
  967. g_Opt.GetCopyBufferItem(2, Item);
  968. if(Item.m_lCopyHotKey > 0)
  969. {
  970. a.Cmd = COPY_BUFFER_HOT_KEY_3_ID;
  971. a.Key = Item.m_lCopyHotKey;
  972. m_Accels.AddAccel(a);
  973. }
  974. }
  975. void CQListCtrl::OnKillFocus(CWnd* pNewWnd)
  976. {
  977. CListCtrl::OnKillFocus(pNewWnd);
  978. // if(FocusOnToolTip() == FALSE)
  979. // m_pToolTip->Hide();
  980. }
  981. HWND CQListCtrl::GetToolTipHWnd()
  982. {
  983. return m_pToolTip->GetSafeHwnd();
  984. }
  985. BOOL CQListCtrl::SetItemCountEx(int iCount, DWORD dwFlags /* = LVSICF_NOINVALIDATEALL */)
  986. {
  987. theApp.SetStatus(NULL, TRUE);
  988. return CListCtrl::SetItemCountEx(iCount, dwFlags);
  989. }
  990. #define TIMER_SHOW_PROPERTIES 1
  991. void CQListCtrl::OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult)
  992. {
  993. NMLISTVIEW *pnmv = (NMLISTVIEW *) pNMHDR;
  994. if((pnmv->uNewState == 3) ||
  995. (pnmv->uNewState == 1))
  996. {
  997. if(g_Opt.m_bAllwaysShowDescription)
  998. {
  999. KillTimer(TIMER_SHOW_PROPERTIES);
  1000. SetTimer(TIMER_SHOW_PROPERTIES, 300, NULL);
  1001. }
  1002. if(GetSelectedCount() > 0 )
  1003. theApp.SetStatus(NULL, FALSE);
  1004. }
  1005. }
  1006. void CQListCtrl::OnTimer(UINT nIDEvent)
  1007. {
  1008. if(nIDEvent == TIMER_SHOW_PROPERTIES)
  1009. {
  1010. if( theApp.m_bShowingQuickPaste )
  1011. ShowFullDescription(true);
  1012. KillTimer(TIMER_SHOW_PROPERTIES);
  1013. }
  1014. CListCtrl::OnTimer(nIDEvent);
  1015. }
  1016. void CQListCtrl::SetLogFont(LOGFONT &font)
  1017. {
  1018. m_Font.DeleteObject();
  1019. m_Font.CreateFontIndirect(&font);
  1020. SetFont(&m_Font);
  1021. }
  1022. void CQListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  1023. {
  1024. CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
  1025. }
  1026. BOOL CQListCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  1027. {
  1028. return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
  1029. }
  1030. BOOL CQListCtrl::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
  1031. {
  1032. NMLVCACHEHINT* pcachehint = NULL;
  1033. if(message == WM_NOTIFY)
  1034. {
  1035. NMHDR* phdr = (NMHDR*)lParam;
  1036. switch(phdr->code)
  1037. {
  1038. case LVN_ODCACHEHINT:
  1039. pcachehint= (NMLVCACHEHINT*) phdr;
  1040. GetParent()->SendMessage(NM_FILL_REST_OF_LIST, pcachehint->iFrom, pcachehint->iTo);
  1041. return FALSE;
  1042. }
  1043. }
  1044. return CListCtrl::OnChildNotify(message, wParam, lParam, pLResult);
  1045. }
  1046. BOOL CQListCtrl::OnItemDeleted(long lID)
  1047. {
  1048. BOOL bRet = m_ThumbNails.RemoveKey(lID);
  1049. BOOL bRet2 = m_RTFData.RemoveKey(lID);
  1050. return (bRet || bRet2);
  1051. }