OSDN Git Service

Implement issue #772: Add preference option to clear "Don't ask this question again...
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Wed, 7 Jul 2021 12:59:39 +0000 (21:59 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Wed, 7 Jul 2021 12:59:39 +0000 (21:59 +0900)
Src/Merge.rc
Src/SubeditList.cpp
Src/SubeditList.h
Src/SubstitutionFiltersDlg.cpp
Src/SubstitutionFiltersDlg.h

index 6f5ca7f..f1ff1c3 100644 (file)
@@ -1536,7 +1536,7 @@ IDD_PROPPAGE_EDITOR_SYNTAX DIALOGEX 0, 0, 255, 242
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION\r
 FONT 8, "MS Shell Dlg", 0, 0, 0x1\r
 BEGIN\r
-    CONTROL         "",IDC_SYNTAX_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 7, 7, 241, 215\r
+    CONTROL         "",IDC_SYNTAX_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 7, 7, 241, 215\r
     PUSHBUTTON      "Defaults", IDC_COMPARE_DEFAULTS, 161, 228, 88, 14\r
 END\r
 \r
@@ -1546,7 +1546,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN\r
     LTEXT           "WinMerge allows hiding some common message boxes. Press the Reset button to make all message boxes visible again.",IDC_STATIC,7,7,240,30\r
     PUSHBUTTON      "Reset",IDC_RESET_ALL_MESSAGE_BOXES,161,28,88,14,NOT WS_TABSTOP\r
-    CONTROL         "",IDC_MESSAGEBOX_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 7, 47, 241, 195\r
+    CONTROL         "",IDC_MESSAGEBOX_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, 7, 47, 241, 195\r
 END\r
 \r
 IDD_MESSAGE_BOX DIALOGEX 0, 0, 186, 95\r
index fec61cf..e469bc3 100644 (file)
@@ -251,12 +251,18 @@ int CSubeditList::HitTestEx(CPoint &point, int *col) const
        return -1;
 }
 
+#ifndef WM_MOUSEHWHEEL
+#  define WM_MOUSEHWHEEL 0x20e
+#endif
 
 BEGIN_MESSAGE_MAP(CSubeditList, CListCtrl)
        //{{AFX_MSG_MAP(CSubeditList)
                // NOTE - the ClassWizard will add and remove mapping macros here.
-       ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SUBSTITUTION_FILTERS, OnEndLabelEdit)
        ON_WM_LBUTTONDOWN()
+       ON_WM_VSCROLL()
+       ON_WM_HSCROLL()
+       ON_WM_MOUSEWHEEL()
+       ON_WM_MOUSEHWHEEL()
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -416,29 +422,16 @@ void CSubeditList::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
        CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
 }
 
-void CSubeditList::OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
+BOOL CSubeditList::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
 {
-       LV_DISPINFO *plvDispInfo = (LV_DISPINFO *)pNMHDR;
-       LV_ITEM *plvItem = &plvDispInfo->item;
-        
-       if (plvItem->pszText != NULL)
-       {
-               SetItemText(plvItem->iItem, plvItem->iSubItem, plvItem->pszText);
-       }
-       *pResult = FALSE;
+       if( GetFocus() != this ) SetFocus();
+       return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
 }
 
-void CSubeditList::OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult)
+void CSubeditList::OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt)
 {
-       LV_DISPINFO* plvDispInfo = (LV_DISPINFO*)pNMHDR;
-       LV_ITEM* plvItem = &plvDispInfo->item;
-       plvItem->iSubItem = 1;
-
-//     if (plvItem->pszText != NULL)
-//     {
-//             SetItemText(plvItem->iItem, plvItem->iSubItem, plvItem->pszText);
-//     }
-       *pResult = FALSE;
+       if( GetFocus() != this ) SetFocus();
+       CListCtrl::OnMouseHWheel(nFlags, zDelta, pt);
 }
 
 void CSubeditList::OnLButtonDown(UINT nFlags, CPoint point)
