0

We have an MFC SDI application in VS2010 with a CMFCToolBar containing a CMFCToolBarEditBoxButton. Is there a way to handle the paste event when a user pastes something into that edit box?

We handle ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) in the main window but the paste message isn't getting raised when focus is inside the CMFCToolBarEditBoxButton.

CoderDake
  • 1,497
  • 2
  • 15
  • 30
sleepp
  • 47
  • 1
  • 7

1 Answers1

0

From the MFC Sources [afxtoolbareditboxbutton.cpp], it looks like the 'Paste()' function of the underlying CMFCToolBarEditCtrl is called directly during Ctrl-V, the 'Paste()' member function just sends WM_PASTE to the edit window.

Could do try making a handler for WM_PASTE?

This SO Answer has an example of how to do this.

Community
  • 1
  • 1
Edward Clements
  • 5,040
  • 2
  • 21
  • 27
  • I'm having trouble figuring out how to attach a handler to the CEdit already created inside the CMFCToolBarEditBoxButton or subclassing the button to creates a different CEdit or where else WM_PASTE could be handled. Any ideas? Thanks! – sleepp Oct 03 '13 at 14:17
  • You could override `CMFCToolBarEditBoxButton::CreateEdit()` [MFC Source afxtoolbareditboxbutton.cpp] and supply your own CEdit-derived class where you can handle the WM_PASTE? – Edward Clements Oct 03 '13 at 18:28