QListCtrl.cpp 31 KB

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