From: Kimmo Varis Date: Mon, 6 Jun 2005 15:50:17 +0000 (+0000) Subject: PATCH: [ 1215235 ] Allow removing items from comboboxes X-Git-Tag: 2.16.5~5899 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6fc5a6858a710d81fae3ba9513932bb9512bd0a5;p=winmerge-jp%2Fwinmerge-jp.git PATCH: [ 1215235 ] Allow removing items from comboboxes --- diff --git a/Src/Common/SuperComboBox.cpp b/Src/Common/SuperComboBox.cpp index 5b333ff47..ce4660fbd 100644 --- a/Src/Common/SuperComboBox.cpp +++ b/Src/Common/SuperComboBox.cpp @@ -219,17 +219,31 @@ BOOL CSuperComboBox::OnSelchange() BOOL CSuperComboBox::PreTranslateMessage(MSG* pMsg) { - if (m_bAutoComplete - && pMsg->message == WM_KEYDOWN) - { - m_bDoComplete = TRUE; + if (pMsg->message == WM_KEYDOWN) + { + int nVirtKey = (int) pMsg->wParam; + // If Shift+Del pressed when dropdown is open, delete selected item + // from dropdown list + if (GetAsyncKeyState(VK_SHIFT)) + { + if (GetDroppedState() && nVirtKey == VK_DELETE) + { + int cursel = GetCurSel(); + if (cursel != CB_ERR) + DeleteString(cursel); + return FALSE; // No need to further handle this message + } + } + if (m_bAutoComplete) + { + m_bDoComplete = TRUE; - int nVirtKey = (int) pMsg->wParam; - if (nVirtKey == VK_DELETE || nVirtKey == VK_BACK) - m_bDoComplete = FALSE; - } + if (nVirtKey == VK_DELETE || nVirtKey == VK_BACK) + m_bDoComplete = FALSE; + } + } - return CComboBox::PreTranslateMessage(pMsg); + return CComboBox::PreTranslateMessage(pMsg); } void CSuperComboBox::SetAutoAdd(BOOL bAdd, UINT idstrAddText) diff --git a/Src/OpenDlg.cpp b/Src/OpenDlg.cpp index b85c01633..ca8e35803 100644 --- a/Src/OpenDlg.cpp +++ b/Src/OpenDlg.cpp @@ -224,15 +224,35 @@ void COpenDlg::OnOK() mf->m_options.SaveOption(OPT_FILEFILTER_CURRENT, m_strExt); } - m_ctlLeft.SaveState(_T("Files\\Left")); - m_ctlRight.SaveState(_T("Files\\Right")); - m_ctlExt.SaveState(_T("Files\\Ext")); - + SaveComboboxStates(); theApp.WriteProfileInt(_T("Settings"), _T("Recurse"), m_bRecurse); CDialog::OnOK(); } +/** + * @brief Called when dialog is closed via Cancel. + * + * Open-dialog is canceled when 'Cancel' button is selected or + * Esc-key is pressed. Save combobox states, since user may have + * removed items from them and don't want them to re-appear. + */ +void COpenDlg::OnCancel() +{ + SaveComboboxStates(); + CDialog::OnCancel(); +} + +/** + * @brief Save File- and filter-combobox states. + */ +void COpenDlg::SaveComboboxStates() +{ + m_ctlLeft.SaveState(_T("Files\\Left")); + m_ctlRight.SaveState(_T("Files\\Right")); + m_ctlExt.SaveState(_T("Files\\Ext")); +} + /** @brief Handler for WM_INITDIALOG; conventional location to initialize controls */ BOOL COpenDlg::OnInitDialog() { diff --git a/Src/OpenDlg.h b/Src/OpenDlg.h index 2ddf29749..9f38fe64d 100644 --- a/Src/OpenDlg.h +++ b/Src/OpenDlg.h @@ -97,6 +97,8 @@ protected: afx_msg void OnRightButton(); afx_msg void OnSaveProjectButton(); virtual void OnOK(); + virtual void OnCancel(); + afx_msg void SaveComboboxStates(); virtual BOOL OnInitDialog(); afx_msg void OnSelchangeLeftCombo(); afx_msg void OnSelchangeRightCombo(); diff --git a/Src/readme.txt b/Src/readme.txt index f9fd00be5..b165adb9b 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,8 @@ +2005-06-06 Kimmo + PATCH: [ 1215235 ] Allow removing items from comboboxes + Src: OpenDlg.cpp OpenDlg.h + Src/Common: SuperComboBox.cpp + 2005-06-05 Tim RFE: [ 1203923 ] New refresh icon Src/res: Toolbar.bmp