@@ -452,41 +445,39 @@ void CSubeditList::OnLButtonDown(UINT nFlags, CPoint point)
                //if ((GetItemState(index, flag) & flag) == flag && colnum > 0)
                if ((GetItemState(index, flag) & flag) == flag)
                {
-                       // Add check for LVS_EDITLABELS
-                       if (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_EDITLABELS)
+                       if (m_readOnlyColumns.find(colnum) == m_readOnlyColumns.end())
                        {
-                               if (m_readOnlyColumns.find(colnum) == m_readOnlyColumns.end())
-                                       if (m_binaryValueColumns.find(colnum) != m_binaryValueColumns.end())
+                               if (m_binaryValueColumns.find(colnum) != m_binaryValueColumns.end())
+                               {
+                                       CString text = GetItemText(index, colnum);
+                                       if (IsWin7_OrGreater())
                                        {
-                                               CString text = GetItemText(index, colnum);
-                                               if (IsWin7_OrGreater())
-                                               {
-                                                       SetItemText(index, colnum, text.Compare(_T("\u2611")) == 0 ?
-                                                               _T("\u2610") : _T("\u2611"));
-                                               }
-                                               else
-                                               {
-                                                       SetItemText(index, colnum, text.Compare(_T("true")) == 0 ?
-                                                               _T("false") : _T("true"));
-                                               }
+                                               SetItemText(index, colnum, text.Compare(_T("\u2611")) == 0 ?
+                                                       _T("\u2610") : _T("\u2611"));
                                        }
                                        else
                                        {
-                                               switch (GetEditStyle(colnum))
-                                               {
-                                               case EditStyle::EDIT_BOX:
-                                                       EditSubLabel(index, colnum);
-                                                       break;
-                                               case EditStyle::DROPDOWN_LIST:
-                                                       EditSubLabelDropdownList(index, colnum);
-                                                       break;
-                                               case EditStyle::WILDCARD_DROP_LIST:
-                                                       EditSubLabelWildcardDropList(index, colnum);
-                                                       break;
-                                               default:
-                                                       break;
-                                               }
+                                               SetItemText(index, colnum, text.Compare(_T("true")) == 0 ?
+                                                       _T("false") : _T("true"));
                                        }
+                               }
+                               else
+                               {
+                                       switch (GetEditStyle(colnum))
+                                       {
+                                       case EditStyle::EDIT_BOX:
+                                               EditSubLabel(index, colnum);
+                                               break;
+                                       case EditStyle::DROPDOWN_LIST:
+                                               EditSubLabelDropdownList(index, colnum);
+                                               break;
+                                       case EditStyle::WILDCARD_DROP_LIST:
+                                               EditSubLabelWildcardDropList(index, colnum);
+                                               break;
+                                       default:
+                                               break;
+                                       }
+                               }
                        }
                }
                else
@@ -501,11 +492,11 @@ void CSubeditList::OnLButtonDown(UINT nFlags, CPoint point)
 // CInPlaceEdit
 
 CInPlaceEdit::CInPlaceEdit(int iItem, int iSubItem, CString sInitText)
-:m_sInitText( sInitText )
+: m_sInitText( sInitText )
+, m_iItem(iItem)
+, m_iSubItem(iSubItem)
+, m_bESC(false)
 {
-       m_iItem = iItem;
-       m_iSubItem = iSubItem;
-       m_bESC = FALSE;
 }
 
 CInPlaceEdit::~CInPlaceEdit()
@@ -550,23 +541,12 @@ void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd)
 {
        CEdit::OnKillFocus(pNewWnd);
 
-       CString str;
-       GetWindowText(str);
-
-       // Send Notification to parent of ListView ctrl
-       LV_DISPINFO dispinfo;
-       dispinfo.hdr.hwndFrom = GetParent()->m_hWnd;
-       dispinfo.hdr.idFrom = GetDlgCtrlID();
-       dispinfo.hdr.code = LVN_ENDLABELEDIT;
-
-       dispinfo.item.mask = LVIF_TEXT;
-       dispinfo.item.iItem = m_iItem;
-       dispinfo.item.iSubItem = m_iSubItem;
-       dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str);
-       dispinfo.item.cchTextMax = str.GetLength();
-
-       GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(), 
-                                       (LPARAM)&dispinfo );
+       if (!m_bESC)
+       {
+               CString str;
+               GetWindowText(str);
+               static_cast<CListCtrl*>(GetParent())->SetItemText(m_iItem, m_iSubItem, str);
+       }
 
        DestroyWindow();
 }
@@ -589,7 +569,6 @@ void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
                return;
        }
 
