Search ssh executable on the PATH configured in TortoiseGit
[TortoiseGit.git] / src / Utils / ACListWnd.cpp
blob16fa7bfcbe67a61077086277115b163161c408a1
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 - 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"
14 #ifdef _DEBUG
15 #define new DEBUG_NEW
16 #undef THIS_FILE
17 static char THIS_FILE[] = __FILE__;
18 #endif
20 static UINT auIDStatusBar[] =
22 ID_SEPARATOR
25 #define _MAX_ENTRYS_ 8
26 #define _MODE_FIND_ALL_ (1L << 5)
28 /////////////////////////////////////////////////////////////////////////////
29 // CACListWnd
31 void DoPaintMessageLoop()
33 MSG message1;
34 while(::PeekMessage(&message1,NULL,WM_PAINT,WM_PAINT, PM_REMOVE))
36 ::TranslateMessage(&message1);
37 ::DispatchMessage(&message1);
41 /**********************************************************************/
43 CACListWnd::CACListWnd()
45 m_lTopIndex = 0;
46 m_lCount = 0;
47 m_ItemHeight = 16;
48 m_lSelItem = -1;
49 m_VisibleItems = 0;
50 m_pEditParent = NULL;
51 m_LastSize.SetRectEmpty();
52 m_PrefixChar = 0;
53 m_lMode = 0;
54 pFontDC = NULL;
55 m_nIDTimer = 0;
56 SecureZeroMemory(&logfont, sizeof(LOGFONT));
59 /**********************************************************************/
61 CACListWnd::~CACListWnd()
63 m_SearchList.RemoveAll();
64 m_DisplayList.RemoveAll();
65 DestroyWindow();
68 /*********************************************************************/
70 void CACListWnd::OnActivateApp(BOOL bActive, DWORD dwThreadID)
72 #if (_MSC_VER >= 1300)
73 CWnd::OnActivateApp(bActive, dwThreadID); //vc7 FIX 1.2
74 #else
75 CWnd::OnActivateApp(bActive, (HTASK)dwThreadID); //vc6 FIX 1.2
76 #endif
78 ShowWindow(false);
82 BEGIN_MESSAGE_MAP(CACListWnd, CWnd)
83 //{{AFX_MSG_MAP(CACListWnd)
84 ON_WM_PAINT()
85 ON_WM_SIZE()
86 ON_WM_ERASEBKGND()
87 ON_WM_NCPAINT()
88 ON_WM_KEYDOWN()
89 ON_WM_NCCALCSIZE()
90 ON_WM_VSCROLL()
91 ON_WM_ACTIVATEAPP()
92 ON_WM_NCHITTEST()
93 ON_WM_LBUTTONDOWN()
94 ON_WM_RBUTTONDOWN()
95 ON_WM_SETCURSOR()
96 ON_WM_SHOWWINDOW()
97 ON_WM_NCLBUTTONDOWN()
98 ON_WM_MOUSEMOVE()
99 ON_WM_TIMER()
100 ON_WM_GETMINMAXINFO()
101 //}}AFX_MSG_MAP
102 END_MESSAGE_MAP()
105 /////////////////////////////////////////////////////////////////////////////
106 // Behandlungsroutinen für Nachrichten CACListWnd
108 void CACListWnd::DrawItem(CDC* pDC,long m_lItem,long width)
110 long y = m_lItem - m_lTopIndex;
111 CRect rcLabel(2,y*m_ItemHeight,width,(y+1)*m_ItemHeight);
113 pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
115 if(m_lItem == m_lSelItem)
117 rcLabel.left = 0;
118 pDC->FillSolidRect(rcLabel,::GetSysColor(COLOR_HIGHLIGHT));
119 pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
120 rcLabel.left = 2;
123 if(m_PrefixChar)
124 m_DisplayStr = m_PrefixChar + m_DisplayList.GetAt(m_lItem);
125 else
126 m_DisplayStr = m_DisplayList.GetAt(m_lItem);
128 pDC->DrawText(m_DisplayStr, -1, rcLabel, DT_LEFT | DT_SINGLELINE |
129 DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS);
132 /*********************************************************************/
134 void CACListWnd::OnPaint()
136 CPaintDC dc(this);
137 CRect rcWnd,m_rect, rc;
138 CDC MemDC,*pDC=NULL;
139 CBitmap m_bitmap, *m_pOldBitmap;
140 int i;
142 GetClientRect(rc);
143 rcWnd = m_rect = rc;
145 rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL);
146 rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL);
148 m_rect.right -= ScrollBarWidth();
150 MemDC.CreateCompatibleDC(&dc);
152 m_bitmap.CreateCompatibleBitmap(&dc, m_rect.Width(), m_rect.Height());
153 m_pOldBitmap = MemDC.SelectObject(&m_bitmap);
155 MemDC.SetWindowOrg(m_rect.left, m_rect.top);
157 long width = rcWnd.Width() - ScrollBarWidth();
159 MemDC.FillSolidRect(rcWnd,::GetSysColor(COLOR_WINDOW));
160 MemDC.SelectObject(GetStockObject(DEFAULT_GUI_FONT));
161 MemDC.SetBkMode(TRANSPARENT);
163 for(i = m_lTopIndex; i < m_lCount;i++)
165 DrawItem(&MemDC,i,width);
169 CPen m_Pen1(PS_SOLID, 1, ::GetSysColor(COLOR_WINDOW));
170 CPen m_Pen2(PS_SOLID, 1, ::GetSysColor(COLOR_BTNFACE));
171 CPen m_Pen3(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));
173 pDC = &dc;
175 if(m_VertBar.IsWindowVisible())
176 dc.FillSolidRect(rc, ::GetSysColor(COLOR_BTNFACE) );
177 else
178 pDC = &MemDC;
180 CPen *pOldPen = (CPen*)pDC->SelectObject(&m_Pen1);
181 int a = 1,bottom;
183 width = GetSystemMetrics(SM_CXHSCROLL);
184 bottom = (rcWnd.bottom-GetSystemMetrics(SM_CXHSCROLL))-1;
186 //gripper
187 for( i = 0; i < 20 ;i++,a++)
189 if(a==1)
190 pDC->SelectObject(&m_Pen1);
191 if(a==2)
192 pDC->SelectObject(&m_Pen2);
193 if(a==3)
194 pDC->SelectObject(&m_Pen3);
195 if(a > 3)
196 a = 0;
198 pDC->MoveTo(rc.left + i - 1, rcWnd.bottom);
199 pDC->LineTo(rc.left + i + width, bottom);
202 dc.BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
203 &MemDC, m_rect.left, m_rect.top, SRCCOPY);
205 pDC->SelectObject( pOldPen );
206 MemDC.SelectObject(m_pOldBitmap);
209 /*********************************************************************/
211 void CACListWnd::Init(CWnd *pWnd)
213 VERIFY(m_VertBar.Create(WS_VISIBLE|SBS_VERT|SBS_LEFTALIGN,
214 CRect(0,0,GetSystemMetrics(SM_CYVSCROLL),100),this,0));
216 SetScroller();
217 m_pEditParent = (CEdit*)pWnd;
219 m_lCount = (long)m_DisplayList.GetSize();
220 m_VertBar.SetScrollPos(0,false);
221 SetProp();
223 CDC *m_pDC;
224 m_pDC = GetDC();
225 if(m_pDC)
227 m_pDC->SelectObject(GetStockObject(DEFAULT_GUI_FONT));
228 CSize m_Size = m_pDC->GetOutputTextExtent(_T("Hg"));
229 m_ItemHeight = m_Size.cy;
230 ReleaseDC(m_pDC);
234 /*********************************************************************/
236 void CACListWnd::SetScroller()
238 CRect rcWnd,rcBar;
239 GetClientRect(rcWnd);
241 if(m_VertBar.GetSafeHwnd())
243 rcBar = rcWnd;
244 rcBar.top=-1;
245 rcBar.left = (rcWnd.Width()-GetSystemMetrics(SM_CYVSCROLL));
246 rcBar.bottom-= GetSystemMetrics(SM_CYHSCROLL);
247 m_VertBar.MoveWindow(rcBar);
248 rcBar.top = rcWnd.bottom-20;
249 rcBar.bottom = rcWnd.bottom;
251 m_VertBar.SetScrollPos(m_lTopIndex,true);
256 /*********************************************************************/
258 void CACListWnd::OnSize(UINT nType, int cx, int cy)
260 CWnd::OnSize(nType, cx, cy);
261 SetScroller();
262 SetProp();
264 if(!m_LastSize.IsRectEmpty())
265 GetWindowRect(m_LastSize);
268 /*********************************************************************/
270 long CACListWnd::ScrollBarWidth()
272 if(m_VertBar.IsWindowVisible())
273 return GetSystemMetrics(SM_CYVSCROLL);
274 else
275 return 0;
278 /*********************************************************************/
280 void CACListWnd::SetProp()
282 CRect rcWnd,rcBar;
284 if(!m_lCount)
285 return;
287 CWnd::GetWindowRect(rcWnd);
288 ScreenToClient(rcWnd);
290 SCROLLINFO si;
291 si.cbSize = sizeof(SCROLLINFO);
292 si.fMask = SIF_PAGE|SIF_RANGE;
293 si.nMin = 0;
294 si.nMax = m_lCount-1;
295 m_VisibleItems = si.nPage = rcWnd.Height()/m_ItemHeight;
296 si.nTrackPos = 2;
297 m_VertBar.SetScrollRange(0,m_lCount-1);
298 m_VertBar.SetScrollInfo(&si);
300 if(m_VisibleItems > m_lCount-1)
301 m_VertBar.ShowWindow(false);
302 else
303 m_VertBar.ShowWindow(true);
305 if(m_lTopIndex+m_VisibleItems > m_lCount)
307 m_lTopIndex = m_lCount-m_VisibleItems;
308 if(m_lTopIndex < 0)
309 m_lTopIndex = 0;
310 m_VertBar.SetScrollPos(m_lTopIndex,true);
314 /*********************************************************************/
316 BOOL CACListWnd::OnEraseBkgnd(CDC* /*pDC*/)
318 return false;
321 /*********************************************************************/
323 void CACListWnd::OnNcPaint()
325 CWindowDC dc(this);
326 CRect rectClient, rectWindow,rcWnd;
328 GetClientRect(rectClient);
329 GetWindowRect(rectWindow);
330 ScreenToClient(rectWindow);
332 rectClient.OffsetRect(-(rectWindow.left), -(rectWindow.top));
333 dc.ExcludeClipRect(rectClient);
335 rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
337 dc.FillSolidRect(rectWindow,::GetSysColor(COLOR_WINDOWTEXT));
340 /*********************************************************************/
342 void CACListWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
344 CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
346 if (nChar == VK_ESCAPE)
347 ShowWindow(false);
350 /*********************************************************************/
352 void CACListWnd::OnNcCalcSize(BOOL /*bCalcValidRects*/, NCCALCSIZE_PARAMS FAR* lpncsp)
354 ::InflateRect(lpncsp->rgrc,
355 -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
358 /*********************************************************************/
360 int CACListWnd::HitTest(CPoint point)
362 CRect rcItem;
363 CRect rcWnd;
365 GetClientRect(rcWnd);
366 long width = rcWnd.Width() - ScrollBarWidth();
368 for(int i = m_lTopIndex; i < m_lCount; i++)
370 long y = i - m_lTopIndex;
371 rcItem.SetRect(2,y*m_ItemHeight,width,(y+1)*m_ItemHeight);
373 if(PtInRect(&rcItem, point))
374 return (m_lSelItem = (y+m_lTopIndex));
377 return -1;
380 /*********************************************************************/
382 LRESULT CACListWnd::OnNcHitTest(CPoint point)
384 CRect rectClient;
385 GetWindowRect(rectClient);
387 rectClient.left = rectClient.right - GetSystemMetrics(SM_CYVSCROLL);
388 rectClient.top = rectClient.bottom - GetSystemMetrics(SM_CXVSCROLL);
390 if(rectClient.PtInRect(point))
391 return HTBOTTOMRIGHT;
392 else
393 return HTCLIENT;
396 /*********************************************************************/
398 void CACListWnd::OnLButtonDown(UINT nFlags, CPoint point)
400 CWnd::OnLButtonDown(nFlags, point);
401 int sel = HitTest(point);
403 if(sel >= 0)
405 if(!EnsureVisible(sel,true))
406 Invalidate();
407 m_lSelItem = sel;
408 m_pEditParent->SendMessage(ENAC_UPDATE, WM_KEYDOWN, GetDlgCtrlID());
409 DoPaintMessageLoop();
410 Sleep(500);
411 ShowWindow(false);
413 else
415 CRect rc;
416 GetClientRect(rc);
417 if(!rc.PtInRect(point))
418 ShowWindow(false);
422 /*********************************************************************/
424 void CACListWnd::OnRButtonDown(UINT nFlags, CPoint point)
426 CWnd::OnRButtonDown(nFlags, point);
427 ShowWindow(false);
430 /*********************************************************************/
432 BOOL CACListWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
434 CRect rectClient;
435 CPoint ptCursor;
437 GetWindowRect(rectClient);
438 ScreenToClient(&rectClient);
440 rectClient.left = rectClient.right - GetSystemMetrics(SM_CYVSCROLL);
441 rectClient.top = rectClient.bottom - GetSystemMetrics(SM_CXVSCROLL);
444 GetCursorPos(&ptCursor);
445 ScreenToClient(&ptCursor);
447 if(rectClient.PtInRect(ptCursor)) // Vergrößerungs-Cursor
449 return CWnd::OnSetCursor(pWnd, nHitTest, message);
452 ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
453 return TRUE;
456 /*********************************************************************/
458 void CACListWnd::InvalidateAndScroll()
460 m_VertBar.SetScrollPos(m_lTopIndex,true);
461 Invalidate();
462 DoPaintMessageLoop();
465 /*********************************************************************/
467 bool CACListWnd::EnsureVisible(int item, bool m_bWait)
469 if(item > m_lTopIndex && item < m_lTopIndex + m_VisibleItems)
470 return false; // ist visible
472 if(item > m_lTopIndex) // scroll down
474 long m_len = item;
475 for(int i = m_lTopIndex; i < m_len; i++)
477 if(i >= m_lCount-m_VisibleItems)
478 break;
479 if(i >= m_lCount-m_VisibleItems || i + m_VisibleItems > item)
481 break;
484 m_lTopIndex++;
486 if(m_bWait)
488 InvalidateAndScroll();
489 Sleep(10);
490 DoPaintMessageLoop();
493 InvalidateAndScroll();
494 return true;
497 if(item < m_lTopIndex) // scroll up
499 while(item < m_lTopIndex)
501 if(m_lTopIndex > 0)
502 m_lTopIndex--;
503 else
505 break;
508 if(m_bWait)
510 InvalidateAndScroll();
511 Sleep(10);
512 DoPaintMessageLoop();
516 InvalidateAndScroll();
517 return true;
520 return false;
523 /*********************************************************************/
525 bool CACListWnd::SelectItem(int item)
527 if(item > m_lCount)
528 return false;
530 if(item == -1)
532 EnsureVisible(m_lSelItem,false);
533 Invalidate();
534 return false;
537 m_lSelItem = item;
539 if(!EnsureVisible(item,true))
540 Invalidate();
542 return true;
545 /*********************************************************************/
547 int CACListWnd::FindStringExact( int nStartAfter, LPCTSTR lpszString )
549 if(nStartAfter > m_SearchList.GetSize())
550 return -1;
552 for(int i = nStartAfter+1; i < m_SearchList.GetSize(); i++)
553 if(m_SearchList.GetAt(i).Compare(lpszString) == 0)
554 return i;
555 return -1;
558 /*********************************************************************/
560 ** Vers. 1.1
561 * NEW: m_bDisplayOnly
563 int CACListWnd::FindString(int nStartAfter, LPCTSTR lpszString, bool m_bDisplayOnly)
565 long m_AktCount = (long)m_DisplayList.GetSize();
567 if(!m_bDisplayOnly)
569 CString m_Str1,m_Str2 = lpszString;
570 if(!m_pEditParent)
572 ShowWindow(false);
573 return -1;
576 if(nStartAfter > m_SearchList.GetSize())
578 ShowWindow(false);
579 return -1;
582 if(m_Str2.IsEmpty())
584 ShowWindow(false);
585 return -1;
588 m_DisplayList.RemoveAll();
590 m_Str2.MakeUpper();
592 for(int i = nStartAfter+1; i < m_SearchList.GetSize(); i++)
594 if(m_PrefixChar)
595 m_Str1 = m_PrefixChar;
596 else
597 m_Str1 = _T("");
599 m_Str1 += m_SearchList.GetAt(i);
601 m_Str1.MakeUpper();
603 if(m_lMode & _MODE_FIND_ALL_)
605 if(m_Str1.Find(m_Str2) >= 0)
607 m_DisplayList.Add(m_SearchList.GetAt(i));
610 else // _MODE_FIND_EXACT_
612 if(m_Str1.Find(m_Str2) == 0)
614 m_DisplayList.Add(m_SearchList.GetAt(i));
619 m_lCount = (long)m_DisplayList.GetSize();
621 if(m_lCount)
623 CRect rcWnd;
624 int iHeight,iWight;
626 m_pEditParent->GetWindowRect(rcWnd);
628 SetScroller();
629 SetProp();
631 ShowWindow(true);
632 Invalidate();
634 iHeight = m_lCount*m_ItemHeight+(GetSystemMetrics(SM_CYBORDER)*2);
636 if(m_lCount > _MAX_ENTRYS_)
637 iHeight = _MAX_ENTRYS_*m_ItemHeight+(GetSystemMetrics(SM_CYBORDER)*2);
639 if(!m_LastSize.IsRectEmpty())
641 iWight = m_LastSize.Width();
642 iHeight = m_LastSize.Height();
643 rcWnd.top += rcWnd.Height();
644 rcWnd.right = rcWnd.left+iWight;
645 rcWnd.bottom = rcWnd.top+iHeight;
647 SetWindowPos(&CWnd::wndTopMost, rcWnd.left,
648 rcWnd.top,
649 rcWnd.Width(),
650 rcWnd.Height(), 0);
652 else
654 SetWindowPos(&CWnd::wndTopMost, rcWnd.left,
655 rcWnd.top + rcWnd.Height(),
656 rcWnd.Width(),
657 iHeight, 0);
660 if(m_AktCount != m_DisplayList.GetSize())
661 m_lSelItem = -1;
663 SortList(m_DisplayList);
665 else
667 ShowWindow(false);
670 return 1;
673 /*********************************************************************/
675 int CACListWnd::SelectString(LPCTSTR lpszString )
677 int item = FindString(-1, lpszString);
678 SelectItem(item);
679 return item;
682 /*********************************************************************/
684 bool CACListWnd::GetText(int item, CString& m_Text)
686 if(item < 0 || item > m_SearchList.GetSize())
687 return false;
688 m_Text = m_SearchList.GetAt(item);
689 return true;
692 /*********************************************************************/
694 void CACListWnd::OnShowWindow(BOOL bShow, UINT nStatus)
696 if(bShow)
698 m_nIDTimer = (long)SetTimer( IDTimerInstall, 200, NULL);
699 m_pEditParent->GetParent()->GetWindowRect(m_ParentRect);
701 else
703 if(m_nIDTimer)
704 KillTimer(IDTimerInstall);
705 m_nIDTimer = 0;
706 m_lSelItem = -1;
707 m_lTopIndex = 0;
710 CWnd::OnShowWindow(bShow, nStatus);
711 ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
714 /*********************************************************************/
716 void CACListWnd::OnNcLButtonDown(UINT nHitTest, CPoint point)
719 if(OnNcHitTest(point) == HTBOTTOMRIGHT)
720 GetWindowRect(m_LastSize);
721 CWnd::OnNcLButtonDown(nHitTest, point);
724 /*********************************************************************/
726 CString CACListWnd::GetString()
728 int i = (int)m_DisplayList.GetSize();
730 if(!i)
731 return _T("");
732 if(i <= m_lSelItem || m_lSelItem == -1)
733 i = 0;
734 else
735 i = m_lSelItem;
737 return m_DisplayList.GetAt(i);
740 /*********************************************************************/
742 void CACListWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
744 CWnd::OnVScroll(nSBCode, nPos, pScrollBar);
745 long m_oldlTopIndex = m_lTopIndex;
747 switch(nSBCode)
749 case SB_ENDSCROLL:
750 break;
752 case SB_PAGEUP:
753 m_lTopIndex -= m_VisibleItems;
754 if(m_lTopIndex < 0)
755 m_lTopIndex = 0;
756 break;
758 case SB_PAGEDOWN:
759 m_lTopIndex += m_VisibleItems;
760 if(m_lTopIndex >= m_lCount-m_VisibleItems)
761 m_lTopIndex = m_lCount-m_VisibleItems;
762 break;
764 case SB_LINEUP:
765 m_lTopIndex--;
766 if(m_lTopIndex < 0)
767 m_lTopIndex = 0;
768 break;
770 case SB_LINEDOWN:
771 m_lTopIndex++;
772 if(m_lTopIndex >= m_lCount-m_VisibleItems)
773 m_lTopIndex = m_lCount-m_VisibleItems;
774 break;
776 case SB_THUMBTRACK:
777 m_lTopIndex = nPos;
778 break;
781 m_VertBar.SetScrollPos(m_lTopIndex,true);
783 if(m_oldlTopIndex != m_lTopIndex)
784 Invalidate();
787 /*********************************************************************/
789 CString CACListWnd::GetNextString(int nChar)
791 switch(nChar)
793 case VK_DOWN:
794 m_lSelItem++;
795 break;
797 case VK_UP:
798 m_lSelItem--;
799 break;
801 case VK_PRIOR:
802 m_lSelItem -= m_VisibleItems;
803 if(m_lSelItem < 0)
804 m_lSelItem = 0;
805 break;
807 case VK_NEXT:
808 m_lSelItem += m_VisibleItems;
809 if(m_lSelItem >= m_lCount-1)
810 m_lSelItem = m_lCount-1;
811 break;
813 case VK_HOME:
814 m_lSelItem = 0;
815 break;
817 case VK_END:
818 m_lSelItem = m_lCount-1;
819 break;
822 if(m_lSelItem < 0)
823 m_lSelItem = m_lCount-1;
825 if(m_lSelItem >= m_lCount)
826 m_lSelItem = 0;
828 if(EnsureVisible(m_lSelItem,(m_lCount > 50) ? false : true))
829 InvalidateAndScroll();
831 return GetString();
834 /*********************************************************************/
836 void CACListWnd::OnMouseMove(UINT nFlags, CPoint point)
838 CWnd::OnMouseMove(nFlags, point);
839 int sel = HitTest(point);
840 if(sel >= 0)
842 Invalidate();
846 /*********************************************************************/
848 void CACListWnd::OnTimer(UINT_PTR nIDEvent)
850 CWnd::OnTimer(nIDEvent);
852 CRect m_ParentRect1;
853 m_pEditParent->GetParent()->GetWindowRect(m_ParentRect1);
854 if(!m_ParentRect1.EqualRect(m_ParentRect))
855 ShowWindow(false);
858 /*********************************************************************/
860 void CACListWnd::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
862 if(GetSafeHwnd())
864 // Vers. 1.2
865 long m_lMinY1 = GetSystemMetrics(SM_CYHSCROLL)*2 + GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CXHTHUMB),
866 m_lMinY2 = m_lCount * m_ItemHeight + (GetSystemMetrics(SM_CYBORDER)*2);
868 if(m_VisibleItems > m_lCount-1 && m_lMinY2 < m_lMinY1)
869 lpMMI->ptMinTrackSize.y = m_lMinY2;
870 else
871 lpMMI->ptMinTrackSize.y = m_lMinY1;
872 //---------
874 lpMMI->ptMinTrackSize.x = GetSystemMetrics(SM_CXHSCROLL)*4;
877 // Vers. 1.2
878 if(m_pEditParent != NULL)
880 RECT rc;
881 m_pEditParent->GetWindowRect (&rc);
882 lpMMI->ptMinTrackSize.x = rc.right - rc.left;
885 else
886 CWnd::OnGetMinMaxInfo(lpMMI);
889 /*********************************************************************/
891 int CACListWnd::CompareString(const void* p1, const void* p2)
893 return _stricmp( * ( char** ) p1, * ( char** ) p2 );
896 /*********************************************************************/
898 void CACListWnd::SortList(CStringArray& m_List)
900 int m_Count = (int)m_List.GetSize();
901 int i;
903 if (m_Count > 1)
905 CStringArray m_Liste1;
906 m_Liste1.Copy(m_List);
908 LPCTSTR* ppSortArray = new LPCTSTR[m_Count+1];
911 for(i=0; i < m_Count; i++)
913 ppSortArray[i] = (LPCTSTR)m_Liste1.GetAt(i);
916 m_List.RemoveAll();
918 qsort(ppSortArray, m_Count, sizeof(LPCTSTR), CompareString);
920 for(i=0; i < m_Count; i++)
922 m_List.Add((LPCTSTR) ppSortArray[i]);
924 m_Liste1.RemoveAll();
925 delete [] ppSortArray;
929 /*********************************************************************/
931 ** Vers. 1.1
932 ** NEW: CopyList()
934 void CACListWnd::CopyList()
936 m_DisplayList.Copy(m_SearchList);
937 m_lCount = (long)m_DisplayList.GetSize();
938 if(m_lCount)
939 FindString(0,_T(""),true);
942 /*********************************************************************/