1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoioseSVN
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.
23 * Extends the CComboBoxEx class with a history of entered
24 * values. An example of such a combobox is the Start/Run
25 * dialog which lists the programs you used last in a combobox.
26 * To use this class do the following:
27 * -# add both files HistoryCombo.h and HistoryCombo.cpp to your project.
28 * -# add a ComboBoxEx to your dialog
29 * -# create a variable for the ComboBox of type control
30 * -# change the type of the created variable from CComboBoxEx to
32 * -# in your OnInitDialog() call SetURLHistory(TRUE) if your ComboBox
34 * -# in your OnInitDialog() call the LoadHistory() method
35 * -# in your OnOK() or somewhere similar call the SaveHistory() method
40 class CHistoryCombo
: public CComboBoxEx
44 CHistoryCombo(BOOL bAllowSortStyle
= FALSE
);
45 virtual ~CHistoryCombo();
50 * Adds the string \a str to both the combobox and the history.
51 * If \a pos is specified, insert the string at the specified
52 * position, otherwise add it to the end of the list.
54 int AddString(CString str
, INT_PTR pos
= -1);
55 void DisableTooltip(){m_bDyn
= FALSE
;} //because rebase need disable combox tooltip to show version info
58 virtual BOOL
PreCreateWindow(CREATESTRUCT
& cs
);
59 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
60 virtual void PreSubclassWindow();
62 afx_msg
void OnMouseMove(UINT nFlags
, CPoint point
);
63 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
64 afx_msg
int OnCreate(LPCREATESTRUCT lpCreateStruct
);
71 * Clears the history in the registry/inifile and the ComboBox.
72 * \param bDeleteRegistryEntries if this value is true then the registry key
75 void ClearHistory(BOOL bDeleteRegistryEntries
= TRUE
);
77 * When \a bURLHistory is TRUE, treat the combo box entries
78 * as URLs. This activates Shell URL auto completion and
79 * the display of special icons in front of the combobox
80 * entries. Default is FALSE.
82 void SetURLHistory(BOOL bURLHistory
);
84 * When \a bPathHistory is TRUE, treat the combo box entries
85 * as Paths. This activates Shell Path auto completion and
86 * the display of special icons in front of the combobox
87 * entries. Default is FALSE.
89 void SetPathHistory(BOOL bPathHistory
);
91 * Sets the maximum numbers of entries in the history list.
92 * If the history is larger as \em nMaxItems then the last
93 * items in the history are deleted.
95 void SetMaxHistoryItems(int nMaxItems
);
97 * Saves the history to the registry/inifile.
98 * \remark if you haven't called LoadHistory() before this method
103 * Loads the history from the registry/inifile and fills in the
105 * \param lpszSection a section name where to put the entries, e.g. "lastloadedfiles"
106 * \param lpszKeyPrefix a prefix to use for the history entries in registry/inifiles. E.g. "file" or "entry"
108 CString
LoadHistory(LPCTSTR lpszSection
, LPCTSTR lpszKeyPrefix
);
111 * Returns the string in the combobox which is either selected or the user has entered.
113 CString
GetString() const;
115 void AddString(STRING_VECTOR
&list
);
119 * Will be called whenever the return key is pressed while the
120 * history combo has the input focus. A derived class may implement
121 * a special behavior for the return key by overriding this method.
122 * It must return true to prevent the default processing for the
123 * return key. The default implementation returns false.
125 virtual bool OnReturnKeyPressed() { return false; }
128 * Removes the selected item from the combo box and updates
129 * the registry settings. Returns TRUE if successful.
131 BOOL
RemoveSelectedItem();
134 CStringArray m_arEntries
;
136 CString m_sKeyPrefix
;
137 int m_nMaxHistoryItems
;
138 BOOL m_bAllowSortStyle
;