-
        CEdit::OnChar(nChar, nRepCnt, nFlags);
 
        // Resize edit control if needed
@@ -647,10 +626,10 @@ int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
 CInPlaceComboBox::CInPlaceComboBox(int iItem, int iSubItem, CString sInitText, const std::vector<String>& list)
 : m_sInitText( sInitText )
 , m_list(list)
+, m_iItem(iItem)
+, m_iSubItem(iSubItem)
+, m_bESC(false)
 {
-       m_iItem = iItem;
-       m_iSubItem = iSubItem;
-       m_bESC = FALSE;
 }
 
 CInPlaceComboBox::~CInPlaceComboBox()
@@ -662,6 +641,7 @@ BEGIN_MESSAGE_MAP(CInPlaceComboBox, CComboBox)
        //{{AFX_MSG_MAP(CInPlaceComboBox)
        ON_WM_KILLFOCUS()
        ON_WM_NCDESTROY()
+       ON_WM_CHAR()
        ON_WM_CREATE()
        ON_WM_LBUTTONDOWN()
        //}}AFX_MSG_MAP
@@ -693,9 +673,12 @@ void CInPlaceComboBox::OnKillFocus(CWnd* pNewWnd)
 {
        CComboBox::OnKillFocus(pNewWnd);
 
-       CString str;
-       GetWindowText(str);
-       static_cast<CListCtrl*>(GetParent())->SetItemText(m_iItem, m_iSubItem, str);
+       if (!m_bESC)
+       {
+               CString str;
+               GetWindowText(str);
+               static_cast<CListCtrl*>(GetParent())->SetItemText(m_iItem, m_iSubItem, str);
+       }
 
        DestroyWindow();
 }
@@ -707,6 +690,19 @@ void CInPlaceComboBox::OnNcDestroy()
        delete this;
 }
 
+void CInPlaceComboBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+       if (nChar == VK_ESCAPE || nChar == VK_RETURN)
+       {
+               if (nChar == VK_ESCAPE)
+                       m_bESC = TRUE;
+               GetParent()->SetFocus();
+               return;
+       }
+
+       CComboBox::OnChar(nChar, nRepCnt, nFlags);
+}
+
 int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
 {
        if (CComboBox::OnCreate(lpCreateStruct) == -1)
index 521d400..46d21f2 100644 (file)
@@ -77,6 +77,7 @@ protected:
        //{{AFX_MSG(CInPlaceComboBox)
        afx_msg void OnKillFocus(CWnd* pNewWnd);
        afx_msg void OnNcDestroy();
+       afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        //}}AFX_MSG
  
@@ -150,8 +151,8 @@ public:
        afx_msg int HitTestEx(CPoint& point, int* col) const;
        afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
        afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
-       afx_msg void OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
-       afx_msg void OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
+       afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+       afx_msg void OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
        afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
        //}}AFX_MSG
 
index eb870cf..57eeed4 100644 (file)
@@ -54,7 +54,6 @@ BEGIN_MESSAGE_MAP(SubstitutionFiltersDlg, CTrPropertyPage)
        ON_BN_CLICKED(IDC_LFILTER_ADDBTN, OnBnClickedAddBtn)
        ON_BN_CLICKED(IDC_LFILTER_CLEARBTN, OnBnClickedClearBtn)
        ON_BN_CLICKED(IDC_LFILTER_REMOVEBTN, OnBnClickedRemovebtn)
-       ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SUBSTITUTION_FILTERS, OnEndLabelEdit)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -216,11 +215,3 @@ void SubstitutionFiltersDlg::OnBnClickedRemovebtn()
                m_listFilters.EnsureVisible(newSel, bPartialOk);
        }
 }
-
-/**
- * @brief Called when in-place editing has finished.
- */
-void SubstitutionFiltersDlg::OnEndLabelEdit(NMHDR *pNMHDR, LRESULT *pResult)
-{
-       m_listFilters.OnEndLabelEdit(pNMHDR, pResult);
-}
index 1d1e129..a10b170 100644 (file)
@@ -45,7 +45,6 @@ protected:
        afx_msg void OnBnClickedAddBtn();
        afx_msg void OnBnClickedClearBtn();
        afx_msg void OnBnClickedRemovebtn();
-       afx_msg void OnEndLabelEdit(NMHDR* pNMHDR, LRESULT* pResult);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()