1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoioseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
23 * Extends the CComboBoxEx class with a history of entered
\r
24 * values. An example of such a combobox is the Start/Run
\r
25 * dialog which lists the programs you used last in a combobox.
\r
26 * To use this class do the following:
\r
27 * -# add both files HistoryCombo.h and HistoryCombo.cpp to your project.
\r
28 * -# add a ComboBoxEx to your dialog
\r
29 * -# create a variable for the ComboBox of type control
\r
30 * -# change the type of the created variable from CComboBoxEx to
\r
32 * -# in your OnInitDialog() call SetURLHistory(TRUE) if your ComboBox
\r
34 * -# in your OnInitDialog() call the LoadHistory() method
\r
35 * -# in your OnOK() or somewhere similar call the SaveHistory() method
\r
39 class CHistoryCombo : public CComboBoxEx
\r
43 CHistoryCombo(BOOL bAllowSortStyle = FALSE);
\r
44 virtual ~CHistoryCombo();
\r
49 * Adds the string \a str to both the combobox and the history.
\r
50 * If \a pos is specified, insert the string at the specified
\r
51 * position, otherwise add it to the end of the list.
\r
53 int AddString(CString str, INT_PTR pos = -1);
\r
56 DECLARE_MESSAGE_MAP()
\r
57 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
\r
58 virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
59 virtual void PreSubclassWindow();
\r
61 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
\r
62 afx_msg void OnTimer(UINT_PTR nIDEvent);
\r
63 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
\r
65 void CreateToolTip();
\r
70 * Clears the history in the registry/inifile and the ComboBox.
\r
71 * \param bDeleteRegistryEntries if this value is true then the registry key
\r
72 * itself is deleted.
\r
74 void ClearHistory(BOOL bDeleteRegistryEntries = TRUE);
\r
76 * When \a bURLHistory is TRUE, treat the combo box entries
\r
77 * as URLs. This activates Shell URL auto completion and
\r
78 * the display of special icons in front of the combobox
\r
79 * entries. Default is FALSE.
\r
81 void SetURLHistory(BOOL bURLHistory);
\r
83 * When \a bPathHistory is TRUE, treat the combo box entries
\r
84 * as Paths. This activates Shell Path auto completion and
\r
85 * the display of special icons in front of the combobox
\r
86 * entries. Default is FALSE.
\r
88 void SetPathHistory(BOOL bPathHistory);
\r
90 * Sets the maximum numbers of entries in the history list.
\r
91 * If the history is larger as \em nMaxItems then the last
\r
92 * items in the history are deleted.
\r
94 void SetMaxHistoryItems(int nMaxItems);
\r
96 * Saves the history to the registry/inifile.
\r
97 * \remark if you haven't called LoadHistory() before this method
\r
100 void SaveHistory();
\r
102 * Loads the history from the registry/inifile and fills in the
\r
104 * \param lpszSection a section name where to put the entries, e.g. "lastloadedfiles"
\r
105 * \param lpszKeyPrefix a prefix to use for the history entries in registry/inifiles. E.g. "file" or "entry"
\r
107 CString LoadHistory(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix);
\r
110 * Returns the string in the combobox which is either selected or the user has entered.
\r
112 CString GetString() const;
\r
116 * Will be called whenever the return key is pressed while the
\r
117 * history combo has the input focus. A derived class may implement
\r
118 * a special behavior for the return key by overriding this method.
\r
119 * It must return true to prevent the default processing for the
\r
120 * return key. The default implementation returns false.
\r
122 virtual bool OnReturnKeyPressed() { return false; }
\r
125 * Removes the selected item from the combo box and updates
\r
126 * the registry settings. Returns TRUE if successful.
\r
128 BOOL RemoveSelectedItem();
\r
131 CStringArray m_arEntries;
\r
132 CString m_sSection;
\r
133 CString m_sKeyPrefix;
\r
134 int m_nMaxHistoryItems;
\r
135 BOOL m_bAllowSortStyle;
\r
136 BOOL m_bURLHistory;
\r
137 BOOL m_bPathHistory;
\r
138 HWND m_hWndToolTip;
\r
139 TOOLINFO m_ToolInfo;
\r