Fix typos
[TortoiseGit.git] / src / Utils / ACListWnd.cpp
blob05d5b4f950855a4bc87acc6293ab2adbf517c67a
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (c) 2003 by Andreas Kapust <info@akinstaller.de>; <http://www.codeproject.com/Articles/2607/AutoComplete-without-IAutoComplete>
4 // Copyright (C) 2009, 2012-2013, 2015-2016, 2018-2020, 2023 - TortoiseGit
6 // Licensed under: The Code Project Open License (CPOL); <http://www.codeproject.com/info/cpol10.aspx>
8 // ACWnd.cpp: Implementierungsdatei
9 //
11 #include "stdafx.h"
12 #include "ACListWnd.h"
13 #include "StringUtils.h"
14 #include "DPIAware.h"
15 #include "Theme.h"
17 #ifdef _DEBUG
18 #define new DEBUG_NEW
19 #undef THIS_FILE
20 static char THIS_FILE[] = __FILE__;
21 #endif
23 static UINT auIDStatusBar[] =
25 ID_SEPARATOR
28 #define _MAX_ENTRYS_ 8
29 #define _MODE_FIND_ALL_ (1L << 5)
31 /////////////////////////////////////////////////////////////////////////////
32 // CACListWnd
34 void DoPaintMessageLoop()
36 MSG message1;
37 while (::PeekMessage(&message1, nullptr, WM_PAINT, WM_PAINT, PM_REMOVE))
39 ::TranslateMessage(&message1);
40 ::DispatchMessage(&message1);
44 /**********************************************************************/
46 CACListWnd::CACListWnd()
48 NONCLIENTMETRICS metrics = { 0 };
49 metrics.cbSize = sizeof(NONCLIENTMETRICS);
50 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
51 m_uiFont.CreateFontIndirect(&metrics.lfMessageFont);
54 /**********************************************************************/
56 CACListWnd::~CACListWnd()
58 m_SearchList.RemoveAll();
59 m_DisplayList.RemoveAll();
60 DestroyWindow();
63 /*********************************************************************/
65 void CACListWnd::OnActivateApp(BOOL bActive, DWORD dwThreadID)
67 #if (_MSC_VER >= 1300)
68 CWnd::OnActivateApp(bActive, dwThreadID); //vc7 FIX 1.2
69 #else
70 CWnd::OnActivateApp(bActive, (HTASK)dwThreadID); //vc6 FIX 1.2
71 #endif
73 ShowWindow(false);
77 BEGIN_MESSAGE_MAP(CACListWnd, CWnd)
78 //{{AFX_MSG_MAP(CACListWnd)
79 ON_WM_PAINT()
80 ON_WM_SIZE()
81 ON_WM_ERASEBKGND()
82 ON_WM_NCPAINT()
83 ON_WM_KEYDOWN()
84 ON_WM_NCCALCSIZE()
85 ON_WM_VSCROLL()
86 ON_WM_ACTIVATEAPP()
87 ON_WM_NCHITTEST()
88 ON_WM_LBUTTONDOWN()
89 ON_WM_RBUTTONDOWN()
90 ON_WM_SETCURSOR()
91 ON_WM_SHOWWINDOW()
92 ON_WM_NCLBUTTONDOWN()
93 ON_WM_MOUSEMOVE()
94 ON_WM_TIMER()
95 ON_WM_GETMINMAXINFO()
96 //}}AFX_MSG_MAP
97 END_MESSAGE_MAP()
100 /////////////////////////////////////////////////////////////////////////////
101 // Behandlungsroutinen für Nachrichten CACListWnd
103 void CACListWnd::DrawItem(CDC* pDC,long m_lItem,long width)
105 long y = m_lItem - m_lTopIndex;
106 CRect rcLabel(2,y*m_ItemHeight,width,(y+1)*m_ItemHeight);
108 pDC->SetTextColor(CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : CTheme::Instance().GetThemeColor(::GetSysColor(COLOR_WINDOWTEXT)));
110 if(m_lItem == m_lSelItem)
112 rcLabel.left = 0;
113 pDC->FillSolidRect(rcLabel,::GetSysColor(COLOR_HIGHLIGHT));
114 pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
115 rcLabel.left = 2;
118 if(m_PrefixChar)
119 m_DisplayStr = m_PrefixChar + m_DisplayList.GetAt(m_lItem);
120 else
121 m_DisplayStr = m_DisplayList.GetAt(m_lItem);
123 pDC->DrawText(m_DisplayStr, -1, rcLabel, DT_LEFT | DT_SINGLELINE |
124 DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
127 /*********************************************************************/
129 void CACListWnd::OnPaint()
131 CPaintDC dc(this);
132 CRect rcWnd,m_rect, rc;
133 CDC MemDC, *pDC = nullptr;
134 CBitmap m_bitmap, *m_pOldBitmap;
136 GetClientRect(rc);
137 rcWnd = m_rect = rc;
139 rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL);
140 rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL);
142 m_rect.right -= ScrollBarWidth();
144 MemDC.CreateCompatibleDC(&dc);
146 m_bitmap.CreateCompatibleBitmap(&dc, m_rect.Width(), m_rect.Height());
147 m_pOldBitmap = MemDC.SelectObject(&m_bitmap);
149 MemDC.SetWindowOrg(m_rect.left, m_rect.top);
151 long width = rcWnd.Width() - ScrollBarWidth();
153 MemDC.FillSolidRect(rcWnd, CTheme::Instance().IsDarkTheme() ? CTheme::darkBkColor : CTheme::Instance().GetThemeColor(::GetSysColor(COLOR_WINDOW)));
154 MemDC.SelectObject(m_uiFont);
155 MemDC.SetBkMode(TRANSPARENT);
157 for (int i = m_lTopIndex; i < m_lCount; ++i)
159 DrawItem(&MemDC,i,width);
163 CPen m_Pen1(PS_SOLID, 1, CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : ::GetSysColor(COLOR_WINDOW));
164 CPen m_Pen2(PS_SOLID, 1, ::GetSysColor(COLOR_BTNFACE));
165 CPen m_Pen3(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));
167 pDC = &dc;
169 if(m_VertBar.IsWindowVisible())
170 dc.FillSolidRect(rc, ::GetSysColor(COLOR_BTNFACE) );
171 else
172 pDC = &MemDC;
174 CPen* pOldPen = pDC->SelectObject(&m_Pen1);
175 int a = 1,bottom;
177 width = GetSystemMetrics(SM_CXHSCROLL);
178 bottom = (rcWnd.bottom-GetSystemMetrics(SM_CXHSCROLL))-1;
180 //gripper
181 for (int i = 0; i < 20 ; ++i, ++a)
183 if(a==1)
184 pDC->SelectObject(&m_Pen1);
185 if(a==2)
186 pDC->SelectObject(&m_Pen2);
187 if(a==3)
188 pDC->SelectObject(&m_Pen3);
189 if(a > 3)
190 a = 0;
192 pDC->MoveTo(rc.left + i - 1, rcWnd.bottom);
193 pDC->LineTo(rc.left + i + width, bottom);
196 dc.BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
197 &MemDC, m_rect.left, m_rect.top, SRCCOPY);
199 pDC->SelectObject( pOldPen );
200 MemDC.SelectObject(m_pOldBitmap);
203 /*********************************************************************/
205 void CACListWnd::Init(CWnd *pWnd)
207 VERIFY(m_VertBar.Create(WS_VISIBLE|SBS_VERT|SBS_LEFTALIGN,
208 CRect(0, 0, GetSystemMetrics(SM_CYVSCROLL), CDPIAware::Instance().ScaleX(*pWnd, 100)), this, 0));
210 SetScroller();
211 m_pEditParent = static_cast<CEdit*>(pWnd);
213 m_lCount = static_cast<long>(m_DisplayList.GetSize());
214 m_VertBar.SetScrollPos(0,false);
215 SetProp();
217 CDC *m_pDC;
218 m_pDC = GetDC();
219 if(m_pDC)
221 m_pDC->SelectObject(GetStockObject(DEFAULT_GUI_FONT));
222 CSize m_Size = m_pDC->GetOutputTextExtent(L"Hg");
223 m_ItemHeight = m_Size.cy;
224 ReleaseDC(m_pDC);
228 /*********************************************************************/
230 void CACListWnd::SetScroller()
232 CRect rcWnd,rcBar;
233 GetClientRect(rcWnd);
235 if(m_VertBar.GetSafeHwnd())
237 rcBar = rcWnd;
238 rcBar.top=-1;
239 rcBar.left = (rcWnd.Width()-GetSystemMetrics(SM_CYVSCROLL));
240 rcBar.bottom-= GetSystemMetrics(SM_CYHSCROLL);
241 m_VertBar.MoveWindow(rcBar);
242 rcBar.top = rcWnd.bottom - CDPIAware::Instance().ScaleY(m_VertBar.GetSafeHwnd() , 20);
243 rcBar.bottom = rcWnd.bottom;
245 m_VertBar.SetScrollPos(m_lTopIndex,true);
249 /*********************************************************************/
251 void CACListWnd::OnSize(UINT nType, int cx, int cy)
253 CWnd::OnSize(nType, cx, cy);
254 SetScroller();
255 SetProp();
257 if(!m_LastSize.IsRectEmpty())
258 GetWindowRect(m_LastSize);
261 /*********************************************************************/
263 long CACListWnd::ScrollBarWidth()
265 if(m_VertBar.IsWindowVisible())
266 return GetSystemMetrics(SM_CYVSCROLL);
267 else
268 return 0;
271 /*********************************************************************/
273 void CACListWnd::SetProp()
275 CRect rcWnd,rcBar;
277 if(!m_lCount)
278 return;
280 CWnd::GetWindowRect(rcWnd);
281 ScreenToClient(rcWnd);
283 SCROLLINFO si;
284 si.cbSize = sizeof(SCROLLINFO);
285 si.fMask = SIF_PAGE|SIF_RANGE;
286 si.nMin = 0;
287 si.nMax = m_lCount-1;
288 m_VisibleItems = si.nPage = rcWnd.Height()/m_ItemHeight;
289 si.nTrackPos = 2;
290 m_VertBar.SetScrollRange(0,m_lCount-1);
291 m_VertBar.SetScrollInfo(&si);
293 if(m_VisibleItems > m_lCount-1)
294 m_VertBar.ShowWindow(false);
295 else
296 m_VertBar.ShowWindow(true);
298 if(m_lTopIndex+m_VisibleItems > m_lCount)
300 m_lTopIndex = m_lCount-m_VisibleItems;
301 if(m_lTopIndex < 0)
302 m_lTopIndex = 0;
303 m_VertBar.SetScrollPos(m_lTopIndex,true);
307 /*********************************************************************/
309 BOOL CACListWnd::OnEraseBkgnd(CDC* /*pDC*/)
311 return false;
314 /*********************************************************************/
316 void CACListWnd::OnNcPaint()
318 CWindowDC dc(this);
319 CRect rectClient, rectWindow,rcWnd;
321 GetClientRect(rectClient);
322 GetWindowRect(rectWindow);
323 ScreenToClient(rectWindow);
325 rectClient.OffsetRect(-(rectWindow.left), -(rectWindow.top));
326 dc.ExcludeClipRect(rectClient);
328 rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
330 dc.FillSolidRect(rectWindow, CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : CTheme::Instance().GetThemeColor(::GetSysColor(COLOR_WINDOWTEXT)));
333 /*********************************************************************/
335 void CACListWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
337 CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
339 if (nChar == VK_ESCAPE)
340 ShowWindow(false);
343 /*********************************************************************/
345 void CACListWnd::OnNcCalcSize(BOOL /*bCalcValidRects*/, NCCALCSIZE_PARAMS FAR* lpncsp)
347 ::InflateRect(lpncsp->rgrc,
348 -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
351 /*********************************************************************/
353 int CACListWnd::HitTest(CPoint point)
355 CRect rcItem;
356 CRect rcWnd;
358 GetClientRect(rcWnd);
359 long width = rcWnd.Width() - ScrollBarWidth();
361 for(int i = m_lTopIndex; i < m_lCount; i++)
363 long y = i - m_lTopIndex;
364 rcItem.SetRect(2,y*m_ItemHeight,width,(y+1)*m_ItemHeight);
366 if(PtInRect(&rcItem, point))
367 return (m_lSelItem = (y+m_lTopIndex));
370 return -1;
373 /*********************************************************************/
375 LRESULT CACListWnd::OnNcHitTest(CPoint point)
377 CRect rectClient;
378 GetWindowRect(rectClient);
380 rectClient.left = rectClient.right - GetSystemMetrics(SM_CYVSCROLL);
381 rectClient.top = rectClient.bottom - GetSystemMetrics(SM_CXVSCROLL);
383 if(rectClient.PtInRect(point))
384 return HTBOTTOMRIGHT;
385 else
386 return HTCLIENT;
389 /*********************************************************************/
391 void CACListWnd::OnLButtonDown(UINT nFlags, CPoint point)
393 CWnd::OnLButtonDown(nFlags, point);
394 int sel = HitTest(point);
396 if(sel >= 0)
398 if(!EnsureVisible(sel,true))
399 Invalidate();
400 m_lSelItem = sel;
401 m_pEditParent->SendMessage(ENAC_UPDATE, WM_KEYDOWN, GetDlgCtrlID());
402 DoPaintMessageLoop();
403 Sleep(500);
404 ShowWindow(false);
406 else
408 CRect rc;
409 GetClientRect(rc);
410 if(!rc.PtInRect(point))
411 ShowWindow(false);
415 /*********************************************************************/
417 void CACListWnd::OnRButtonDown(UINT nFlags, CPoint point)
419 CWnd::OnRButtonDown(nFlags, point);
420 ShowWindow(false);
423 /*********************************************************************/
425 BOOL CACListWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
427 CRect rectClient;
428 CPoint ptCursor;
430 GetWindowRect(rectClient);
431 ScreenToClient(&rectClient);
433 rectClient.left = rectClient.right - GetSystemMetrics(SM_CYVSCROLL);
434 rectClient.top = rectClient.bottom - GetSystemMetrics(SM_CXVSCROLL);
437 GetCursorPos(&ptCursor);
438 ScreenToClient(&ptCursor);
440 if(rectClient.PtInRect(ptCursor)) // Vergrößerungs-Cursor
442 return CWnd::OnSetCursor(pWnd, nHitTest, message);
445 ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
446 return TRUE;
449 /*********************************************************************/
451 void CACListWnd::InvalidateAndScroll()
453 m_VertBar.SetScrollPos(m_lTopIndex,true);
454 Invalidate();
455 DoPaintMessageLoop();
458 /*********************************************************************/
460 bool CACListWnd::EnsureVisible(int item, bool m_bWait)
462 if(item > m_lTopIndex && item < m_lTopIndex + m_VisibleItems)
463 return false; // ist visible
465 if(item > m_lTopIndex) // scroll down
467 long m_len = item;
468 for(int i = m_lTopIndex; i < m_len; i++)
470 if(i >= m_lCount-m_VisibleItems)
471 break;
472 if(i >= m_lCount-m_VisibleItems || i + m_VisibleItems > item)
474 break;
477 m_lTopIndex++;
479 if(m_bWait)
481 InvalidateAndScroll();
482 Sleep(10);
483 DoPaintMessageLoop();
486 InvalidateAndScroll();
487 return true;
490 if(item < m_lTopIndex) // scroll up
492 while(item < m_lTopIndex)
494 if(m_lTopIndex > 0)
495 m_lTopIndex--;
496 else
498 break;
501 if(m_bWait)
503 InvalidateAndScroll();
504 Sleep(10);
505 DoPaintMessageLoop();
509 InvalidateAndScroll();
510 return true;
513 return false;
516 /*********************************************************************/
518 bool CACListWnd::SelectItem(int item)
520 if(item > m_lCount)
521 return false;
523 if(item == -1)
525 EnsureVisible(m_lSelItem,false);
526 Invalidate();
527 return false;
530 m_lSelItem = item;
532 if(!EnsureVisible(item,true))
533 Invalidate();
535 return true;
538 /*********************************************************************/
540 int CACListWnd::FindStringExact( int nStartAfter, LPCWSTR lpszString )
542 if(nStartAfter > m_SearchList.GetSize())
543 return -1;
545 for(int i = nStartAfter+1; i < m_SearchList.GetSize(); i++)
546 if(m_SearchList.GetAt(i).Compare(lpszString) == 0)
547 return i;
548 return -1;
551 /*********************************************************************/
553 ** Vers. 1.1
554 * NEW: m_bDisplayOnly
556 int CACListWnd::FindString(int nStartAfter, LPCWSTR lpszString, bool m_bDisplayOnly)
558 long m_AktCount = static_cast<long>(m_DisplayList.GetSize());
560 if(!m_bDisplayOnly)
562 CString m_Str1,m_Str2 = lpszString;
563 if(!m_pEditParent)
565 ShowWindow(false);
566 return -1;
569 if(nStartAfter > m_SearchList.GetSize())
571 ShowWindow(false);
572 return -1;
575 if(m_Str2.IsEmpty())
577 ShowWindow(false);
578 return -1;
581 m_DisplayList.RemoveAll();
583 m_Str2.MakeUpper();
585 for(int i = nStartAfter+1; i < m_SearchList.GetSize(); i++)
587 if(m_PrefixChar)
588 m_Str1 = m_PrefixChar;
589 else
590 m_Str1.Empty();
592 m_Str1 += m_SearchList.GetAt(i);
594 m_Str1.MakeUpper();
596 if(m_lMode & _MODE_FIND_ALL_)
598 if(m_Str1.Find(m_Str2) >= 0)
600 m_DisplayList.Add(m_SearchList.GetAt(i));
603 else // _MODE_FIND_EXACT_
605 if (CStringUtils::StartsWith(m_Str1, m_Str2))
607 m_DisplayList.Add(m_SearchList.GetAt(i));
612 m_lCount = static_cast<long>(m_DisplayList.GetSize());
614 if(m_lCount)
616 CRect rcWnd;
617 int iHeight,iWight;
619 m_pEditParent->GetWindowRect(rcWnd);
621 SetScroller();
622 SetProp();
624 ShowWindow(true);
625 Invalidate();
627 iHeight = m_lCount*m_ItemHeight+(GetSystemMetrics(SM_CYBORDER)*2);
629 if(m_lCount > _MAX_ENTRYS_)
630 iHeight = _MAX_ENTRYS_*m_ItemHeight+(GetSystemMetrics(SM_CYBORDER)*2);
632 if(!m_LastSize.IsRectEmpty())
634 iWight = m_LastSize.Width();
635 iHeight = m_LastSize.Height();
636 rcWnd.top += rcWnd.Height();
637 rcWnd.right = rcWnd.left+iWight;
638 rcWnd.bottom = rcWnd.top+iHeight;
640 SetWindowPos(&CWnd::wndTopMost, rcWnd.left,
641 rcWnd.top,
642 rcWnd.Width(),
643 rcWnd.Height(), 0);
645 else
647 SetWindowPos(&CWnd::wndTopMost, rcWnd.left,
648 rcWnd.top + rcWnd.Height(),
649 rcWnd.Width(),
650 iHeight, 0);
653 if(m_AktCount != m_DisplayList.GetSize())
654 m_lSelItem = -1;
656 SortList(m_DisplayList);
658 else
660 ShowWindow(false);
663 return 1;
666 /*********************************************************************/
668 int CACListWnd::SelectString(LPCWSTR lpszString )
670 int item = FindString(-1, lpszString);
671 SelectItem(item);
672 return item;
675 /*********************************************************************/
677 bool CACListWnd::GetText(int item, CString& m_Text)
679 if(item < 0 || item > m_SearchList.GetSize())
680 return false;
681 m_Text = m_SearchList.GetAt(item);
682 return true;
685 /*********************************************************************/
687 void CACListWnd::OnShowWindow(BOOL bShow, UINT nStatus)
689 if(bShow)
691 m_nIDTimer = static_cast<long>(SetTimer(IDTimerInstall, 200, nullptr));
692 m_pEditParent->GetParent()->GetWindowRect(m_ParentRect);
694 else
696 if(m_nIDTimer)
697 KillTimer(IDTimerInstall);
698 m_nIDTimer = 0;
699 m_lSelItem = -1;
700 m_lTopIndex = 0;
703 CWnd::OnShowWindow(bShow, nStatus);
704 ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
707 /*********************************************************************/
709 void CACListWnd::OnNcLButtonDown(UINT nHitTest, CPoint point)
711 if(OnNcHitTest(point) == HTBOTTOMRIGHT)
712 GetWindowRect(m_LastSize);
713 CWnd::OnNcLButtonDown(nHitTest, point);
716 /*********************************************************************/
718 CString CACListWnd::GetString()
720 int i = static_cast<int>(m_DisplayList.GetSize());
722 if(!i)
723 return L"";
724 if(i <= m_lSelItem || m_lSelItem == -1)
725 i = 0;
726 else
727 i = m_lSelItem;
729 return m_DisplayList.GetAt(i);
732 /*********************************************************************/
734 void CACListWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
736 CWnd::OnVScroll(nSBCode, nPos, pScrollBar);
737 long m_oldlTopIndex = m_lTopIndex;
739 switch(nSBCode)
741 case SB_ENDSCROLL:
742 break;
744 case SB_PAGEUP:
745 m_lTopIndex -= m_VisibleItems;
746 if(m_lTopIndex < 0)
747 m_lTopIndex = 0;
748 break;
750 case SB_PAGEDOWN:
751 m_lTopIndex += m_VisibleItems;
752 if(m_lTopIndex >= m_lCount-m_VisibleItems)
753 m_lTopIndex = m_lCount-m_VisibleItems;
754 break;
756 case SB_LINEUP:
757 m_lTopIndex--;
758 if(m_lTopIndex < 0)
759 m_lTopIndex = 0;
760 break;
762 case SB_LINEDOWN:
763 m_lTopIndex++;
764 if(m_lTopIndex >= m_lCount-m_VisibleItems)
765 m_lTopIndex = m_lCount-m_VisibleItems;
766 break;
768 case SB_THUMBTRACK:
769 m_lTopIndex = nPos;
770 break;
773 m_VertBar.SetScrollPos(m_lTopIndex,true);
775 if(m_oldlTopIndex != m_lTopIndex)
776 Invalidate();
779 /*********************************************************************/
781 CString CACListWnd::GetNextString(int nChar)
783 switch(nChar)
785 case VK_DOWN:
786 m_lSelItem++;
787 break;
789 case VK_UP:
790 m_lSelItem--;
791 break;
793 case VK_PRIOR:
794 m_lSelItem -= m_VisibleItems;
795 if(m_lSelItem < 0)
796 m_lSelItem = 0;
797 break;
799 case VK_NEXT:
800 m_lSelItem += m_VisibleItems;
801 if(m_lSelItem >= m_lCount-1)
802 m_lSelItem = m_lCount-1;
803 break;
805 case VK_HOME:
806 m_lSelItem = 0;
807 break;
809 case VK_END:
810 m_lSelItem = m_lCount-1;
811 break;
814 if(m_lSelItem < 0)
815 m_lSelItem = m_lCount-1;
817 if(m_lSelItem >= m_lCount)
818 m_lSelItem = 0;
820 if(EnsureVisible(m_lSelItem,(m_lCount > 50) ? false : true))
821 InvalidateAndScroll();
823 return GetString();
826 /*********************************************************************/
828 void CACListWnd::OnMouseMove(UINT nFlags, CPoint point)
830 CWnd::OnMouseMove(nFlags, point);
831 int sel = HitTest(point);
832 if(sel >= 0)
834 Invalidate();
838 /*********************************************************************/
840 void CACListWnd::OnTimer(UINT_PTR nIDEvent)
842 CWnd::OnTimer(nIDEvent);
844 CRect m_ParentRect1;
845 m_pEditParent->GetParent()->GetWindowRect(m_ParentRect1);
846 if(!m_ParentRect1.EqualRect(m_ParentRect))
847 ShowWindow(false);
850 /*********************************************************************/
852 void CACListWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
854 if(GetSafeHwnd())
856 // Vers. 1.2
857 long m_lMinY1 = GetSystemMetrics(SM_CYHSCROLL)*2 + GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CXHTHUMB),
858 m_lMinY2 = m_lCount * m_ItemHeight + (GetSystemMetrics(SM_CYBORDER)*2);
860 if(m_VisibleItems > m_lCount-1 && m_lMinY2 < m_lMinY1)
861 lpMMI->ptMinTrackSize.y = m_lMinY2;
862 else
863 lpMMI->ptMinTrackSize.y = m_lMinY1;
864 //---------
866 lpMMI->ptMinTrackSize.x = GetSystemMetrics(SM_CXHSCROLL)*4;
869 // Vers. 1.2
870 if (m_pEditParent)
872 RECT rc;
873 m_pEditParent->GetWindowRect (&rc);
874 lpMMI->ptMinTrackSize.x = rc.right - rc.left;
877 else
878 CWnd::OnGetMinMaxInfo(lpMMI);
881 /*********************************************************************/
883 int CACListWnd::CompareString(const void* p1, const void* p2)
885 return _stricmp( * ( char** ) p1, * ( char** ) p2 );
888 /*********************************************************************/
890 void CACListWnd::SortList(CStringArray& list)
892 int m_Count = static_cast<int>(list.GetSize());
894 if (m_Count > 1)
896 CStringArray m_Liste1;
897 m_Liste1.Copy(list);
899 LPCWSTR* ppSortArray = new LPCWSTR[m_Count+1];
902 for (int i = 0; i < m_Count; ++i)
904 ppSortArray[i] = static_cast<LPCWSTR>(m_Liste1.GetAt(i));
907 list.RemoveAll();
909 qsort(ppSortArray, m_Count, sizeof(LPCWSTR), CompareString);
911 for (int i = 0; i < m_Count; ++i)
913 list.Add(static_cast<LPCWSTR>(ppSortArray[i]));
915 m_Liste1.RemoveAll();
916 delete [] ppSortArray;
920 /*********************************************************************/
922 ** Vers. 1.1
923 ** NEW: CopyList()
925 void CACListWnd::CopyList()
927 m_DisplayList.Copy(m_SearchList);
928 m_lCount = static_cast<long>(m_DisplayList.GetSize());
929 if(m_lCount)
930 FindString(0, L"", true);
933 /*********************************************************************/