OSDN Git Service

PATCH: [ 1215235 ] Allow removing items from comboboxes
authorKimmo Varis <kimmov@gmail.com>
Mon, 6 Jun 2005 15:50:17 +0000 (15:50 +0000)
committerKimmo Varis <kimmov@gmail.com>
Mon, 6 Jun 2005 15:50:17 +0000 (15:50 +0000)
Src/Common/SuperComboBox.cpp
Src/OpenDlg.cpp
Src/OpenDlg.h
Src/readme.txt

index 5b333ff..ce4660f 100644 (file)
@@ -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)
index b85c016..ca8e358 100644 (file)
@@ -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() 
 {
index 2ddf297..9f38fe6 100644 (file)
@@ -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();
index f9fd00b..b165adb 100644 (file)
@@ -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