Prevent the recycle bin from even getting monitored
[TortoiseGit.git] / src / TortoiseProc / HistoryDlg.cpp
blob2082397e75f03386f2cedb95748aecbf4877d47f
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008,2011 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "Registry.h"
23 #include "HistoryDlg.h"
26 IMPLEMENT_DYNAMIC(CHistoryDlg, CResizableStandAloneDialog)
27 CHistoryDlg::CHistoryDlg(CWnd* pParent /*=NULL*/)
28 : CResizableStandAloneDialog(CHistoryDlg::IDD, pParent)
32 CHistoryDlg::~CHistoryDlg()
36 void CHistoryDlg::DoDataExchange(CDataExchange* pDX)
38 CResizableStandAloneDialog::DoDataExchange(pDX);
39 DDX_Control(pDX, IDC_HISTORYLIST, m_List);
43 BEGIN_MESSAGE_MAP(CHistoryDlg, CResizableStandAloneDialog)
44 ON_BN_CLICKED(IDOK, OnBnClickedOk)
45 ON_LBN_DBLCLK(IDC_HISTORYLIST, OnLbnDblclkHistorylist)
46 ON_WM_KEYDOWN()
47 END_MESSAGE_MAP()
50 void CHistoryDlg::OnBnClickedOk()
52 int pos = m_List.GetCurSel();
53 if (pos != LB_ERR)
55 m_SelectedText = m_history->GetEntry(pos);
57 else
58 m_SelectedText.Empty();
59 OnOK();
62 BOOL CHistoryDlg::OnInitDialog()
64 CResizableStandAloneDialog::OnInitDialog();
66 // calculate and set listbox width
67 CDC* pDC=m_List.GetDC();
68 CSize itemExtent;
69 int horizExtent = 1;
70 for (size_t i = 0; i < m_history->GetCount(); ++i)
72 CString sEntry = m_history->GetEntry(i);
73 sEntry.Remove('\r');
74 sEntry.Replace('\n', ' ');
75 m_List.AddString(sEntry);
76 itemExtent = pDC->GetTextExtent(sEntry);
77 horizExtent = max(horizExtent, itemExtent.cx+5);
79 m_List.SetHorizontalExtent(horizExtent);
80 ReleaseDC(pDC);
82 AddAnchor(IDC_HISTORYLIST, TOP_LEFT, BOTTOM_RIGHT);
83 AddAnchor(IDOK, BOTTOM_RIGHT);
84 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
85 EnableSaveRestore(_T("HistoryDlg"));
86 m_List.SetFocus();
87 return FALSE;
90 void CHistoryDlg::OnLbnDblclkHistorylist()
92 int pos = m_List.GetCurSel();
93 if (pos != LB_ERR)
95 m_SelectedText = m_history->GetEntry(pos);
96 OnOK();
98 else
99 m_SelectedText.Empty();
102 BOOL CHistoryDlg::PreTranslateMessage(MSG* pMsg)
104 if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_DELETE))
106 int pos = m_List.GetCurSel();
107 if (pos != LB_ERR)
109 m_List.DeleteString(pos);
110 m_List.SetCurSel(min(pos, m_List.GetCount() - 1));
111 m_history->RemoveEntry(pos);
112 m_history->Save();
113 return TRUE;
117 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);