OSDN Git Service

FilepathEdit.*: Enable Ctrl+C shortcut key
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 16 Jul 2018 10:29:58 +0000 (19:29 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 16 Jul 2018 10:29:58 +0000 (19:29 +0900)
Src/FilepathEdit.cpp
Src/FilepathEdit.h

index a50b74e..8c394be 100644 (file)
@@ -42,6 +42,7 @@ BEGIN_MESSAGE_MAP(CFilepathEdit, CEdit)
        ON_WM_CONTEXTMENU()
        ON_WM_CTLCOLOR_REFLECT()
        ON_WM_NCPAINT()
+       ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
 END_MESSAGE_MAP()
 
 
@@ -321,6 +322,21 @@ void CFilepathEdit::OnNcPaint()
        dc.FillSolidRect(CRect(rect.left + margin, rect.bottom - margin, rect.right, rect.bottom), m_crBackGnd);
 }
 
+void CFilepathEdit::OnEditCopy()
+{
+       Copy();
+}
+
+BOOL CFilepathEdit::PreTranslateMessage(MSG *pMsg)
+{
+       if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
+       {
+               if (::TranslateAccelerator (m_hWnd, static_cast<CFrameWnd *>(AfxGetMainWnd())->GetDefaultAccelerator(), pMsg))
+                       return TRUE;
+       }
+       return CEdit::PreTranslateMessage(pMsg);
+}
+
 /**
  * @brief Set the control to look active/inactive.
  * This function sets control to look like an active control. We don't
index 63288a6..4aa44e9 100644 (file)
@@ -46,8 +46,10 @@ public :
        void SetTextColor(COLORREF rgb);
 
 protected:
+       virtual BOOL PreTranslateMessage(MSG *pMsg);
        afx_msg void OnContextMenu(CWnd*, CPoint point);
        afx_msg void OnNcPaint();
+       afx_msg void OnEditCopy();
        HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
        DECLARE_MESSAGE_MAP();