QListCtrl.cpp 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  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 = GetSysColor(COLOR_HIGHLIGHT);
  322. OldColor = pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
  323. }
  324. else
  325. {
  326. crBkgnd = GetSysColor(COLOR_BTNFACE);
  327. OldColor = pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
  328. }
  329. }
  330. else
  331. {
  332. //Shade alternating Rows
  333. if((nItem % 2) == 0)
  334. {
  335. COLORREF color = GetSysColor(COLOR_WINDOW);
  336. int r = GetRValue(color) - 15;
  337. int g = GetGValue(color) - 15;
  338. int b = GetBValue(color) - 15;
  339. r = max(r, 0);
  340. g = max(g, 0);
  341. b = max(b, 0);
  342. crBkgnd = RGB(r, g, b);
  343. }
  344. else
  345. crBkgnd = GetSysColor(COLOR_WINDOW);
  346. OldColor = pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
  347. }
  348. pDC->FillSolidRect(rcItem, crBkgnd);
  349. nOldBKMode = pDC->SetBkMode(TRANSPARENT);
  350. CRect rcText = rcItem;
  351. rcText.left += ROW_LEFT_BORDER;
  352. rcText.top++;
  353. // Draw the text.
  354. //CString csText = GetItemText(nItem, 0);
  355. CString csText;
  356. LPTSTR lpszText = csText.GetBufferSetLength(g_Opt.m_bDescTextSize);
  357. GetItemText(nItem, 0, lpszText, g_Opt.m_bDescTextSize);
  358. csText.ReleaseBuffer();
  359. // extract symbols
  360. CString strSymbols;
  361. int nSymEnd = csText.Find('|');
  362. if( nSymEnd >= 0 )
  363. {
  364. strSymbols = csText.Left(nSymEnd);
  365. csText = csText.Mid(nSymEnd+1);
  366. }
  367. // set firstTenNum to the first ten number (1-10) corresponding to
  368. // the current nItem.
  369. // -1 means that nItem is not in the FirstTen block.
  370. int firstTenNum = GetFirstTenNum(nItem);
  371. if( m_bShowTextForFirstTenHotKeys && firstTenNum > 0 )
  372. {
  373. rcText.left += 12;
  374. }
  375. // if we are inside a group, don't display the "in group" flag
  376. if( theApp.m_GroupID > 0 )
  377. {
  378. int nFlag = strSymbols.Find(_T("!"));
  379. if( nFlag >= 0 )
  380. strSymbols.Delete(nFlag);
  381. }
  382. DrawBitMap(nItem, rcText, pDC);
  383. // draw the symbol box
  384. if( strSymbols.GetLength() > 0 )
  385. {
  386. strSymbols = " " + strSymbols + " "; // leave space for box
  387. // add spaces to leave room for the symbols
  388. CRect rectSym(rcText.left, rcText.top+1, rcText.left, rcText.top+1);
  389. CRect rectSpace(0,0,0,0);
  390. //Get text bounds
  391. pDC->DrawText(" ", &rectSpace, DT_VCENTER | DT_EXPANDTABS | DT_CALCRECT);
  392. pDC->DrawText(strSymbols, &rectSym, DT_VCENTER | DT_EXPANDTABS | DT_CALCRECT);
  393. VERIFY( rectSpace.Width() > 0 );
  394. // int numSpaces = rectSym.Width() / rectSpace.Width();
  395. // numSpaces++;
  396. // csText = CString(' ',numSpaces) + csText;
  397. // draw the symbols
  398. pDC->FillSolidRect( rectSym, GetSysColor(COLOR_ACTIVECAPTION) );
  399. //pDC->FillSolidRect( rectSym, RGB(0,255,255) );
  400. pDC->Draw3dRect(rectSym, GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_3DDKSHADOW));
  401. // COLORREF crOld = pDC->SetTextColor(GetSysColor(COLOR_INFOTEXT));
  402. COLORREF crOld = pDC->SetTextColor(RGB(255, 255, 255));
  403. pDC->DrawText(strSymbols, rectSym, DT_VCENTER|DT_EXPANDTABS|DT_NOPREFIX);
  404. pDC->SetTextColor(crOld);
  405. rcText.left += rectSym.Width() + 2;
  406. }
  407. if(DrawText(nItem, rcText, pDC) == FALSE)
  408. pDC->DrawText(csText, rcText, DT_VCENTER|DT_EXPANDTABS|DT_NOPREFIX);
  409. // Draw a focus rect around the item if necessary.
  410. if(bListHasFocus && (rItem.state & LVIS_FOCUSED))
  411. pDC->DrawFocusRect(rcItem);
  412. if( m_bShowTextForFirstTenHotKeys && firstTenNum > 0 )
  413. {
  414. CString cs;
  415. if( firstTenNum == 10 )
  416. cs = "0";
  417. else
  418. cs.Format(_T("%d"), firstTenNum);
  419. CRect crClient;
  420. GetWindowRect(crClient);
  421. ScreenToClient(crClient);
  422. CRect crHotKey = rcItem;
  423. crHotKey.right = crHotKey.left + 11;
  424. crHotKey.left += 2;
  425. crHotKey.top += 2;
  426. HFONT hOldFont = (HFONT)pDC->SelectObject(m_SmallFont);
  427. pDC->DrawText(cs, crHotKey, DT_BOTTOM);
  428. pDC->MoveTo(CPoint(rcItem.left + 11, rcItem.top));
  429. pDC->LineTo(CPoint(rcItem.left + 11, rcItem.bottom));
  430. pDC->SelectObject(hOldFont);
  431. }
  432. // restore the previous values
  433. if(OldColor > -1)
  434. pDC->SetTextColor(OldColor);
  435. if(nOldBKMode > -1)
  436. pDC->SetBkMode(nOldBKMode);
  437. *pResult = CDRF_SKIPDEFAULT; // We've painted everything.
  438. }
  439. }
  440. BOOL CQListCtrl::DrawText(int nItem, CRect &crRect, CDC *pDC)
  441. {
  442. if(g_Opt.m_bDrawRTF == FALSE)
  443. return FALSE;
  444. static CLIPFORMAT clFormat = GetFormatID(_T("Rich Text Format"));
  445. BOOL bRet = FALSE;
  446. long lDatabaseID = GetItemData(nItem);
  447. CClipFormat* pThumbnail = &(m_RTFData[lDatabaseID]);
  448. if(pThumbnail == NULL)
  449. return FALSE;
  450. //If it has not been read in
  451. if(pThumbnail->m_cfType != clFormat)
  452. {
  453. pThumbnail->m_cfType = clFormat;
  454. //Get the data from the database
  455. GetClipData(nItem, *pThumbnail);
  456. }
  457. // if there's no data, then we're done.
  458. if( pThumbnail->m_hgData == NULL )
  459. return FALSE;
  460. if(m_pFormatter == NULL)
  461. {
  462. m_pFormatter = new CFormattedTextDraw;
  463. m_pFormatter->Create();
  464. }
  465. if(m_pFormatter)
  466. {
  467. char *pData = (char*)GlobalLock(pThumbnail->m_hgData);
  468. if(pData)
  469. {
  470. CComBSTR bStr(pData);
  471. m_pFormatter->put_RTFText(bStr);
  472. m_pFormatter->Draw(pDC->m_hDC, crRect);
  473. GlobalUnlock(pThumbnail->m_hgData);
  474. bRet = TRUE;
  475. }
  476. }
  477. return bRet;
  478. }
  479. // DrawBitMap loads a DIB from the DB, draws a crRect thumbnail of the image
  480. // to pDC and caches that thumbnail as a DIB in m_ThumbNails[ ItemID ].
  481. // ALL items are cached in m_ThumbNails (those without images are cached with NULL m_hgData)
  482. BOOL CQListCtrl::DrawBitMap(int nItem, CRect &crRect, CDC *pDC)
  483. {
  484. if(g_Opt.m_bDrawThumbnail == FALSE)
  485. return FALSE;
  486. bool bFromDB = false;
  487. long lDatabaseID = GetItemData(nItem);
  488. CClipFormat* pThumbnail = &(m_ThumbNails[lDatabaseID]);
  489. if(pThumbnail == NULL)
  490. return FALSE;
  491. //If it has not been read in
  492. if(pThumbnail->m_cfType != CF_DIB)
  493. {
  494. pThumbnail->m_cfType = CF_DIB;
  495. //Get the data from the database
  496. GetClipData(nItem, *pThumbnail);
  497. //convert to a small bitmap
  498. CBitmap Bitmap;
  499. if( !CBitmapHelper::GetCBitmap(pThumbnail, pDC, &Bitmap, crRect.Height()) )
  500. {
  501. Bitmap.DeleteObject();
  502. // the data is useless, so free it.
  503. pThumbnail->Free();
  504. return FALSE;
  505. }
  506. // delete the large image data loaded from the db
  507. pThumbnail->Free();
  508. pThumbnail->m_cfType = CF_DIB;
  509. //Convert the smaller bitmap back to a dib
  510. HPALETTE hPal = NULL;
  511. pThumbnail->m_hgData = CBitmapHelper::hBitmapToDIB( (HBITMAP)Bitmap, BI_RGB, hPal );
  512. ASSERT( pThumbnail->bDeleteData ); // the map owns the data.
  513. Bitmap.DeleteObject();
  514. }
  515. // if there's no data, then we're done.
  516. if( pThumbnail->m_hgData == NULL )
  517. return TRUE;
  518. //Will return the width of the bitmap in nWidth
  519. int nWidth = 0;
  520. if(CBitmapHelper::DrawDIB(pDC, pThumbnail->m_hgData, crRect.left, crRect.top, nWidth))
  521. {
  522. // adjust the rect so other information can be drawn next to the thumbnail
  523. crRect.left += nWidth + 3;
  524. }
  525. return TRUE;
  526. }
  527. void CQListCtrl::RefreshVisibleRows()
  528. {
  529. int nTopIndex = GetTopIndex();
  530. int nLastIndex = nTopIndex + GetCountPerPage();
  531. RedrawItems(nTopIndex, nLastIndex);
  532. ::UpdateWindow(m_hWnd);
  533. }
  534. void CQListCtrl::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  535. {
  536. if(GetKeyState(VK_RETURN) & 0x800)
  537. GetParent()->SendMessage(NM_PROPERTIES, 0, 0);
  538. else
  539. CListCtrl::OnSysKeyDown(nChar, nRepCnt, nFlags);
  540. }
  541. BOOL CQListCtrl::OnEraseBkgnd(CDC* pDC)
  542. {
  543. // Simply returning TRUE seems OK since we do custom item
  544. // painting. However, there is a pixel buffer around the
  545. // border of this control (not within the item rects)
  546. // which becomes visually corrupt if it is not erased.
  547. // In most cases, I do not notice the erasure, so I have kept
  548. // the call to CListCtrl::OnEraseBkgnd(pDC);
  549. // However, for some reason, bulk erasure is very noticeable when
  550. // shift-scrolling the page to select a block of items, so
  551. // I made a special case for that:
  552. if( GetSelectedCount() >= 2 )
  553. return TRUE;
  554. return CListCtrl::OnEraseBkgnd(pDC);
  555. }
  556. BOOL CQListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  557. {
  558. // need to handle both ANSI and UNICODE versions of the message
  559. TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
  560. TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
  561. CString strTipText;
  562. UINT nID = pNMHDR->idFrom;
  563. if(nID == 0) // Notification in NT from automatically
  564. return FALSE; // created tooltip
  565. ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500);
  566. // Use Item's name as the tool tip. Change this for something different.
  567. // Like use its file size, etc.
  568. GetToolTipText(nID-1, strTipText);
  569. //Replace the tabs with spaces, the tooltip didn't like the \t s
  570. strTipText.Replace(_T("\t"), _T(" "));
  571. int nLength = strTipText.GetLength()+2;
  572. #ifndef _UNICODE
  573. if (pNMHDR->code == TTN_NEEDTEXTA)
  574. {
  575. if(m_pchTip != NULL)
  576. delete m_pchTip;
  577. m_pchTip = new TCHAR[nLength];
  578. lstrcpyn(m_pchTip, strTipText, nLength-1);
  579. m_pchTip[nLength-1] = 0;
  580. pTTTW->lpszText = (WCHAR*)m_pchTip;
  581. }
  582. else
  583. {
  584. if(m_pwchTip != NULL)
  585. delete m_pwchTip;
  586. m_pwchTip = new WCHAR[nLength];
  587. _mbstowcsz(m_pwchTip, strTipText, nLength-1);
  588. m_pwchTip[nLength-1] = 0; // end of text
  589. pTTTW->lpszText = (WCHAR*)m_pwchTip;
  590. }
  591. #else
  592. if(pNMHDR->code == TTN_NEEDTEXTA)
  593. {
  594. if(m_pchTip != NULL)
  595. delete m_pchTip;
  596. m_pchTip = new TCHAR[nLength];
  597. STRNCPY(m_pchTip, strTipText, nLength-1);
  598. m_pchTip[nLength-1] = 0; // end of text
  599. pTTTW->lpszText = (LPTSTR)m_pchTip;
  600. }
  601. else
  602. {
  603. if(m_pwchTip != NULL)
  604. delete m_pwchTip;
  605. m_pwchTip = new WCHAR[nLength];
  606. lstrcpyn(m_pwchTip, strTipText, nLength-1);
  607. m_pwchTip[nLength-1] = 0;
  608. pTTTW->lpszText = (LPTSTR) m_pwchTip;
  609. }
  610. #endif
  611. *pResult = 0;
  612. return TRUE; // message was handled
  613. }
  614. int CQListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
  615. {
  616. CRect rect;
  617. GetClientRect(&rect);
  618. if(rect.PtInRect(point))
  619. {
  620. if(GetItemCount())
  621. {
  622. int nTopIndex = GetTopIndex();
  623. int nBottomIndex = nTopIndex + GetCountPerPage();
  624. if(nBottomIndex > GetItemCount()) nBottomIndex = GetItemCount();
  625. for(int nIndex = nTopIndex; nIndex <= nBottomIndex; nIndex++)
  626. {
  627. GetItemRect(nIndex, rect, LVIR_BOUNDS);
  628. if(rect.PtInRect(point))
  629. {
  630. pTI->hwnd = m_hWnd;
  631. pTI->uId = (UINT)(nIndex+1);
  632. pTI->lpszText = LPSTR_TEXTCALLBACK;
  633. pTI->rect = rect;
  634. return pTI->uId;
  635. }
  636. }
  637. }
  638. }
  639. return -1;
  640. }
  641. int CQListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
  642. {
  643. if (CListCtrl::OnCreate(lpCreateStruct) == -1)
  644. return -1;
  645. EnableToolTips();
  646. m_pToolTip = new CToolTipEx;
  647. m_pToolTip->Create(this);
  648. m_pToolTip->SetNotifyWnd(GetParent());
  649. return 0;
  650. }
  651. BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
  652. {
  653. DWORD dID;
  654. if(m_Accels.OnMsg(pMsg, dID))
  655. {
  656. switch(dID)
  657. {
  658. case COPY_BUFFER_HOT_KEY_1_ID:
  659. PutSelectedItemOnDittoCopyBuffer(0);
  660. break;
  661. case COPY_BUFFER_HOT_KEY_2_ID:
  662. PutSelectedItemOnDittoCopyBuffer(1);
  663. break;
  664. case COPY_BUFFER_HOT_KEY_3_ID:
  665. PutSelectedItemOnDittoCopyBuffer(2);
  666. break;
  667. default:
  668. GetParent()->SendMessage(NM_SELECT_DB_ID, dID, 0);
  669. }
  670. return TRUE;
  671. }
  672. if(m_pToolTip)
  673. {
  674. if(m_pToolTip->OnMsg(pMsg))
  675. return TRUE;
  676. }
  677. switch(pMsg->message)
  678. {
  679. case WM_KEYDOWN:
  680. if(HandleKeyDown(pMsg->wParam, pMsg->lParam))
  681. return TRUE;
  682. break; // end case WM_KEYDOWN
  683. case WM_VSCROLL:
  684. ASSERT(FALSE);
  685. break;
  686. } // end switch(pMsg->message)
  687. return CListCtrl::PreTranslateMessage(pMsg);
  688. }
  689. BOOL CQListCtrl::HandleKeyDown(WPARAM wParam, LPARAM lParam)
  690. {
  691. if(m_pToolTip)
  692. {
  693. MSG Msg;
  694. Msg.lParam = lParam;
  695. Msg.wParam = wParam;
  696. Msg.message = WM_KEYDOWN;
  697. if(m_pToolTip->OnMsg(&Msg))
  698. return TRUE;
  699. }
  700. WPARAM vk = wParam;
  701. // if a number key was pressed
  702. if('0' <= vk && vk <= '9')
  703. {
  704. // if <Ctrl> is required but is absent, then break
  705. if(g_Opt.m_bUseCtrlNumAccel && !(GetKeyState(VK_CONTROL) & 0x8000))
  706. return FALSE;
  707. int index = vk - '0';
  708. // '0' is actually 10 in the ditto window
  709. if(index == 0)
  710. index = 10;
  711. // translate num 1-10 into the actual index (based upon m_bStartTop)
  712. index = GetFirstTenIndex(index);
  713. GetParent()->SendMessage(NM_SELECT_INDEX, index, 0);
  714. return TRUE;
  715. }
  716. if(VK_NUMPAD0 <= vk && vk <= VK_NUMPAD9)
  717. {
  718. // if <Ctrl> is required but is absent, then break
  719. if( g_Opt.m_bUseCtrlNumAccel && !(GetKeyState(VK_CONTROL) & 0x8000) )
  720. return FALSE;
  721. int index = vk - VK_NUMPAD0;
  722. // '0' is actually 10 in the ditto window
  723. if(index == 0)
  724. index = 10;
  725. // translate num 1-10 into the actual index (based upon m_bStartTop)
  726. index = GetFirstTenIndex(index);
  727. GetParent()->SendMessage(NM_SELECT_INDEX, index, 0);
  728. return TRUE;
  729. }
  730. switch( vk )
  731. {
  732. case 'X': // Ctrl-X = Cut (prepare for moving the items into a Group)
  733. if(GetKeyState(VK_CONTROL) & 0x8000)
  734. {
  735. LoadCopyOrCutToClipboard();
  736. theApp.IC_Cut(); // uses selection
  737. return TRUE;
  738. }
  739. break;
  740. case 'C': // Ctrl-C = Copy (prepare for copying the items into a Group)
  741. if(GetKeyState(VK_CONTROL) & 0x8000)
  742. {
  743. LoadCopyOrCutToClipboard();
  744. theApp.IC_Copy(); // uses selection
  745. return TRUE;
  746. }
  747. break;
  748. case 'V': // Ctrl-V = Paste (actually performs the copy or move of items into the current Group)
  749. if(GetKeyState(VK_CONTROL) & 0x8000)
  750. {
  751. theApp.IC_Paste();
  752. return TRUE;
  753. }
  754. break;
  755. case 'A': // Ctrl-A = Select All
  756. if(GetKeyState(VK_CONTROL) & 0x8000)
  757. {
  758. int nCount = GetItemCount();
  759. for(int i = 0; i < nCount; i++)
  760. {
  761. SetSelection(i);
  762. }
  763. return TRUE;
  764. }
  765. break;
  766. case VK_F3:
  767. {
  768. ShowFullDescription();
  769. return TRUE;
  770. }
  771. case VK_BACK:
  772. theApp.EnterGroupID( theApp.m_GroupParentID );
  773. return TRUE;
  774. case VK_SPACE:
  775. if(GetKeyState(VK_CONTROL) & 0x8000)
  776. {
  777. theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
  778. return TRUE;
  779. }
  780. break;
  781. } // end switch(vk)
  782. return FALSE;
  783. }
  784. void CQListCtrl::LoadCopyOrCutToClipboard()
  785. {
  786. ARRAY arr;
  787. GetSelectionItemData(arr);
  788. int nCount = arr.GetSize();
  789. if(nCount <= 0)
  790. return;
  791. CProcessPaste paste;
  792. //Don't send the paste just load it into memory
  793. paste.m_bSendPaste = false;
  794. if(nCount > 1)
  795. paste.GetClipIDs().Copy(arr);
  796. else
  797. paste.GetClipIDs().Add(arr[0]);
  798. //Don't move these to the top
  799. BOOL bItWas = g_Opt.m_bUpdateTimeOnPaste;
  800. g_Opt.m_bUpdateTimeOnPaste = FALSE;
  801. paste.DoPaste();
  802. g_Opt.m_bUpdateTimeOnPaste = bItWas;
  803. }
  804. void CQListCtrl::ShowFullDescription(bool bFromAuto)
  805. {
  806. int nItem = GetCaret();
  807. CRect rc, crWindow;
  808. GetWindowRect(&crWindow);
  809. GetItemRect(nItem, rc, LVIR_BOUNDS);
  810. ClientToScreen(rc);
  811. CPoint pt;
  812. if(bFromAuto == false)
  813. {
  814. pt = CPoint(rc.left, rc.bottom);
  815. }
  816. else
  817. pt = CPoint((crWindow.left + (crWindow.right - crWindow.left)/2), rc.bottom);
  818. CString csDescription;
  819. GetToolTipText(nItem, csDescription);
  820. m_pToolTip->DestroyWindow();
  821. m_pToolTip = new CToolTipEx;
  822. m_pToolTip->Create(this);
  823. m_pToolTip->SetNotifyWnd(GetParent());
  824. if(m_pToolTip)
  825. {
  826. m_pToolTip->SetToolTipText(_T(""));
  827. m_pToolTip->SetRTFText(" ");
  828. bool bSetPlainText = false;
  829. CClipFormat Clip;
  830. Clip.m_cfType = CF_UNICODETEXT;
  831. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  832. {
  833. LPVOID pvData = GlobalLock(Clip.m_hgData);
  834. if(pvData)
  835. {
  836. CString csText = (WCHAR*)pvData;
  837. m_pToolTip->SetToolTipText(csText);
  838. bSetPlainText = true;
  839. }
  840. GlobalUnlock(Clip.m_hgData);
  841. Clip.Free();
  842. Clip.Clear();
  843. }
  844. if(bSetPlainText == false)
  845. {
  846. Clip.m_cfType = CF_TEXT;
  847. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  848. {
  849. LPVOID pvData = GlobalLock(Clip.m_hgData);
  850. if(pvData)
  851. {
  852. CString csText = (char*)pvData;
  853. m_pToolTip->SetToolTipText(csText);
  854. bSetPlainText = true;
  855. }
  856. GlobalUnlock(Clip.m_hgData);
  857. Clip.Free();
  858. Clip.Clear();
  859. }
  860. }
  861. if(bSetPlainText == false)
  862. {
  863. m_pToolTip->SetToolTipText(csDescription);
  864. }
  865. Clip.m_cfType = RegisterClipboardFormat(CF_RTF);
  866. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  867. {
  868. LPVOID pvData = GlobalLock(Clip.m_hgData);
  869. if(pvData)
  870. {
  871. m_pToolTip->SetRTFText((char*)pvData);
  872. }
  873. GlobalUnlock(Clip.m_hgData);
  874. Clip.Free();
  875. Clip.Clear();
  876. }
  877. Clip.m_cfType = CF_DIB;
  878. if(GetClipData(nItem, Clip) && Clip.m_hgData)
  879. {
  880. CBitmap *pBitMap = new CBitmap;
  881. if(pBitMap)
  882. {
  883. CRect rcItem;
  884. GetWindowRect(rcItem);
  885. CDC *pDC = GetDC();;
  886. CBitmapHelper::GetCBitmap(&Clip, pDC, pBitMap, (rcItem.Width() * 2));
  887. ReleaseDC(pDC);
  888. //Tooltip wnd will release
  889. m_pToolTip->SetBitmap(pBitMap);
  890. }
  891. Clip.Free();
  892. Clip.Clear();
  893. }
  894. m_pToolTip->Show(pt);
  895. }
  896. }
  897. void CQListCtrl::GetToolTipText(int nItem, CString &csText)
  898. {
  899. CWnd* pParent=GetParent();
  900. if(pParent && (pParent->GetSafeHwnd() != NULL))
  901. {
  902. CQListToolTipText info;
  903. memset(&info, 0, sizeof(info));
  904. info.hdr.code = NM_GETTOOLTIPTEXT;
  905. info.hdr.hwndFrom = GetSafeHwnd();
  906. info.hdr.idFrom = GetDlgCtrlID();
  907. info.lItem = nItem;
  908. //plus 100 for extra info - shortcut and such
  909. info.cchTextMax = g_Opt.m_bDescTextSize + 100;
  910. info.pszText = csText.GetBufferSetLength(info.cchTextMax);
  911. pParent->SendMessage(WM_NOTIFY,(WPARAM)info.hdr.idFrom,(LPARAM)&info);
  912. csText.ReleaseBuffer();
  913. }
  914. }
  915. BOOL CQListCtrl::GetClipData(int nItem, CClipFormat &Clip)
  916. {
  917. return theApp.GetClipData(GetItemData(nItem), Clip);
  918. }
  919. DWORD CQListCtrl::GetItemData(int nItem)
  920. {
  921. if((GetStyle() & LVS_OWNERDATA))
  922. {
  923. CWnd* pParent=GetParent();
  924. if(pParent && (pParent->GetSafeHwnd() != NULL))
  925. {
  926. LV_DISPINFO info;
  927. memset(&info, 0, sizeof(info));
  928. info.hdr.code = LVN_GETDISPINFO;
  929. info.hdr.hwndFrom = GetSafeHwnd();
  930. info.hdr.idFrom = GetDlgCtrlID();
  931. info.item.iItem = nItem;
  932. info.item.lParam = -1;
  933. info.item.mask = LVIF_PARAM;
  934. pParent->SendMessage(WM_NOTIFY,(WPARAM)info.hdr.idFrom,(LPARAM)&info);
  935. return info.item.lParam;
  936. }
  937. }
  938. return CListCtrl::GetItemData(nItem);
  939. }
  940. void CQListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  941. {
  942. CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
  943. }
  944. void CQListCtrl::DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db)
  945. {
  946. m_Accels.m_Map.RemoveAll();
  947. if(bCreate)
  948. {
  949. CMainTableFunctions::LoadAcceleratorKeys(m_Accels, db);
  950. LoadDittoCopyBufferHotkeys();
  951. }
  952. }
  953. void CQListCtrl::LoadDittoCopyBufferHotkeys()
  954. {
  955. CCopyBufferItem Item;
  956. CAccel a;
  957. g_Opt.GetCopyBufferItem(0, Item);
  958. if(Item.m_lCopyHotKey > 0)
  959. {
  960. a.Cmd = COPY_BUFFER_HOT_KEY_1_ID;
  961. a.Key = Item.m_lCopyHotKey;
  962. m_Accels.AddAccel(a);
  963. }
  964. g_Opt.GetCopyBufferItem(1, Item);
  965. if(Item.m_lCopyHotKey > 0)
  966. {
  967. a.Cmd = COPY_BUFFER_HOT_KEY_2_ID;
  968. a.Key = Item.m_lCopyHotKey;
  969. m_Accels.AddAccel(a);
  970. }
  971. g_Opt.GetCopyBufferItem(2, Item);
  972. if(Item.m_lCopyHotKey > 0)
  973. {
  974. a.Cmd = COPY_BUFFER_HOT_KEY_3_ID;
  975. a.Key = Item.m_lCopyHotKey;
  976. m_Accels.AddAccel(a);
  977. }
  978. }
  979. void CQListCtrl::OnKillFocus(CWnd* pNewWnd)
  980. {
  981. CListCtrl::OnKillFocus(pNewWnd);
  982. // if(FocusOnToolTip() == FALSE)
  983. // m_pToolTip->Hide();
  984. }
  985. HWND CQListCtrl::GetToolTipHWnd()
  986. {
  987. return m_pToolTip->GetSafeHwnd();
  988. }
  989. BOOL CQListCtrl::SetItemCountEx(int iCount, DWORD dwFlags /* = LVSICF_NOINVALIDATEALL */)
  990. {
  991. theApp.SetStatus(NULL, TRUE);
  992. return CListCtrl::SetItemCountEx(iCount, dwFlags);
  993. }
  994. #define TIMER_SHOW_PROPERTIES 1
  995. void CQListCtrl::OnSelectionChange(NMHDR* pNMHDR, LRESULT* pResult)
  996. {
  997. NMLISTVIEW *pnmv = (NMLISTVIEW *) pNMHDR;
  998. if((pnmv->uNewState == 3) ||
  999. (pnmv->uNewState == 1))
  1000. {
  1001. if(g_Opt.m_bAllwaysShowDescription)
  1002. {
  1003. KillTimer(TIMER_SHOW_PROPERTIES);
  1004. SetTimer(TIMER_SHOW_PROPERTIES, 300, NULL);
  1005. }
  1006. if(GetSelectedCount() > 0 )
  1007. theApp.SetStatus(NULL, FALSE);
  1008. }
  1009. }
  1010. void CQListCtrl::OnTimer(UINT nIDEvent)
  1011. {
  1012. if(nIDEvent == TIMER_SHOW_PROPERTIES)
  1013. {
  1014. if( theApp.m_bShowingQuickPaste )
  1015. ShowFullDescription(true);
  1016. KillTimer(TIMER_SHOW_PROPERTIES);
  1017. }
  1018. CListCtrl::OnTimer(nIDEvent);
  1019. }
  1020. void CQListCtrl::SetLogFont(LOGFONT &font)
  1021. {
  1022. m_Font.DeleteObject();
  1023. m_Font.CreateFontIndirect(&font);
  1024. SetFont(&m_Font);
  1025. }
  1026. void CQListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  1027. {
  1028. CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
  1029. }
  1030. BOOL CQListCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  1031. {
  1032. return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
  1033. }
  1034. BOOL CQListCtrl::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
  1035. {
  1036. NMLVCACHEHINT* pcachehint = NULL;
  1037. if(message == WM_NOTIFY)
  1038. {
  1039. NMHDR* phdr = (NMHDR*)lParam;
  1040. switch(phdr->code)
  1041. {
  1042. case LVN_ODCACHEHINT:
  1043. pcachehint= (NMLVCACHEHINT*) phdr;
  1044. GetParent()->SendMessage(NM_FILL_REST_OF_LIST, pcachehint->iFrom, pcachehint->iTo);
  1045. return FALSE;
  1046. }
  1047. }
  1048. return CListCtrl::OnChildNotify(message, wParam, lParam, pLResult);
  1049. }
  1050. BOOL CQListCtrl::OnItemDeleted(long lID)
  1051. {
  1052. BOOL bRet = m_ThumbNails.RemoveKey(lID);
  1053. BOOL bRet2 = m_RTFData.RemoveKey(lID);
  1054. return (bRet || bRet2);
  1055. }