QListCtrl.cpp 29 KB

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