Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top